-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmincoin-qt.py
More file actions
74 lines (53 loc) · 1.92 KB
/
mincoin-qt.py
File metadata and controls
74 lines (53 loc) · 1.92 KB
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
from gui.mincoin import Ui_MainWindow
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
import time
import wallet
import base64
import rpc
my_wallet = wallet.Wallet()
my_rpc = rpc.RPC()
class TransactionTable(QtCore.QAbstractTableModel):
COLUMNS = ['txid', 'to', 'amount']
def headerData(self, index: int, orientation: QtCore.Qt.Orientation, role: int=None):
if orientation == QtCore.Qt.Horizontal and role == QtCore.Qt.DisplayRole:
return self.COLUMNS[index]
return QtCore.QVariant()
def rowCount(self, parent: QtCore.QModelIndex=None, *args, **kwargs):
return len([])
def columnCount(self, QModelIndex_parent=None, *args, **kwargs):
return len(self.COLUMNS)
def data(self, index: QtCore.QModelIndex, role: int=None):
if role == QtCore.Qt.DisplayRole:
return 'cell'
return QtCore.QVariant()
def do_send(ui: Ui_MainWindow):
amount = int(ui.send_amount.text())
recipient = str(ui.recipient.text())
my_wallet.send(recipient, amount)
def setup_buttons(ui):
ui.generate_payment_request.clicked.connect(
lambda: ui.address.setText(my_wallet.generate_address(ui.label.text().strip())))
transaction_table = TransactionTable()
ui.transactions_2.setModel(transaction_table)
ui.send.clicked.connect(lambda: do_send(ui))
class StateUpdater(QtCore.QThread):
def __init__(self, ui):
super().__init__()
self.ui = ui
# TODO
def run(self):
while True:
self.ui.balance.setText(str(my_wallet.get_balance()))
height = my_rpc.get_info()['top_block_height']
self.ui.blockheight.setText(str(height))
time.sleep(2)
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
setup_buttons(ui)
state_updater = StateUpdater(ui)
state_updater.start()
sys.exit(app.exec_())