bugfix
This commit is contained in:
parent
d807cb11e3
commit
2831aa6175
@ -10,7 +10,7 @@ from kivy.uix.image import Image
|
|||||||
from kivy.graphics.texture import Texture
|
from kivy.graphics.texture import Texture
|
||||||
from kivy.properties import StringProperty
|
from kivy.properties import StringProperty
|
||||||
from kivy.properties import ObjectProperty, StringProperty, ListProperty,\
|
from kivy.properties import ObjectProperty, StringProperty, ListProperty,\
|
||||||
BooleanProperty
|
BooleanProperty, NumericProperty
|
||||||
from kivy.lang import Builder
|
from kivy.lang import Builder
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
|
|
||||||
@ -32,6 +32,16 @@ class QRCodeWidget(VBox):
|
|||||||
defaulting to `'data/images/image-loading.gif'`.
|
defaulting to `'data/images/image-loading.gif'`.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
version = NumericProperty(40)
|
||||||
|
box_size = NumericProperty(20)
|
||||||
|
err_level = StringProperty('L')
|
||||||
|
border = NumericProperty(1)
|
||||||
|
error_correct_values = {
|
||||||
|
'L':qrcode.constants.ERROR_CORRECT_L,
|
||||||
|
'M':qrcode.constants.ERROR_CORRECT_M,
|
||||||
|
'Q':qrcode.constants.ERROR_CORRECT_Q,
|
||||||
|
'H':qrcode.constants.ERROR_CORRECT_H
|
||||||
|
}
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.qrimage = Image(allow_stretch=True, keep_ratio=True)
|
self.qrimage = Image(allow_stretch=True, keep_ratio=True)
|
||||||
self.addr = None
|
self.addr = None
|
||||||
@ -72,12 +82,17 @@ class QRCodeWidget(VBox):
|
|||||||
QRCode = qrcode.QRCode
|
QRCode = qrcode.QRCode
|
||||||
L = qrcode.constants.ERROR_CORRECT_L
|
L = qrcode.constants.ERROR_CORRECT_L
|
||||||
addr = self.addr
|
addr = self.addr
|
||||||
|
print('self.box_size=', self.box_size)
|
||||||
|
errv = self.error_correct_values.get(self.err_level)
|
||||||
|
if not errv:
|
||||||
|
errv=self.error_corrent_values.get('L')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.qr = qr = QRCode(
|
self.qr = qr = QRCode(
|
||||||
version=None,
|
version=self.version,
|
||||||
error_correction=L,
|
error_correction=errv,
|
||||||
box_size=10,
|
box_size=self.box_size,
|
||||||
border=4,
|
border=self.border,
|
||||||
)
|
)
|
||||||
qr.add_data(addr)
|
qr.add_data(addr)
|
||||||
qr.make(fit=True)
|
qr.make(fit=True)
|
||||||
|
@ -1,26 +1,45 @@
|
|||||||
|
from kivy.properties import NumericProperty, StringProperty
|
||||||
from kivy.uix.scrollview import ScrollView
|
from kivy.uix.scrollview import ScrollView
|
||||||
from kivy.effects.scroll import ScrollEffect
|
from kivy.effects.scroll import ScrollEffect
|
||||||
from kivy.uix.widget import Widget
|
from kivy.uix.widget import Widget
|
||||||
from kivy.uix.boxlayout import BoxLayout
|
from kivy.uix.boxlayout import BoxLayout
|
||||||
from kivy.factory import Factory
|
from kivy.factory import Factory
|
||||||
|
|
||||||
|
from kivyblocks.utils import *
|
||||||
|
|
||||||
class ScrollPanel(ScrollView):
|
class ScrollPanel(ScrollView):
|
||||||
|
x_padding_c = NumericProperty(0)
|
||||||
|
y_padding_c = NumericProperty(0)
|
||||||
|
bg_color = ListProperty(0.2, 0.2, 0.2, 1)
|
||||||
|
orient = StringProperty('H')
|
||||||
|
|
||||||
def __init__(self,inner=None, **kw):
|
def __init__(self,inner=None, **kw):
|
||||||
print('ScrollPanel(): kw=', kw)
|
|
||||||
super(ScrollPanel,self).__init__()
|
super(ScrollPanel,self).__init__()
|
||||||
self.effect_cls = ScrollEffect
|
self.effect_cls = ScrollEffect
|
||||||
if not inner:
|
if not inner:
|
||||||
kw.update({
|
kw.update({
|
||||||
'size_hint':(None,None),
|
'size_hint':(None,None),
|
||||||
|
'bg_color':self.bg_color,
|
||||||
'orientation':'vertical'
|
'orientation':'vertical'
|
||||||
})
|
})
|
||||||
self._inner = BoxLayout(**kw)
|
desc = {
|
||||||
|
"widgettype":"Box",
|
||||||
|
"options":kw
|
||||||
|
}
|
||||||
|
self._inner = Factory.Blocks().widgetBuild(desc)
|
||||||
elif isinstance(inner, Widget):
|
elif isinstance(inner, Widget):
|
||||||
self._inner = inner
|
self._inner = inner
|
||||||
else:
|
else:
|
||||||
self._inner = Factory.Blocks().widgetBuild(inner)
|
self._inner = Factory.Blocks().widgetBuild(inner)
|
||||||
|
|
||||||
|
if isinstance(self._inner, BoxLayout):
|
||||||
|
if self.orient.upper() == 'H':
|
||||||
|
self._inner.orientation = 'horizontal'
|
||||||
|
else:
|
||||||
|
self._inner.orientation = 'vertical'
|
||||||
|
self.padding = self.spacing = \
|
||||||
|
[CSize(self.x_padding_c), CSize(self.y_padding_c)]
|
||||||
|
|
||||||
self._inner.bind(
|
self._inner.bind(
|
||||||
minimum_height=self._inner.setter('height'))
|
minimum_height=self._inner.setter('height'))
|
||||||
self._inner.bind(
|
self._inner.bind(
|
||||||
|
Loading…
Reference in New Issue
Block a user