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

View File

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

View File

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

View File

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