electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 1eef00ca8351b39da7e8814dbe979ac4d0422711
parent b9b5f1e58c954b5e195b00c109a52086101c2c88
Author: ThomasV <thomasv@gitorious>
Date:   Sun, 12 Feb 2012 07:27:32 +0100

qt gui:history

Diffstat:
Mclient/gui_qt.py | 88+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 71 insertions(+), 17 deletions(-)

diff --git a/client/gui_qt.py b/client/gui_qt.py @@ -1,4 +1,4 @@ -import sys, time +import sys, time, datetime # todo: see PySide @@ -32,6 +32,8 @@ class BitcoinWidget(QMainWindow): tabs.addTab(self.create_contacts_tab(),'Contacts') tabs.addTab(self.create_wall_tab(), 'Wall') tabs.setMinimumSize(600, 400) + tabs.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) + tabs.show() self.create_status_bar() @@ -60,23 +62,81 @@ class BitcoinWidget(QMainWindow): if self.wallet.interface.was_updated: self.textbox.setText( self.wallet.interface.message ) self.wallet.interface.was_updated = False + self.update_history_tab() + def create_history_tab(self): - h = [ 'ff', 'bar' ] - qstr = QStringList((QString('foo'),QString('bar'))) - qstr_model = QtGui.QStringListModel(qstr) - lv = QListView() - lv.setModel(qstr_model) - return lv + self.history_list = w = QTreeWidget(self) + w.setColumnCount(5) + w.setHeaderLabels( ['conf', 'Date','Description','Amount','Balance']) + return w + + + def update_history_tab(self): + self.history_list.clear() + balance = 0 + for tx in self.wallet.get_tx_history(): + tx_hash = tx['tx_hash'] + if tx['height']: + conf = self.wallet.interface.blocks - tx['height'] + 1 + time_str = datetime.datetime.fromtimestamp( tx['nTime']).isoformat(' ')[:-3] + else: + conf = 0 + time_str = 'pending' + v = tx['value'] + balance += v + label = self.wallet.labels.get(tx_hash) + is_default_label = (label == '') or (label is None) + if is_default_label: label = tx['default_label'] + item = QTreeWidgetItem( [ "%d"%conf, time_str, label, format_satoshis(v,True), format_satoshis(balance)] ) + self.history_list.addTopLevelItem(item) + def create_send_tab(self): - return QLabel('heh') + w = QWidget() + + paytoEdit = QtGui.QLineEdit() + descriptionEdit = QtGui.QLineEdit() + amountEdit = QtGui.QLineEdit() + feeEdit = QtGui.QLineEdit() + + grid = QtGui.QGridLayout() + grid.setSpacing(8) + + grid.addWidget(QLabel('Pay to'), 1, 0) + grid.addWidget(paytoEdit, 1, 1) + + grid.addWidget(QLabel('Description'), 2, 0) + grid.addWidget(descriptionEdit, 2, 1) + + grid.addWidget(QLabel('Amount'), 3, 0) + grid.addWidget(amountEdit, 3, 1) + + grid.addWidget(QLabel('Fee'), 4, 0) + grid.addWidget(feeEdit, 4, 1) + + w.setLayout(grid) + w.show() + + w2 = QWidget() + vbox = QtGui.QVBoxLayout() + vbox.addWidget(w) + vbox.addStretch(1) + w2.setLayout(vbox) + + return w2 def create_receive_tab(self): - return QLabel('heh') + self.addresses_list = w = QTreeWidget(self) + w.setColumnCount(3) + w.setHeaderLabels( ['Address', 'Label','Tx']) + return w def create_contacts_tab(self): - return QLabel('heh') + self.contacts_list = w = QTreeWidget(self) + w.setColumnCount(3) + w.setHeaderLabels( ['Address', 'Label','Tx']) + return w def create_wall_tab(self): self.textbox = textbox = QTextEdit(self) @@ -85,7 +145,7 @@ class BitcoinWidget(QMainWindow): def create_status_bar(self): sb = QStatusBar() - sb.setFixedHeight(18) + sb.setFixedHeight(20) self.setStatusBar(sb) @@ -101,9 +161,3 @@ class BitcoinGUI(): w = BitcoinWidget(self.wallet) w.connect_slots(s) app.exec_() - - - - - -