first sketch of qt gui

This commit is contained in:
thomasv 2012-02-11 13:14:12 +01:00
parent 1d15286015
commit 9829253ecf
3 changed files with 119 additions and 77 deletions

View File

@ -31,7 +31,7 @@ urldecode = lambda x: _ud.sub(lambda m: chr(int(m.group(1), 16)), x)
from wallet import format_satoshis
if __name__ == '__main__':
known_commands = ['help', 'validateaddress', 'balance', 'contacts', 'create', 'payto', 'sendtx', 'password', 'newaddress', 'addresses', 'history', 'label', 'gui', 'mktx','seed','import','signmessage','verifymessage','eval']
known_commands = ['help', 'validateaddress', 'balance', 'contacts', 'create', 'payto', 'sendtx', 'password', 'newaddress', 'addresses', 'history', 'label', 'mktx','seed','import','signmessage','verifymessage','eval', 'gtk','qt']
usage = "usage: %prog [options] command args\nCommands: "+ (', '.join(known_commands))
@ -44,23 +44,30 @@ if __name__ == '__main__':
parser.add_option("-s", "--fromaddr", dest="from_addr", default=None, help="set source address for payto/mktx. if it isn't in the wallet, it will ask for the private key unless supplied in the format public_key:private_key. It's not saved in the wallet.")
parser.add_option("-c", "--changeaddr", dest="change_addr", default=None, help="set the change address for payto/mktx. default is a spare address, or the source address if it's not in the wallet")
options, args = parser.parse_args()
try:
cmd = args[0]
except:
cmd = "gui"
try:
firstarg = args[1]
except:
firstarg = ''
interface = Interface()
wallet = Wallet(interface)
wallet.set_path(options.wallet_path)
if cmd == 'gui' or re.match('^bitcoin:', cmd):
cmd = args[0] if len(args) > 0 else 'gtk'
firstarg = args[1] if len(args) > 1 else ''
if cmd in ['gtk','qt'] or re.match('^bitcoin:', cmd):
if cmd == 'qt':
import gui_qt as gui
else:
import gui
interface.get_servers()
gui.init_wallet(wallet)
try:
found = wallet.read()
if not found:
gui.restore_create_dialog(wallet)
except BaseException, e:
show_message(e.message)
exit(1)
gui = gui.BitcoinGUI(wallet)
interface.start(wallet)
@ -213,7 +220,7 @@ if __name__ == '__main__':
print "show the transaction history"
elif cmd2 == 'label':
print "assign a label to an item"
elif cmd2 == 'gui':
elif cmd2 == 'gtk':
print "start the GUI"
elif cmd2 == 'mktx':
print "create a signed transaction. password protected"

View File

@ -74,15 +74,8 @@ def show_seed_dialog(wallet, password, parent):
dialog.run()
dialog.destroy()
def init_wallet(wallet):
def restore_create_dialog(wallet):
try:
found = wallet.read()
except BaseException, e:
show_message(e.message)
exit(1)
if not found:
# ask if the user wants to create a new wallet, or recover from a seed.
# if he wants to recover, and nothing is found, do not create wallet
dialog = gtk.Dialog("electrum", parent=None,

42
client/gui_qt.py Normal file
View File

@ -0,0 +1,42 @@
import sys
from PyQt4.QtGui import *
import PyQt4.QtCore as QtCore
def restore_create_dialog(wallet):
pass
class BitcoinWidget(QWidget):
def __init__(self, wallet):
super(BitcoinWidget, self).__init__()
self.wallet = wallet
self.initUI()
def initUI(self):
qbtn = QPushButton('Quit', self)
qbtn.clicked.connect(QtCore.QCoreApplication.instance().quit)
qbtn.resize(qbtn.sizeHint())
qbtn.move(50, 50)
self.setGeometry(300, 300, 250, 150)
self.setWindowTitle( 'Electrum ' + self.wallet.electrum_version )
self.show()
class BitcoinGUI():
def __init__(self, wallet):
self.wallet = wallet
def main(self):
app = QApplication(sys.argv)
w = BitcoinWidget(self.wallet)
app.exec_()