1
0

kivy:cleanup

This commit is contained in:
ThomasV
2015-10-06 10:43:37 +02:00
parent 65ecbf990d
commit 28ffe32718
6 changed files with 33 additions and 139 deletions

View File

@@ -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

View File

@@ -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):

View File

@@ -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')

View File

@@ -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')