From 4867f3db803bd5e1bb2998080cde30f1a3826253 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 24 Jul 2021 18:19:52 +0800 Subject: [PATCH] bugfix --- kivyblocks/blocks.py | 13 +++++++++---- kivyblocks/form.py | 3 ++- kivyblocks/register.py | 2 ++ kivyblocks/widgetExt/inputext.py | 21 ++++++++++++++------- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/kivyblocks/blocks.py b/kivyblocks/blocks.py index 70e7bd1..d774abc 100755 --- a/kivyblocks/blocks.py +++ b/kivyblocks/blocks.py @@ -512,9 +512,9 @@ class Blocks(EventDispatcher): def build_rtdesc(self, desc): rtdesc = desc.get('rtdata') if not rtdesc: - if desc.get('datatarget'): + if desc.get('datawidget'): rtdesc = {} - rtdesc['target'] = desc['datatarget'] + rtdesc['target'] = desc['datawidget'] if desc.get('datascript'): rtdesc['script'] = desc.get('datacript') else: @@ -536,6 +536,7 @@ class Blocks(EventDispatcher): """ if desc is None or desc == {}: + print('get_rtdata():desc is None') return {} kwargs = desc.get('kwargs', {}) if not isinstance(kwargs, dict): @@ -547,6 +548,7 @@ class Blocks(EventDispatcher): if target: w = self.getWidgetById(target, from_widget=widget) if w is None: + print('get_rtdata():w is None', desc) return {} script = desc.get('script') if script: @@ -559,15 +561,18 @@ class Blocks(EventDispatcher): return d method = desc.get('method', 'getValue') - if not hasattr(w, 'method'): + if not hasattr(w, method): + print('get_rtdata():method is None', desc, type(w)) return {} f = getattr(w, method) try: - r = f(*args, **kwargs) + r = f(**kwargs) if isinstance(r, dict): return r + print('get_rtdata():method return is not dict', desc, 'ret=', r) return {} except: + print_exc() return {} def methodAction(self, widget, desc, *args): diff --git a/kivyblocks/form.py b/kivyblocks/form.py index 536c4a7..0926141 100644 --- a/kivyblocks/form.py +++ b/kivyblocks/form.py @@ -16,6 +16,7 @@ from .color_definitions import getColors from .dataloader import DataGraber from .ready import WidgetReady from .widget_css import WidgetCSS +from .dateinput import DateInput """ form options @@ -81,7 +82,7 @@ uitypes = { }, "date":{ "orientation":"horizontal", - "wclass":DatePicker, + "wclass":DateInput, }, "time":{ "orientation":"horizontal", diff --git a/kivyblocks/register.py b/kivyblocks/register.py index d0814e4..f9cd84c 100644 --- a/kivyblocks/register.py +++ b/kivyblocks/register.py @@ -35,10 +35,12 @@ from .camerawithmic import CameraWithMic from .scrollpanel import ScrollPanel from .udp_widget import UdpWidget from .paging import PageLoader +from .dateinput import DateInput r = Factory.register if kivy.platform in ['win','linux', 'macosx']: r('ScreenWithMic', ScreenWithMic) +r('DateInput', DateInput) r('HTTPSeriesData', HTTPSeriesData) r('HTTPDataHandler', HTTPDataHandler) r('PageLoader', PageLoader) diff --git a/kivyblocks/widgetExt/inputext.py b/kivyblocks/widgetExt/inputext.py index ddedb73..78a0a89 100755 --- a/kivyblocks/widgetExt/inputext.py +++ b/kivyblocks/widgetExt/inputext.py @@ -18,9 +18,7 @@ from ..widget_css import WidgetCSS class BoolInput(Switch): def __init__(self,csscls='input', **kw): - a = {} - a['active'] = kw.get('value', kw.get('defaultvalue',False)) - super().__init__(**a) + super().__init__() self.register_event_type('on_changed') self.bind(active=on_active) @@ -70,7 +68,7 @@ class StrInput(TextInput): a['height'] = CSize(h) super(StrInput, self).__init__(**a) - self.old_value = None + self.text = self.old_value = '' self.register_event_type('on_changed') self.bind(on_text_validate=self.checkChange) @@ -79,7 +77,9 @@ class StrInput(TextInput): def checkChange(self,o,v=None): v = self.getValue() + print('StrInput():v=', v) if v != self.old_value: + self.old_value = v self.dispatch('on_changed',v) def getValue(self): @@ -214,7 +214,7 @@ class SelectInput(BoxLayout): def __init__(self,csscls='input', **kw): a={} w = kw.get('width',10) - h = kw.get('height',1.5) + h = kw.get('height',2.5) if w <= 1: a['size_hint_x'] = w else: @@ -224,7 +224,7 @@ class SelectInput(BoxLayout): a['size_hint_y'] = h else: a['size_hint_y'] = None - a['height'] = h + a['height'] = CSize(h) super(SelectInput,self).__init__(orientation='horizontal',\ **a) @@ -233,7 +233,7 @@ class SelectInput(BoxLayout): # self.tinp.readonly = True newkw = {} newkw.update(kw) - newkw.update({'on_select':self.setData}) + # newkw.update({'on_select':self.setData}) self.dropdown = MyDropDown(**newkw) if kw.get('value'): self.si_data = kw.get('value') @@ -241,12 +241,19 @@ class SelectInput(BoxLayout): else: self.si_data = '' self.text = '' + self.dropdown.bind(on_select=self.dropdown_select) self.tinp.text = self.text self.add_widget(self.tinp) self.old_value = self.si_data self.tinp.bind(focus=self.showDropdown) self.register_event_type('on_changed') + def dropdown_select(self, o, d): + self.setData(d) + + def set_selectable_data(self, data): + self.dropdown.setData(data) + def on_changed(self,v=None): pass