electrum

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

commit 28ffe32718bc836c001639f4cff9ad31990290f7
parent 65ecbf990d712fd152ef6d1f8e5a3a7401839df1
Author: ThomasV <thomasv@electrum.org>
Date:   Tue,  6 Oct 2015 10:43:37 +0200

kivy:cleanup

Diffstat:
Mgui/kivy/main.kv | 49++++++++++++++-----------------------------------
Mgui/kivy/main_window.py | 38--------------------------------------
Mgui/kivy/uix/qrcodewidget.py | 29++++++++++++-----------------
Mgui/kivy/uix/screens.py | 4----
Mgui/kivy/uix/ui_screens/receive.kv | 12++----------
Mgui/kivy/uix/ui_screens/send.kv | 40+++++-----------------------------------
6 files changed, 33 insertions(+), 139 deletions(-)

diff --git a/gui/kivy/main.kv b/gui/kivy/main.kv @@ -95,27 +95,6 @@ size: root.size pos: root.pos -<Butt_star@ActionToggleButton>: - important: True - size_hint_x: None - width: '32dp' - mipmap: True - state: 'down' if app.expert_mode else 'normal' - background_down: self.background_normal - foreground_color: (.466, .466, .466, 1) - color_active: (0.235, .588, .89, 1) - on_release: app.expert_mode = True if self.state == 'down' else False - Image: - source: 'atlas://gui/kivy/theming/light/star_big_inactive' - center: root.center - size: root.width/1.5, self.width - color: - root.foreground_color if root.state == 'normal' else root.color_active - canvas.after: - Color: - rgba: 1, 1, 1, 1 - source: - allow_stretch: True <ELTextInput> padding: '10dp', '4dp' @@ -262,20 +241,20 @@ text: _("Select Your address") -<ElectrumScreen> - ScrollView: - do_scroll_x: False - do_scroll_y: False if root.fullscreen else (content.height > root.height - dp(16)) - AnchorLayout: - size_hint_y: None - height: root.height if root.fullscreen else max(root.height, content.height) - GridLayout: - id: content - cols: 1 - spacing: '8dp' - padding: '8dp' - size_hint: (1, 1) if root.fullscreen else (.8, None) - height: self.height if root.fullscreen else self.minimum_height +#<ElectrumScreen> +# ScrollView: +# do_scroll_x: False +# do_scroll_y: False if root.fullscreen else (content.height > root.height - dp(16)) +# AnchorLayout: +# size_hint_y: None +# height: root.height if root.fullscreen else max(root.height, content.height) +# GridLayout: +# id: content +# cols: 1 +# spacing: '8dp' +# padding: '8dp' +# size_hint: (1, 1) if root.fullscreen else (.8, None) +# height: self.height if root.fullscreen else self.minimum_height <TabbedCarousel> diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py @@ -41,13 +41,6 @@ Cache.register('electrum_widgets', timeout=0) from kivy.uix.screenmanager import Screen from kivy.uix.tabbedpanel import TabbedPanel -class ElectrumScreen(Screen): - fullscreen = BooleanProperty(False) - #def add_widget(self, *args): - # if 'content' in self.ids: - # return self.ids.content.add_widget(*args) - # return super(ElectrumScreen, self).add_widget(*args) - Factory.register('TabbedCarousel', module='electrum_gui.kivy.uix.screens') @@ -79,12 +72,6 @@ class ElectrumWindow(App): :attr:`currencies` is a `ListProperty` default to ['Eur', 'GBP'. 'USD']. ''' - expert_mode = BooleanProperty(False) - '''This defines whether expert mode options are available in the ui. - - :attr:`expert_mode` is a `BooleanProperty` defaults to `False`. - ''' - def _get_decimal(self): try: return self.electrum_config.get('decimal_point', 8) @@ -417,22 +404,10 @@ class ElectrumWindow(App): Cache.append('electrum_widgets', 'CSpinner', Factory.CSpinner()) # load and focus the ui - #Load mainscreen - - #dr = Builder.load_file('gui/kivy/uix/ui_screens/mainscreen.kv') - #self.root.add_widget(dr) - #self.root.manager = manager = dr.ids.manager - #self.root.main_screen = m = manager.screens[0] - #self.tabs = m.ids.tabs - self.root.manager = self.root.ids['manager'] self.recent_activity_card = None self.history_screen = None self.contacts_screen = None - self.wallet_screen = None - - #TODO - # load left_menu self.icon = "icons/electrum.png" @@ -710,18 +685,6 @@ class ElectrumWindow(App): #Logger.info('orientation: {}'.format(self._orientation)) #Logger.info('ui_mode: {}'.format(self._ui_mode)) - def load_screen(self, name, direction='left', manager=None): - screen = self.screens.get(name) - if screen is None: - screen = Builder.load_file('gui/kivy/uix/ui_screens/' + name + '.kv') - screen.name = name - self.screens[name] = screen - manager = manager or self.root.manager - manager.switch_to(screen, direction=direction) - - def load_history(self): - #Builder.load_file('gui/kivy/uix/ui_screens/history.kv') - print "load history", self.root.manager.ids.history def save_new_contact(self, address, label): address = unicode(address) @@ -730,7 +693,6 @@ class ElectrumWindow(App): if not is_valid: from electrum.bitcoin import is_valid - if is_valid(address): if label: self.set_label(address, text=label) diff --git a/gui/kivy/uix/qrcodewidget.py b/gui/kivy/uix/qrcodewidget.py @@ -4,8 +4,9 @@ from threading import Thread from functools import partial -from kivy.uix.floatlayout import FloatLayout +import qrcode +from kivy.uix.floatlayout import FloatLayout from kivy.graphics.texture import Texture from kivy.properties import StringProperty from kivy.properties import ObjectProperty, StringProperty, ListProperty,\ @@ -13,12 +14,6 @@ from kivy.properties import ObjectProperty, StringProperty, ListProperty,\ from kivy.lang import Builder from kivy.clock import Clock -try: - import qrcode -except ImportError: - import sys - sys.exit("Error: qrcode does not seem to be installed. Try 'sudo pip install qrcode'") - Builder.load_string(''' @@ -77,11 +72,12 @@ class QRCodeWidget(FloatLayout): def __init__(self, **kwargs): super(QRCodeWidget, self).__init__(**kwargs) - self.addr = None + self.data = None self.qr = None self._qrtexture = None def on_data(self, instance, value): + print "on data" if not (self.canvas or value): return img = self.ids.get('qrimage', None) @@ -95,31 +91,30 @@ class QRCodeWidget(FloatLayout): Thread(target=partial(self.generate_qr, value)).start() def generate_qr(self, value): - self.set_addr(value) + self.set_data(value) self.update_qr() - def set_addr(self, addr): - if self.addr == addr: + def set_data(self, data): + if self.data == data: return MinSize = 210 if len(addr) < 128 else 500 self.setMinimumSize((MinSize, MinSize)) - self.addr = addr + self.data = data self.qr = None def update_qr(self): - if not self.addr and self.qr: + if not self.data and self.qr: return - QRCode = qrcode.QRCode L = qrcode.constants.ERROR_CORRECT_L - addr = self.addr + data = self.data try: - self.qr = qr = QRCode( + self.qr = qr = qrcode.QRCode( version=None, error_correction=L, box_size=10, border=0, ) - qr.add_data(addr) + qr.add_data(data) qr.make(fit=True) except Exception as e: print e diff --git a/gui/kivy/uix/screens.py b/gui/kivy/uix/screens.py @@ -50,10 +50,6 @@ class CScreen(Factory.Screen): self.update() setattr(self.app, self.kvname + '_screen', self) - #app.history_screen = screen - #app.recent_activity_card = screen.ids.recent_activity_card - #app.update_history_tab() - #Clock.schedule_once(lambda dt: self._change_action_view()) def on_leave(self): diff --git a/gui/kivy/uix/ui_screens/receive.kv b/gui/kivy/uix/ui_screens/receive.kv @@ -107,9 +107,9 @@ ReceiveScreen: AddressSelector: id: address_selection foreground_color: blue_bottom.foreground_color - opacity: 1 if app.expert_mode else 0 + opacity: 1 size_hint: 1, None - height: blue_bottom.item_height if app.expert_mode else 0 + height: blue_bottom.item_height on_text: if not args[1].startswith('Select'):\ qr.data = app.encode_uri(args[1],\ @@ -161,11 +161,3 @@ ReceiveScreen: .format(app.base_unit, app.status) font_size: '22dp' minimum_width: '1dp' - Butt_star: - id: but_star - on_release: - if self.state == 'down':\ - app.show_info_bubble(\ - text='[b]Expert mode on[/b]\n you can now select your address',\ - icon='atlas://gui/kivy/theming/light/star_big_inactive',\ - duration=1, arrow_pos='', width='250dp') diff --git a/gui/kivy/uix/ui_screens/send.kv b/gui/kivy/uix/ui_screens/send.kv @@ -6,36 +6,6 @@ #:set mbtc_symbol unichr(187) #:set font_light 'data/fonts/Roboto-Condensed.ttf' -<SendActionView@ActionView> - foreground_color: (.466, .466, .466, 1) - color_active: (0.235, .588, .89, 1) - WalletActionPrevious: - id: action_previous - width: but_star.width - ActionButton: - id: action_logo - important: True - size_hint: 1, 1 - markup: True - mipmap: True - bold: True - markup: True - color: 1, 1, 1, 1 - text: - "[color=#777777][sub] [sup][size=9dp]{}[/size][/sup][/sub]{}[/color]"\ - .format(app.base_unit, app.status) - font_size: '22dp' - minimum_width: '1dp' - Butt_star: - id: but_star - on_release: - if self.state == 'down':\ - app.show_info_bubble(\ - text='[b]Expert mode on[/b]\n you can now select your address',\ - icon='atlas://gui/kivy/theming/light/star_big_inactive',\ - duration=1, arrow_pos='', width='250dp') - - <TextInputSendBlue@TextInput> @@ -55,7 +25,7 @@ SendScreen: mode: 'address' name: 'send' - action_view: Factory.SendActionView() + #action_view: Factory.SendActionView() #on_deactivate: # self.ids.amount_e.focus = False # self.ids.payto_e.focus = False @@ -206,9 +176,9 @@ SendScreen: color: blue_bottom.foreground_color BoxLayout: id: message_selection - opacity: 1 if app.expert_mode else 0 + opacity: 1 size_hint: 1, None - height: blue_bottom.item_height if app.expert_mode else 0 + height: blue_bottom.item_height spacing: '5dp' Image: source: 'atlas://gui/kivy/theming/light/pen' @@ -228,9 +198,9 @@ SendScreen: AddressSelector: id: address_selection foreground_color: blue_bottom.foreground_color - opacity: 1 if app.expert_mode else 0 + opacity: 1 size_hint: 1, None - height: blue_bottom.item_height if app.expert_mode else 0 + height: blue_bottom.item_height Button: #background_color: (1, 1, 1, 1) if self.disabled else ((.258, .80, .388, 1) if self.state == 'normal' else (.203, .490, .741, 1)) text: _('Send')