-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
149 lines (118 loc) · 4.35 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import sys
import qdarkstyle
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication, QMainWindow, QGridLayout, QWidget, QTableWidget, QTableWidgetItem
from PyQt5 import QtCore, QtGui, QtWidgets
from f import Ui_MainWindow, UI_LoginWindow
import sqlite3 as db
import pandas as pd
from wallet import Wallet
# create app
app = QtWidgets.QApplication(sys.argv)
app.setStyleSheet(qdarkstyle.load_stylesheet())
# init
MainWindow = QtWidgets.QMainWindow()
ui_log = UI_LoginWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
ui_login = UI_LoginWindow()
# ui_login.show()
user = Wallet()
# hook logic
def ViewPng():
pass
def test():
user.written_off(name_wallet=ui.Wallet_list.currentText(), amount=int(ui.lineEdit_2.text()),
category=str(ui.lineEdit.text()), message=str(ui.lineEdit_comments.text()))
ui.lineEdit_2.clear()
ui.lineEdit.clear()
entries = user.view()
print(entries)
ui.listwidget.setRowCount(len(entries))
for i in range(len(entries)):
f = 0
for j in range(2, 6):
ui.listwidget.setItem(i, f, QTableWidgetItem(str(entries[i][j])))
f+=1
ui.listwidget.resizeColumnsToContents()
wallet_list = user.get_wallet()
print(wallet_list)
ui.Tabel_view.setRowCount(len(wallet_list))
for i in range(len(wallet_list)):
for j in range(2):
ui.Tabel_view.setItem(i, j, QTableWidgetItem(str(wallet_list[i][j])))
ui.listwidget.resizeColumnsToContents()
def show_it(the_password):
Login(the_password)
ui.login.got.connect(show_it)
def statistic(self):
ui.stat.initUI([user.login, user.password])
def Login(data):
if not user.sign_in(login=str(data[1]), password=str(data[0])):
return None
MainWindow.show()
ui.login.close()
entries = user.view()
ui.listwidget.setRowCount(len(entries))
for i in range(len(entries)):
f = 0
for j in range(2, 6):
ui.listwidget.setItem(i, f, QTableWidgetItem(str(entries[i][j])))
f+=1
wallet_list = user.get_wallet()
print(wallet_list)
ui.Tabel_view.setRowCount(len(wallet_list))
for i in range(len(wallet_list)):
for j in range(2):
ui.Tabel_view.setItem(i, j, QTableWidgetItem(str(wallet_list[i][j])))
ui.listwidget.resizeColumnsToContents()
wallet_name()
def wallet_name():
ui.Wallet_list.clear()
ui.QComboBox_lst.clear()
lst = user.view_wallet()
for item in lst:
ui.Wallet_list.addItem(str(item))
ui.QComboBox_lst.addItem(str(item))
def Registration():
user.init_user(login=str(ui.lineEdit_login.text()), password=str(ui.lineEdit_password.text()), name='Test')
ui_log.lineEdit_login.clear()
ui_log.lineEdit_password.clear()
def refill():
user.refill(value=int(ui.lineEdit_Sum.text()), name_wallet=str(ui.QComboBox_lst.currentText()))
ui.lineEdit_Sum.clear()
wallet_list = user.get_wallet()
ui.Tabel_view.setRowCount(len(wallet_list))
for i in range(len(wallet_list)):
for j in range(2):
ui.Tabel_view.setItem(i, j, QTableWidgetItem(str(wallet_list[i][j])))
def AddWalet():
user.init_wallet(value=int(ui.lineEdit_Value.text()), name_wallet=str(ui.lineEdit_name.text()))
ui.lineEdit_Value.clear()
ui.lineEdit_name.clear()
wallet_list = user.get_wallet()
ui.Tabel_view.setRowCount(len(wallet_list))
for i in range(len(wallet_list)):
for j in range(2):
ui.Tabel_view.setItem(i, j, QTableWidgetItem(str(wallet_list[i][j])))
wallet_name()
def Exit():
MainWindow.close()
ui.login.show()
db_connection = db.connect('transaction.db')
df1 = pd.read_sql_query('SELECT * FROM users', db_connection)
print(df1)
df2 = pd.read_sql_query('SELECT * FROM wallets', db_connection)
print(df2)
df3 = pd.read_sql_query('SELECT * FROM expenses', db_connection)
print(df3)
ui.pushButton.clicked.connect(test)
ui.pushButton_1.clicked.connect(ViewPng)
ui_log.pushButton_Login.clicked.connect(Login)
ui.pushButton_AddWallet.clicked.connect(AddWalet)
ui.pushButton_Exit.clicked.connect(Exit)
ui_log.pushButton_Sign_up.clicked.connect(Registration)
ui.pushButton_1.clicked.connect(statistic)
ui.pushButton_refill.clicked.connect(refill)
# main loop
sys.exit(app.exec_())