kivy: dim qr code on touch

This commit is contained in:
ThomasV 2015-10-16 11:51:28 +02:00
parent aa83f5fdca
commit 3b49b5adca
2 changed files with 9 additions and 21 deletions

View File

@ -18,7 +18,6 @@ from kivy.clock import Clock
Builder.load_string('''
<QRCodeWidget>
#on_parent: if args[1]: qrimage.source = self.loading_image
canvas.before:
# Draw white Rectangle
Color:
@ -28,15 +27,10 @@ Builder.load_string('''
pos: self.pos
canvas.after:
Color:
rgba: .5, .5, .5, 0
Line:
width: dp(1.333)
points:
self.x + dp(2), self.y + dp(2),\
self.right - dp(2), self.y + dp(2),\
self.right - dp(2), self.top - dp(2),\
self.x + dp(2), self.top - dp(2),\
self.x + dp(2), self.y + dp(2)
rgba: root.foreground_color
Rectangle:
size: self.size
pos: self.pos
Image
id: qrimage
pos_hint: {'center_x': .5, 'center_y': .5}
@ -48,18 +42,11 @@ Builder.load_string('''
class QRCodeWidget(FloatLayout):
data = StringProperty(None, allow_none=True)
''' Data using which the qrcode is generated.
:data:`data` is a :class:`~kivy.properties.StringProperty`, defaulting to
`None`.
'''
background_color = ListProperty((1, 1, 1, 1))
''' Background color of the background of the widget.
:data:`background_color` is a :class:`~kivy.properties.ListProperty`,
defaulting to `(1, 1, 1, 1)`.
'''
foreground_color = ListProperty((0, 0, 0, 0))
#loading_image = StringProperty('gui/kivy/theming/loading.gif')

View File

@ -28,9 +28,10 @@ ReceiveScreen:
size_hint: None, 1
width: min(self.height, bl.width)
pos_hint: {'center': (.5, .5)}
shaded: False
on_touch_down:
if self.collide_point(*args[1].pos):\
app.show_info_bubble(icon=self.ids.qrimage.texture, text='texture')
self.shaded = not self.shaded
self.foreground_color = (0, 0, 0, 0.5) if self.shaded else (0, 0, 0, 0)
SendReceiveBlueBottom:
id: blue_bottom