This commit is contained in:
yumoqing 2021-07-24 18:19:52 +08:00
parent 63c9141d0b
commit 4867f3db80
4 changed files with 27 additions and 12 deletions

View File

@ -512,9 +512,9 @@ class Blocks(EventDispatcher):
def build_rtdesc(self, desc): def build_rtdesc(self, desc):
rtdesc = desc.get('rtdata') rtdesc = desc.get('rtdata')
if not rtdesc: if not rtdesc:
if desc.get('datatarget'): if desc.get('datawidget'):
rtdesc = {} rtdesc = {}
rtdesc['target'] = desc['datatarget'] rtdesc['target'] = desc['datawidget']
if desc.get('datascript'): if desc.get('datascript'):
rtdesc['script'] = desc.get('datacript') rtdesc['script'] = desc.get('datacript')
else: else:
@ -536,6 +536,7 @@ class Blocks(EventDispatcher):
""" """
if desc is None or desc == {}: if desc is None or desc == {}:
print('get_rtdata():desc is None')
return {} return {}
kwargs = desc.get('kwargs', {}) kwargs = desc.get('kwargs', {})
if not isinstance(kwargs, dict): if not isinstance(kwargs, dict):
@ -547,6 +548,7 @@ class Blocks(EventDispatcher):
if target: if target:
w = self.getWidgetById(target, from_widget=widget) w = self.getWidgetById(target, from_widget=widget)
if w is None: if w is None:
print('get_rtdata():w is None', desc)
return {} return {}
script = desc.get('script') script = desc.get('script')
if script: if script:
@ -559,15 +561,18 @@ class Blocks(EventDispatcher):
return d return d
method = desc.get('method', 'getValue') 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 {} return {}
f = getattr(w, method) f = getattr(w, method)
try: try:
r = f(*args, **kwargs) r = f(**kwargs)
if isinstance(r, dict): if isinstance(r, dict):
return r return r
print('get_rtdata():method return is not dict', desc, 'ret=', r)
return {} return {}
except: except:
print_exc()
return {} return {}
def methodAction(self, widget, desc, *args): def methodAction(self, widget, desc, *args):

View File

@ -16,6 +16,7 @@ from .color_definitions import getColors
from .dataloader import DataGraber from .dataloader import DataGraber
from .ready import WidgetReady from .ready import WidgetReady
from .widget_css import WidgetCSS from .widget_css import WidgetCSS
from .dateinput import DateInput
""" """
form options form options
@ -81,7 +82,7 @@ uitypes = {
}, },
"date":{ "date":{
"orientation":"horizontal", "orientation":"horizontal",
"wclass":DatePicker, "wclass":DateInput,
}, },
"time":{ "time":{
"orientation":"horizontal", "orientation":"horizontal",

View File

@ -35,10 +35,12 @@ from .camerawithmic import CameraWithMic
from .scrollpanel import ScrollPanel from .scrollpanel import ScrollPanel
from .udp_widget import UdpWidget from .udp_widget import UdpWidget
from .paging import PageLoader from .paging import PageLoader
from .dateinput import DateInput
r = Factory.register r = Factory.register
if kivy.platform in ['win','linux', 'macosx']: if kivy.platform in ['win','linux', 'macosx']:
r('ScreenWithMic', ScreenWithMic) r('ScreenWithMic', ScreenWithMic)
r('DateInput', DateInput)
r('HTTPSeriesData', HTTPSeriesData) r('HTTPSeriesData', HTTPSeriesData)
r('HTTPDataHandler', HTTPDataHandler) r('HTTPDataHandler', HTTPDataHandler)
r('PageLoader', PageLoader) r('PageLoader', PageLoader)

View File

@ -18,9 +18,7 @@ from ..widget_css import WidgetCSS
class BoolInput(Switch): class BoolInput(Switch):
def __init__(self,csscls='input', **kw): def __init__(self,csscls='input', **kw):
a = {} super().__init__()
a['active'] = kw.get('value', kw.get('defaultvalue',False))
super().__init__(**a)
self.register_event_type('on_changed') self.register_event_type('on_changed')
self.bind(active=on_active) self.bind(active=on_active)
@ -70,7 +68,7 @@ class StrInput(TextInput):
a['height'] = CSize(h) a['height'] = CSize(h)
super(StrInput, self).__init__(**a) super(StrInput, self).__init__(**a)
self.old_value = None self.text = self.old_value = ''
self.register_event_type('on_changed') self.register_event_type('on_changed')
self.bind(on_text_validate=self.checkChange) self.bind(on_text_validate=self.checkChange)
@ -79,7 +77,9 @@ class StrInput(TextInput):
def checkChange(self,o,v=None): def checkChange(self,o,v=None):
v = self.getValue() v = self.getValue()
print('StrInput():v=', v)
if v != self.old_value: if v != self.old_value:
self.old_value = v
self.dispatch('on_changed',v) self.dispatch('on_changed',v)
def getValue(self): def getValue(self):
@ -214,7 +214,7 @@ class SelectInput(BoxLayout):
def __init__(self,csscls='input', **kw): def __init__(self,csscls='input', **kw):
a={} a={}
w = kw.get('width',10) w = kw.get('width',10)
h = kw.get('height',1.5) h = kw.get('height',2.5)
if w <= 1: if w <= 1:
a['size_hint_x'] = w a['size_hint_x'] = w
else: else:
@ -224,7 +224,7 @@ class SelectInput(BoxLayout):
a['size_hint_y'] = h a['size_hint_y'] = h
else: else:
a['size_hint_y'] = None a['size_hint_y'] = None
a['height'] = h a['height'] = CSize(h)
super(SelectInput,self).__init__(orientation='horizontal',\ super(SelectInput,self).__init__(orientation='horizontal',\
**a) **a)
@ -233,7 +233,7 @@ class SelectInput(BoxLayout):
# self.tinp.readonly = True # self.tinp.readonly = True
newkw = {} newkw = {}
newkw.update(kw) newkw.update(kw)
newkw.update({'on_select':self.setData}) # newkw.update({'on_select':self.setData})
self.dropdown = MyDropDown(**newkw) self.dropdown = MyDropDown(**newkw)
if kw.get('value'): if kw.get('value'):
self.si_data = kw.get('value') self.si_data = kw.get('value')
@ -241,12 +241,19 @@ class SelectInput(BoxLayout):
else: else:
self.si_data = '' self.si_data = ''
self.text = '' self.text = ''
self.dropdown.bind(on_select=self.dropdown_select)
self.tinp.text = self.text self.tinp.text = self.text
self.add_widget(self.tinp) self.add_widget(self.tinp)
self.old_value = self.si_data self.old_value = self.si_data
self.tinp.bind(focus=self.showDropdown) self.tinp.bind(focus=self.showDropdown)
self.register_event_type('on_changed') 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): def on_changed(self,v=None):
pass pass