1
0

misc python3 updates:

- use jsonrpclib-pelix
 - update the kivy gui
 - update plugins
This commit is contained in:
ThomasV
2017-02-16 10:54:24 +01:00
parent e562b0b565
commit c3388d9677
32 changed files with 130 additions and 129 deletions

View File

@@ -1,4 +1,4 @@
PYTHON = python
PYTHON = python3
# needs kivy installed or in PYTHONPATH

View File

@@ -39,7 +39,6 @@ except ImportError:
# minimum required version for kivy
kivy.require('1.8.0')
from kivy.logger import Logger
from main_window import ElectrumWindow
@@ -54,6 +53,7 @@ class ElectrumGui:
self.plugins = plugins
def main(self):
from .main_window import ElectrumWindow
self.config.open_last_wallet()
w = ElectrumWindow(config=self.config,
network=self.network,

View File

@@ -29,23 +29,23 @@ from kivy.factory import Factory
from kivy.metrics import inch
from kivy.lang import Builder
# lazy imports for factory so that widgets can be used in kv
Factory.register('InstallWizard',
module='electrum_gui.kivy.uix.dialogs.installwizard')
Factory.register('InfoBubble', module='electrum_gui.kivy.uix.dialogs')
Factory.register('OutputList', module='electrum_gui.kivy.uix.dialogs')
Factory.register('OutputItem', module='electrum_gui.kivy.uix.dialogs')
## lazy imports for factory so that widgets can be used in kv
#Factory.register('InstallWizard', module='electrum_gui.kivy.uix.dialogs.installwizard')
#Factory.register('InfoBubble', module='electrum_gui.kivy.uix.dialogs')
#Factory.register('OutputList', module='electrum_gui.kivy.uix.dialogs')
#Factory.register('OutputItem', module='electrum_gui.kivy.uix.dialogs')
from .uix.dialogs.installwizard import InstallWizard
from .uix.dialogs import InfoBubble
from .uix.dialogs import OutputList, OutputItem
#from kivy.core.window import Window
#Window.softinput_mode = 'below_target'
# delayed imports: for startup speed on android
notification = app = ref = None
util = False
# register widget cache for keeping memory down timeout to forever to cache
# the data
Cache.register('electrum_widgets', timeout=0)
@@ -239,12 +239,11 @@ class ElectrumWindow(App):
self.is_exit = False
self.wallet = None
super(ElectrumWindow, self).__init__(**kwargs)
App.__init__(self)#, **kwargs)
title = _('Electrum App')
self.electrum_config = config = kwargs.get('config', None)
self.language = config.get('language', 'en')
self.network = network = kwargs.get('network', None)
if self.network:
self.num_blocks = self.network.get_local_height()
@@ -361,7 +360,7 @@ class ElectrumWindow(App):
popup.open()
def qr_dialog(self, title, data, show_text=False):
from uix.dialogs.qr_dialog import QRDialog
from .uix.dialogs.qr_dialog import QRDialog
popup = QRDialog(title, data, show_text)
popup.open()
@@ -540,8 +539,8 @@ class ElectrumWindow(App):
return True
def settings_dialog(self):
from .uix.dialogs.settings import SettingsDialog
if self._settings_dialog is None:
from uix.dialogs.settings import SettingsDialog
self._settings_dialog = SettingsDialog(self)
self._settings_dialog.update()
self._settings_dialog.open()
@@ -550,7 +549,7 @@ class ElectrumWindow(App):
if name == 'settings':
self.settings_dialog()
elif name == 'wallets':
from uix.dialogs.wallets import WalletDialog
from .uix.dialogs.wallets import WalletDialog
d = WalletDialog()
d.open()
else:
@@ -562,7 +561,7 @@ class ElectrumWindow(App):
''' Initialize The Ux part of electrum. This function performs the basic
tasks of setting up the ui.
'''
from weakref import ref
#from weakref import ref
self.funds_error = False
# setup UX
@@ -663,7 +662,7 @@ class ElectrumWindow(App):
def format_amount_and_units(self, x):
return format_satoshis_plain(x, self.decimal_point()) + ' ' + self.base_unit
@profiler
#@profiler
def update_wallet(self, *dt):
self._trigger_update_status()
if self.wallet and (self.wallet.up_to_date or not self.network or not self.network.is_connected()):
@@ -779,7 +778,7 @@ class ElectrumWindow(App):
info_bubble.show(pos, duration, width, modal=modal, exit=exit)
def tx_dialog(self, tx):
from uix.dialogs.tx_dialog import TxDialog
from .uix.dialogs.tx_dialog import TxDialog
d = TxDialog(self, tx)
d.open()
@@ -818,7 +817,7 @@ class ElectrumWindow(App):
self.show_info(_('Cannot broadcast transaction') + ':\n' + _('Not connected'))
def description_dialog(self, screen):
from uix.dialogs.label_dialog import LabelDialog
from .uix.dialogs.label_dialog import LabelDialog
text = screen.message
def callback(text):
screen.message = text
@@ -827,7 +826,7 @@ class ElectrumWindow(App):
@profiler
def amount_dialog(self, screen, show_max):
from uix.dialogs.amount_dialog import AmountDialog
from .uix.dialogs.amount_dialog import AmountDialog
amount = screen.amount
if amount:
amount, u = str(amount).split()
@@ -844,7 +843,7 @@ class ElectrumWindow(App):
f(*(args + (None,)))
def delete_wallet(self):
from uix.dialogs.question import Question
from .uix.dialogs.question import Question
basename = os.path.basename(self.wallet.storage.path)
d = Question(_('Delete wallet?') + '\n' + basename, self._delete_wallet)
d.open()
@@ -917,10 +916,10 @@ class ElectrumWindow(App):
self.show_error("PIN numbers do not match")
def password_dialog(self, msg, f, args):
from .uix.dialogs.password_dialog import PasswordDialog
def callback(pw):
Clock.schedule_once(lambda _: f(*(args + (pw,))), 0.1)
Clock.schedule_once(lambda x: f(*(args + (pw,))), 0.1)
if self._password_dialog is None:
from uix.dialogs.password_dialog import PasswordDialog
self._password_dialog = PasswordDialog()
self._password_dialog.init(msg, callback)
self._password_dialog.open()

View File

@@ -31,7 +31,7 @@ version.filename = %(source.dir)s/contrib/versions.py
#version = 1.9.8
# (list) Application requirements
requirements = hostpython2, android, openssl, pycrypto, pil, plyer, kivy==master
requirements = python3crystax, android, openssl, pycrypto, pil, plyer, kivy==master
# (str) Presplash of the application
#presplash.filename = %(source.dir)s/gui/kivy/theming/splash.png

View File

@@ -46,6 +46,7 @@ class ChoiceDialog(Factory.Popup):
def __init__(self, title, choices, key, callback):
Factory.Popup.__init__(self)
print(choices, type(choices))
if type(choices) is list:
choices = dict(map(lambda x: (x,x), choices))
layout = self.ids.choices

View File

@@ -14,15 +14,14 @@ from kivy.core.window import Window
from kivy.clock import Clock
from kivy.utils import platform
from electrum_gui.kivy.uix.dialogs import EventsDialog
from electrum_gui.kivy.i18n import _
from electrum.base_wizard import BaseWizard
from password_dialog import PasswordDialog
from . import EventsDialog
from ...i18n import _
from .password_dialog import PasswordDialog
# global Variables
app = App.get_running_app()
is_test = (platform == "linux")
test_seed = "time taxi field recycle tiny license olive virus report rare steel portion achieve"
test_xpub = "xpub661MyMwAqRbcEbvVtRRSjqxVnaWVUMewVzMiURAKyYratih4TtBpMypzzefmv8zUNebmNVzB3PojdC5sV2P9bDgMoo9B3SARw1MXUUfU1GL"
@@ -429,7 +428,7 @@ class WizardDialog(EventsDialog):
crcontent = ObjectProperty(None)
def __init__(self, wizard, **kwargs):
super(WizardDialog, self).__init__(**kwargs)
super(WizardDialog, self).__init__()
self.wizard = wizard
self.ids.back.disabled = not wizard.can_go_back()
self.app = App.get_running_app()
@@ -624,9 +623,7 @@ class RestoreSeedDialog(WizardDialog):
def get_text(self):
ti = self.ids.text_input_seed
text = unicode(ti.text).strip()
text = ' '.join(text.split())
return text
return ' '.join(ti.text.strip().split())
def update_text(self, c):
c = c.lower()
@@ -752,6 +749,7 @@ class InstallWizard(BaseWizard, Widget):
# on completion hide message
Clock.schedule_once(lambda dt: app.info_bubble.hide(now=True), -1)
app = App.get_running_app()
app.show_info_bubble(
text=msg, icon='atlas://gui/kivy/theming/light/important',
pos=Window.center, width='200sp', arrow_pos=None, modal=True)
@@ -793,6 +791,7 @@ class InstallWizard(BaseWizard, Widget):
def show_xpub_dialog(self, **kwargs): ShowXpubDialog(self, **kwargs).open()
def show_error(self, msg):
app = App.get_running_app()
Clock.schedule_once(lambda dt: app.show_error(msg))
def password_dialog(self, message, callback):

View File

@@ -10,7 +10,7 @@ from electrum.plugins import run_hook
from electrum import coinchooser
from electrum.util import fee_levels
from choice_dialog import ChoiceDialog
from .choice_dialog import ChoiceDialog
Builder.load_string('''
#:import partial functools.partial

View File

@@ -1,13 +1,14 @@
import os
from kivy.app import App
from kivy.factory import Factory
from kivy.properties import ObjectProperty
from kivy.lang import Builder
from electrum_gui.kivy.i18n import _
from electrum.util import base_units
import os
from label_dialog import LabelDialog
from ...i18n import _
from .label_dialog import LabelDialog
Builder.load_string('''
#:import os os

View File

@@ -104,7 +104,7 @@ class QRCodeWidget(FloatLayout):
for c in range(k):
bext([0, 0, 0] if matrix[k-1-r][c] else [cr, cg, cb])
# then blit the buffer
buff = ''.join(map(chr, buff))
buff = bytes(buff)
# update texture
self._upd_texture(buff)

View File

@@ -22,7 +22,7 @@ from electrum import bitcoin
from electrum.util import timestamp_to_datetime
from electrum.paymentrequest import PR_UNPAID, PR_PAID, PR_UNKNOWN, PR_EXPIRED
from context_menu import ContextMenu
from .context_menu import ContextMenu
from electrum_gui.kivy.i18n import _
@@ -235,7 +235,7 @@ class SendScreen(CScreen):
self.payment_request = None
def do_paste(self):
contents = unicode(self.app._clipboard.paste())
contents = self.app._clipboard.paste()
if not contents:
self.app.show_info(_("Clipboard is empty"))
return
@@ -261,7 +261,7 @@ class SendScreen(CScreen):
self.app.show_error(_('Invalid amount') + ':\n' + self.screen.amount)
return
outputs = [(bitcoin.TYPE_ADDRESS, address, amount)]
message = unicode(self.screen.message)
message = self.screen.message
amount = sum(map(lambda x:x[2], outputs))
if self.app.electrum_config.get('use_rbf'):
from dialogs.question import Question
@@ -344,7 +344,7 @@ class ReceiveScreen(CScreen):
req = self.app.wallet.get_payment_request(addr, self.app.electrum_config)
self.screen.status = ''
if req:
self.screen.message = unicode(req.get('memo', ''))
self.screen.message = req.get('memo', '')
amount = req.get('amount')
self.screen.amount = self.app.format_amount_and_units(amount) if amount else ''
status = req.get('status', PR_UNKNOWN)
@@ -376,9 +376,9 @@ class ReceiveScreen(CScreen):
self.app.show_info(_('Request copied to clipboard'))
def save_request(self):
addr = str(self.screen.address)
amount = str(self.screen.amount)
message = unicode(self.screen.message)
addr = self.screen.address
amount = self.screen.amount
message = self.screen.message
amount = self.app.get_amount(amount) if amount else 0
req = self.app.wallet.make_payment_request(addr, amount, message, None)
self.app.wallet.add_payment_request(req, self.app.electrum_config)

View File

@@ -1,8 +1,8 @@
#:import _ electrum_gui.kivy.i18n._
#:import Factory kivy.factory.Factory
#:set font_light 'gui/kivy/data/fonts/Roboto-Condensed.ttf'
#:set btc_symbol unichr(171)
#:set mbtc_symbol unichr(187)
#:set btc_symbol chr(171)
#:set mbtc_symbol chr(187)

View File

@@ -1,7 +1,7 @@
#:import _ electrum_gui.kivy.i18n._
#:import Decimal decimal.Decimal
#:set btc_symbol unichr(171)
#:set mbtc_symbol unichr(187)
#:set btc_symbol chr(171)
#:set mbtc_symbol chr(187)
#:set font_light 'gui/kivy/data/fonts/Roboto-Condensed.ttf'

View File

@@ -1,7 +1,7 @@
#:import _ electrum_gui.kivy.i18n._
#:import Decimal decimal.Decimal
#:set btc_symbol unichr(171)
#:set mbtc_symbol unichr(187)
#:set btc_symbol chr(171)
#:set mbtc_symbol chr(187)
#:set font_light 'gui/kivy/data/fonts/Roboto-Condensed.ttf'

View File

@@ -38,7 +38,7 @@ from PyQt4.QtGui import *
from PyQt4.QtCore import *
import PyQt4.QtCore as QtCore
from lib.util import bh2u, bfh
from electrum.util import bh2u, bfh
from . import icons_rc
from electrum import keystore

View File

@@ -42,7 +42,7 @@ from electrum.bitcoin import base_encode
from electrum.i18n import _
from electrum.plugins import run_hook
from lib.util import bfh
from electrum.util import bfh
from .util import *
dialogs = [] # Otherwise python randomly garbage collects the dialogs...

View File

@@ -23,7 +23,7 @@ class ElectrumGui:
self.network = daemon.network
storage = WalletStorage(config.get_wallet_path())
if not storage.file_exists:
print "Wallet not found. try 'electrum create'"
print("Wallet not found. try 'electrum create'")
exit()
if storage.is_encrypted():
password = getpass.getpass('Password:', stream=None)
@@ -63,8 +63,8 @@ class ElectrumGui:
def main_command(self):
self.print_balance()
c = raw_input("enter command: ")
if c == "h" : self.print_commands()
c = input("enter command: ")
if c == "h" : self.print_commands()
elif c == "i" : self.print_history()
elif c == "o" : self.enter_order()
elif c == "p" : self.print_order()
@@ -144,10 +144,10 @@ class ElectrumGui:
+ "\nfee: " + self.str_fee + ", desc: " + self.str_description)
def enter_order(self):
self.str_recipient = raw_input("Pay to: ")
self.str_description = raw_input("Description : ")
self.str_amount = raw_input("Amount: ")
self.str_fee = raw_input("Fee: ")
self.str_recipient = input("Pay to: ")
self.str_description = input("Description : ")
self.str_amount = input("Amount: ")
self.str_fee = input("Fee: ")
def send_order(self):
self.do_send()
@@ -192,7 +192,7 @@ class ElectrumGui:
c = ""
while c != "y":
c = raw_input("ok to send (y/n)?")
c = input("ok to send (y/n)?")
if c == "n": return
try:

View File

@@ -25,7 +25,7 @@ class ElectrumGui:
self.network = daemon.network
storage = WalletStorage(config.get_wallet_path())
if not storage.file_exists:
print "Wallet not found. try 'electrum create'"
print("Wallet not found. try 'electrum create'")
exit()
if storage.is_encrypted():
password = getpass.getpass('Password:', stream=None)
@@ -186,8 +186,13 @@ class ElectrumGui:
self.print_list( self.network.banner.split('\n'))
def print_qr(self, data):
import qrcode, StringIO
s = StringIO.StringIO()
import qrcode
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
s = StringIO()
self.qr = qrcode.QRCode()
self.qr.add_data(data)
self.qr.print_ascii(out=s, invert=False)
@@ -218,7 +223,7 @@ class ElectrumGui:
def main_command(self):
c = self.stdscr.getch()
print c
print(c)
if c == curses.KEY_RIGHT: self.tab = (self.tab + 1)%self.num_tabs
elif c == curses.KEY_LEFT: self.tab = (self.tab - 1)%self.num_tabs
elif c == curses.KEY_DOWN: self.pos +=1