Browse Source

changes to make kivy branch with master

283
akshayaurora 11 years ago
committed by ThomasV
parent
commit
f2fc18fe32
  1. 44
      gui/kivy/__init__.py
  2. 37
      gui/kivy/main_window.py
  3. 2
      gui/kivy/tools/buildozer.spec

44
gui/kivy/__init__.py

@ -21,7 +21,7 @@
import sys
#, time, datetime, re, threading
#from electrum.i18n import _, set_language
from electrum.util import print_error, print_msg, parse_url
from electrum.util import print_error, print_msg
#:TODO: replace this with kivy's own plugin managment
#from electrum.plugins import run_hook
@ -73,46 +73,8 @@ class ElectrumGui:
#init_plugins(self)
def set_url(self, url):
from electrum import util
from decimal import Decimal
try:
address, amount, label, message,\
request_url, url = util.parse_url(url)
except Exception:
self.main_window.show_error(_('Invalid bitcoin URL'))
return
if amount:
try:
if main_window.base_unit == 'mBTC':
amount = str( 1000* Decimal(amount))
else:
amount = str(Decimal(amount))
except Exception:
amount = "0.0"
self.main_window.show_error(_('Invalid Amount'))
if request_url:
try:
from electrum import paymentrequest
except:
self.main_window.show_error("cannot import payment request")
request_url = None
if not request_url:
self.main_window.set_send(address, amount, label, message)
return
def payment_request():
self.payment_request = paymentrequest.PaymentRequest(request_url)
if self.payment_request.verify():
Clock.schedule_once(self.main_window.payment_request_ok)
else:
Clock.schedule_once(self.main_window.payment_request_error)
threading.Thread(target=payment_request).start()
self.main_window.prepare_for_payment_request()
#self.current_window.pary_from_URI
pass
def main(self, url):
''' The main entry point of the kivy ux

37
gui/kivy/main_window.py

@ -25,7 +25,7 @@ Factory.register('QrScannerDialog', module='electrum_gui.kivy.uix.dialogs.qr_sca
# delayed imports: for startup speed on android
notification = app = Decimal = ref = format_satoshis = is_valid = Builder = None
notification = app = Decimal = ref = format_satoshis = bitcoin = Builder = None
inch = None
util = False
re = None
@ -557,16 +557,10 @@ class ElectrumWindow(App):
'''
global format_satoshis
if not format_satoshis:
from electrum.wallet import format_satoshis
from electrum.util import format_satoshis
return format_satoshis(x, is_diff, self.num_zeros,
self.decimal_point, whitespaces)
def read_amount(self, x):
if x in['.', '']:
return None
p = pow(10, self.decimal_point)
return int( p * Decimal(x) )
def update_wallet(self, *dt):
'''
'''
@ -802,13 +796,8 @@ class ElectrumWindow(App):
def do_send(self):
app = App.get_running_app()
screen_send = app.root.main_screen.ids.tabs.ids.screen_send
scrn = screen_send.content.ids
scrn = screen_send.ids
label = unicode(scrn.message_e.text)
# TODO
#if self.gui_object.payment_request:
# outputs = self.gui_object.payment_request.outputs
# amount = self.gui_object.payment_request.get_amount()
#else:
r = unicode(scrn.payto_e.text).strip()
@ -819,24 +808,18 @@ class ElectrumWindow(App):
m = re.match('(.*?)\s*\<([1-9A-HJ-NP-Za-km-z]{26,})\>', r)
to_address = m.group(2) if m else r
global is_valid
if not is_valid:
from electrum.bitcoin import is_valid
global bitcoin
if not bitcoin:
from electrum import bitcoin
if not is_valid(to_address):
if not bitcoin.is_address(to_address):
app.show_error(_('Invalid Bitcoin Address') +
':\n' + to_address)
return
try:
amount = self.read_amount(unicode(scrn.amount_e.text))
except Exception:
app.show_error(_('Invalid Amount'))
return
try:
fee = self.read_amount(unicode(scrn.fee_e.amt))
except Exception as err:
print err
amount = scrn.amount_e.text
fee = scrn.fee_e.amt
if not fee:
app.show_error(_('Invalid Fee'))
return

2
gui/kivy/tools/buildozer.spec

@ -32,7 +32,7 @@ source.exclude_exts = spec
version = 1.9.8
# (list) Application requirements
requirements = pil, qrcode, ecdsa, pbkdf2, openssl, pyopenssl, plyer==master, kivy==master
requirements = pil, qrcode, ecdsa, pbkdf2, openssl, pyopenssl, pyasn, pyasn-modules, plyer==master, kivy==master
# (str) Presplash of the application
presplash.filename = %(source.dir)s/gui/kivy/theming/splash.png

Loading…
Cancel
Save