bugfix
This commit is contained in:
parent
2b47c02f6b
commit
5ac654366e
2252
kivyblocks/blocks.c
2252
kivyblocks/blocks.c
File diff suppressed because it is too large
Load Diff
@ -491,7 +491,8 @@ class Blocks(EventDispatcher):
|
|||||||
d = self.getActionData(widget,desc, *args)
|
d = self.getActionData(widget,desc, *args)
|
||||||
ns = {
|
ns = {
|
||||||
"self":target,
|
"self":target,
|
||||||
"args":args
|
"args":args,
|
||||||
|
"kwargs":d
|
||||||
}
|
}
|
||||||
if d:
|
if d:
|
||||||
ns.update(d)
|
ns.update(d)
|
||||||
@ -692,7 +693,10 @@ class Blocks(EventDispatcher):
|
|||||||
from_widget=from_widget.parent)
|
from_widget=from_widget.parent)
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
for c in from_widget.children:
|
children = [i for i in from_widget.children]
|
||||||
|
if hasattr(from_widget, 'get_subwidgets'):
|
||||||
|
children = from_widget.get_subwidgets()
|
||||||
|
for c in children:
|
||||||
ret = find_widget_by_id(id,from_widget=c)
|
ret = find_widget_by_id(id,from_widget=c)
|
||||||
if ret:
|
if ret:
|
||||||
return ret
|
return ret
|
||||||
|
1530
kivyblocks/dg.c
1530
kivyblocks/dg.c
File diff suppressed because it is too large
Load Diff
@ -411,9 +411,13 @@ class DataGrid(WidgetReady, BoxLayout):
|
|||||||
if self.freeze_part and o == self.freeze_part.body:
|
if self.freeze_part and o == self.freeze_part.body:
|
||||||
self.normal_part.body.scroll_y = o.scroll_y
|
self.normal_part.body.scroll_y = o.scroll_y
|
||||||
|
|
||||||
if o.scroll_y <= 0.001:
|
if o.scroll_y <= 0.01:
|
||||||
|
print('loading next page...', self.dataloader.curpage)
|
||||||
|
self.loading = True
|
||||||
self.dataloader.loadNextPage()
|
self.dataloader.loadNextPage()
|
||||||
if o.scroll_y >= 0.999:
|
if o.scroll_y >= 0.99:
|
||||||
|
print('loading previous page...', self.dataloader.curpage)
|
||||||
|
self.loading = True
|
||||||
self.dataloader.loadPreviousPage()
|
self.dataloader.loadPreviousPage()
|
||||||
|
|
||||||
def getValue(self):
|
def getValue(self):
|
||||||
@ -484,8 +488,6 @@ class DataGrid(WidgetReady, BoxLayout):
|
|||||||
data['data'] = recs2
|
data['data'] = recs2
|
||||||
f = partial(self.add_page_delay,data)
|
f = partial(self.add_page_delay,data)
|
||||||
Clock.schedule_once(f, 0)
|
Clock.schedule_once(f, 0)
|
||||||
print('body=', self.normal_part.body.size,
|
|
||||||
'inner=', self.normal_part.body._inner.size)
|
|
||||||
|
|
||||||
def add_page_delay(self, data, *args):
|
def add_page_delay(self, data, *args):
|
||||||
recs = data['data']
|
recs = data['data']
|
||||||
@ -505,6 +507,7 @@ class DataGrid(WidgetReady, BoxLayout):
|
|||||||
self.dataloader.bufferObjects(page,ids)
|
self.dataloader.bufferObjects(page,ids)
|
||||||
x = self.dataloader.getLocater()
|
x = self.dataloader.getLocater()
|
||||||
self.locater(x)
|
self.locater(x)
|
||||||
|
self.loading = False
|
||||||
|
|
||||||
def delete_page(self,o,data):
|
def delete_page(self,o,data):
|
||||||
print('dg.py:delete_page() called')
|
print('dg.py:delete_page() called')
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
from kivy.factory import Factory
|
from kivy.factory import Factory
|
||||||
|
from kivy.properties import NumericProperty, StringProperty, \
|
||||||
|
DictProperty, ListProperty, OptionProperty, BooleanProperty
|
||||||
from kivy.logger import Logger
|
from kivy.logger import Logger
|
||||||
from kivy.uix.textinput import TextInput
|
from kivy.uix.textinput import TextInput
|
||||||
from kivy.uix.boxlayout import BoxLayout
|
from kivy.uix.boxlayout import BoxLayout
|
||||||
@ -23,7 +25,7 @@ form options
|
|||||||
"toolbar":
|
"toolbar":
|
||||||
"dataloader":{
|
"dataloader":{
|
||||||
"dataurl":"first"
|
"dataurl":"first"
|
||||||
"datatarget":"second",
|
"datatargment":"second",
|
||||||
"datarfname":"third"
|
"datarfname":"third"
|
||||||
"params":
|
"params":
|
||||||
"method"
|
"method"
|
||||||
@ -52,9 +54,11 @@ form options
|
|||||||
|
|
||||||
class InputBox(BoxLayout):
|
class InputBox(BoxLayout):
|
||||||
def __init__(self, form, **options):
|
def __init__(self, form, **options):
|
||||||
|
self.input_widget = None
|
||||||
self.form = form
|
self.form = form
|
||||||
self.options = options
|
self.options = options
|
||||||
self.uitype = options.get('uitype',options.get('datatype','str'))
|
self.uitype = options.get('uitype',options.get('datatype','str'))
|
||||||
|
self.size_hint = (None, None)
|
||||||
width = self.form.inputwidth
|
width = self.form.inputwidth
|
||||||
height = self.form.inputheight
|
height = self.form.inputheight
|
||||||
if self.uitype == 'text':
|
if self.uitype == 'text':
|
||||||
@ -82,6 +86,18 @@ class InputBox(BoxLayout):
|
|||||||
pos=self.setSize)
|
pos=self.setSize)
|
||||||
self.register_event_type("on_datainput")
|
self.register_event_type("on_datainput")
|
||||||
|
|
||||||
|
def on_size(self, *args):
|
||||||
|
if self.input_widget is None:
|
||||||
|
return
|
||||||
|
self.labeltext.size_hint_x = None
|
||||||
|
if self.form.labelwidth < 1:
|
||||||
|
self.labeltext.width = self.width * self.form.labelwidth - \
|
||||||
|
CSize(1)
|
||||||
|
else:
|
||||||
|
self.labeltext.width = CSize(self.form.labelwidth)
|
||||||
|
|
||||||
|
self.input_widget.size_hint_x = None
|
||||||
|
self.input_widget.width = self.width - self.labeltext.width - CSize(1)
|
||||||
def on_datainput(self,o,v=None):
|
def on_datainput(self,o,v=None):
|
||||||
print('on_datainput fired ...',o,v)
|
print('on_datainput fired ...',o,v)
|
||||||
|
|
||||||
@ -92,8 +108,14 @@ class InputBox(BoxLayout):
|
|||||||
opts = {
|
opts = {
|
||||||
"orientation":"horizontal",
|
"orientation":"horizontal",
|
||||||
"size_hint_y":None,
|
"size_hint_y":None,
|
||||||
"height":CSize(2)
|
"height":CSize(self.form.inputheight)
|
||||||
}
|
}
|
||||||
|
if self.form.inputwidth > 1:
|
||||||
|
opts['size_hint_x'] = None
|
||||||
|
opts['width'] = CSize(self.form.inputwidth)
|
||||||
|
else:
|
||||||
|
opts['size_hint_x'] = self.form.inputwidth
|
||||||
|
|
||||||
bl = BoxLayout(**opts)
|
bl = BoxLayout(**opts)
|
||||||
self.add_widget(bl)
|
self.add_widget(bl)
|
||||||
label = self.options.get('label',self.options.get('name'))
|
label = self.options.get('label',self.options.get('name'))
|
||||||
@ -102,6 +124,12 @@ class InputBox(BoxLayout):
|
|||||||
"otext":label,
|
"otext":label,
|
||||||
"font_size":CSize(1),
|
"font_size":CSize(1),
|
||||||
}
|
}
|
||||||
|
if self.form.labelwidth < 1:
|
||||||
|
kwargs['size_hint_x'] = self.form.labelwidth
|
||||||
|
else:
|
||||||
|
kwargs['size_hint_x'] = None
|
||||||
|
kwargs['width'] = CSize(self.form.labelwidth)
|
||||||
|
|
||||||
self.labeltext = Text(**kwargs)
|
self.labeltext = Text(**kwargs)
|
||||||
bl.add_widget(self.labeltext)
|
bl.add_widget(self.labeltext)
|
||||||
if self.options.get('required',False):
|
if self.options.get('required',False):
|
||||||
@ -115,6 +143,11 @@ class InputBox(BoxLayout):
|
|||||||
options['hint_text'] = i18n(self.options.get('hint_text'))
|
options['hint_text'] = i18n(self.options.get('hint_text'))
|
||||||
f = get_input_builder(self.uitype)
|
f = get_input_builder(self.uitype)
|
||||||
self.input_widget = f(options)
|
self.input_widget = f(options)
|
||||||
|
if self.form.labelwidth < 1:
|
||||||
|
self.input_widget.size_hint_x = 1 - self.form.labelwidth
|
||||||
|
else:
|
||||||
|
self.input_widget.size_hint_x = None
|
||||||
|
self.input_widget.width = self.width - self.labeltext.width - CSize(1)
|
||||||
if self.options.get('readonly'):
|
if self.options.get('readonly'):
|
||||||
self.input_widget.disabled = True
|
self.input_widget.disabled = True
|
||||||
if self.options.get('value'):
|
if self.options.get('value'):
|
||||||
@ -171,17 +204,21 @@ class InputBox(BoxLayout):
|
|||||||
|
|
||||||
def defaultToolbar():
|
def defaultToolbar():
|
||||||
return {
|
return {
|
||||||
"img_size_c":1.5,
|
"img_size_c":1,
|
||||||
"text_size_c":0.7,
|
"text_size_c":1,
|
||||||
|
"toolbar_orient":"H",
|
||||||
|
"tool_orient":"horizontal",
|
||||||
"tools":[
|
"tools":[
|
||||||
{
|
{
|
||||||
"name":"__submit",
|
"name":"__submit",
|
||||||
"img_src":"/imgs/submit.png",
|
"source_on":blockImage("save.png"),
|
||||||
|
"source_off":blockImage("save.png"),
|
||||||
"label":"submit"
|
"label":"submit"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"__clear",
|
"name":"__clear",
|
||||||
"img_src":"/imgs/clear.png",
|
"source_on":blockImage("clear.png"),
|
||||||
|
"source_off":blockImage("clear.png"),
|
||||||
"label":"clear"
|
"label":"clear"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -189,44 +226,30 @@ def defaultToolbar():
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Form(WidgetCSS, WidgetReady, BoxLayout):
|
class Form(WidgetCSS, WidgetReady, BoxLayout):
|
||||||
|
cols = NumericProperty(1)
|
||||||
|
csscls=StringProperty('formcss')
|
||||||
|
input_css=StringProperty('formfieldcss')
|
||||||
|
inputwidth=NumericProperty(1)
|
||||||
|
inputheight=NumericProperty(3)
|
||||||
|
labelwidth=NumericProperty(0.3)
|
||||||
|
toolbar_at=OptionProperty('top', \
|
||||||
|
options=['top','bottom','left','right'])
|
||||||
|
dataloader=DictProperty(None)
|
||||||
|
fields = ListProperty([])
|
||||||
|
toolbar=DictProperty(None)
|
||||||
|
submit=DictProperty(None)
|
||||||
|
clear=DictProperty(None)
|
||||||
|
notoolbar=BooleanProperty(False)
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
cols=1,
|
|
||||||
csscls='default',
|
|
||||||
input_css='input',
|
|
||||||
inputwidth=0,
|
|
||||||
inputheight=3,
|
|
||||||
labelwidth=0.3,
|
|
||||||
notoolbar=False,
|
|
||||||
toolbar_at='top', #'top', 'bottom', 'left', 'right'
|
|
||||||
dataloader={},
|
|
||||||
fields=[],
|
|
||||||
submit={},
|
|
||||||
clear={},
|
|
||||||
toolbar={},
|
|
||||||
**options):
|
**options):
|
||||||
self.inputwidth = 1
|
|
||||||
self.input_css = input_css
|
|
||||||
self.inputheight = inputheight
|
|
||||||
self.labelwidth= labelwidth
|
|
||||||
self.fields = fields
|
|
||||||
self.notoolbar = notoolbar
|
|
||||||
self.submit = submit
|
|
||||||
self.clear = clear
|
|
||||||
self.toolbar = toolbar
|
|
||||||
self.toolbar_at=toolbar_at
|
|
||||||
self.dataloader = dataloader
|
|
||||||
self.readiedInput = 0
|
|
||||||
if self.toolbar_at in ['top','bottom']:
|
if self.toolbar_at in ['top','bottom']:
|
||||||
options['orientation'] = 'vertical'
|
options['orientation'] = 'vertical'
|
||||||
else:
|
else:
|
||||||
options['orientation'] = 'horizontal'
|
options['orientation'] = 'horizontal'
|
||||||
print('options=', options)
|
SUPER(Form, self, options)
|
||||||
super(Form, self).__init__(**options)
|
if self.inputwidth <= 1:
|
||||||
#BoxLayout.__init__(self, **options)
|
self.cols = 1
|
||||||
#WidgetReady.__init__(self)
|
self.options_cols = self.cols
|
||||||
#WidgetCSS.__init__(self)
|
|
||||||
self.csscls = csscls
|
|
||||||
self.cols = self.options_cols = cols
|
|
||||||
if isHandHold() and Window.width < Window.height:
|
if isHandHold() and Window.width < Window.height:
|
||||||
self.cols = 1
|
self.cols = 1
|
||||||
self.options = options
|
self.options = options
|
||||||
@ -239,53 +262,47 @@ class Form(WidgetCSS, WidgetReady, BoxLayout):
|
|||||||
|
|
||||||
if not self.notoolbar:
|
if not self.notoolbar:
|
||||||
if self.toolbar_at in ['top', 'bottom']:
|
if self.toolbar_at in ['top', 'bottom']:
|
||||||
self.fsc.height = self.height - self.toolbar.height
|
self.fsc.height = self.height - self.toolbar_w.height
|
||||||
else:
|
else:
|
||||||
self.fsc.width = self.width - self.toolbar.width
|
self.fsc.width = self.width - self.toolbar_w.width
|
||||||
else:
|
else:
|
||||||
if self.toolbar_at in ['top', 'bottom']:
|
if self.toolbar_at in ['top', 'bottom']:
|
||||||
self.fsc.height = self.height
|
self.fsc.height = self.height
|
||||||
else:
|
else:
|
||||||
self.fsc.width = self.width
|
self.fsc.width = self.width
|
||||||
self.fsc.org_box_width = self.width / self.options_cols
|
self.fsc.org_box_width = self.width / self.options_cols
|
||||||
if self.notoolbar:
|
|
||||||
return
|
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
if not self.notoolbar:
|
if not self.notoolbar:
|
||||||
desc = defaultToolbar()
|
desc = defaultToolbar()
|
||||||
desc1 = self.toolbar
|
desc1 = self.toolbar
|
||||||
|
tools = desc['tools'].copy()
|
||||||
if desc1:
|
if desc1:
|
||||||
tools = desc['tools'] + desc1['tools']
|
desc.update(desc1)
|
||||||
desc1['tools'] = tools
|
tools = tools + desc1['tools']
|
||||||
desc = desc1
|
|
||||||
if self.submit:
|
if self.submit:
|
||||||
kw = self.submit.copy()
|
kw = self.submit.copy()
|
||||||
if kw.get('name'):
|
if kw.get('name'):
|
||||||
del kw['name']
|
del kw['name']
|
||||||
for t in desc['tools']:
|
for t in tools:
|
||||||
if t['name'] == '__submit':
|
if t['name'] == '__submit':
|
||||||
t.update(kw)
|
t.update(kw)
|
||||||
if self.clear:
|
if self.clear:
|
||||||
kw = self.clear.copy()
|
kw = self.clear.copy()
|
||||||
if kw.get('name'):
|
if kw.get('name'):
|
||||||
del kw['name']
|
del kw['name']
|
||||||
for t in desc['tools']:
|
for t in tools:
|
||||||
if t['name'] == '__clear':
|
if t['name'] == '__clear':
|
||||||
t.update(kw)
|
t.update(kw)
|
||||||
|
|
||||||
|
desc['tools'] = tools
|
||||||
if self.toolbar_at in ['top', 'bottom']:
|
if self.toolbar_at in ['top', 'bottom']:
|
||||||
desc['orientation'] = 'horizontal'
|
desc['toolbar_orient'] = 'H'
|
||||||
desc['size_hint_y'] = None
|
|
||||||
desc['height'] = CSize(desc['img_size_c'] + \
|
|
||||||
desc['text_size_c'])
|
|
||||||
else:
|
else:
|
||||||
desc['orientation'] = 'vertical'
|
desc['toolbar_orient'] = 'V'
|
||||||
desc['size_hint_x'] = None
|
desc['tool_orient'] = 'veritcal'
|
||||||
desc['width'] = CSize(desc['img_size_c'] + \
|
|
||||||
desc['text_size_c'])
|
self.toolbar_w = Factory.Toolbar(**desc)
|
||||||
|
|
||||||
self.toolbar = Toolbar(**desc)
|
|
||||||
self.fsc = VResponsiveLayout(
|
self.fsc = VResponsiveLayout(
|
||||||
self.inputwidth,
|
self.inputwidth,
|
||||||
self.cols,
|
self.cols,
|
||||||
@ -293,10 +310,10 @@ class Form(WidgetCSS, WidgetReady, BoxLayout):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if self.toolbar_at in ['top', 'left'] and not self.notoolbar:
|
if self.toolbar_at in ['top', 'left'] and not self.notoolbar:
|
||||||
self.add_widget(self.toolbar)
|
self.add_widget(self.toolbar_w)
|
||||||
self.add_widget(self.fsc)
|
self.add_widget(self.fsc)
|
||||||
if self.toolbar_at in ['bottom', 'right'] and not self.notoolbar:
|
if self.toolbar_at in ['bottom', 'right'] and not self.notoolbar:
|
||||||
self.add_widget(self.toolbar)
|
self.add_widget(self.toolbar_w)
|
||||||
|
|
||||||
self.fieldWidgets=[]
|
self.fieldWidgets=[]
|
||||||
for f in self.fields:
|
for f in self.fields:
|
||||||
@ -348,7 +365,7 @@ class Form(WidgetCSS, WidgetReady, BoxLayout):
|
|||||||
Logger.info('kivyblcks: input check success')
|
Logger.info('kivyblcks: input check success')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def on_submit(self,v=None):
|
def on_submit(self,o, v=None):
|
||||||
print('Form():on_submit fired ...',v)
|
print('Form():on_submit fired ...',v)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class Hirarchy(ScrollPanel):
|
|||||||
icon = StringProperty(None)
|
icon = StringProperty(None)
|
||||||
single_expand = BooleanProperty(False)
|
single_expand = BooleanProperty(False)
|
||||||
def __init__(self, **kw):
|
def __init__(self, **kw):
|
||||||
self.register_event_type('on_selected')
|
self.register_event_type('on_press')
|
||||||
self.tree = TreeView(hide_root=True)
|
self.tree = TreeView(hide_root=True)
|
||||||
self.tree.size_hint = (None, None)
|
self.tree.size_hint = (None, None)
|
||||||
self.tree.bind(on_node_expand=self.check_load_subnodes)
|
self.tree.bind(on_node_expand=self.check_load_subnodes)
|
||||||
@ -65,11 +65,11 @@ class Hirarchy(ScrollPanel):
|
|||||||
if self.url:
|
if self.url:
|
||||||
self.data = self.get_remote_data()
|
self.data = self.get_remote_data()
|
||||||
|
|
||||||
def on_selected(self, node):
|
def on_press(self, node):
|
||||||
print('selected node=', node)
|
print('selected node=', node)
|
||||||
|
|
||||||
def node_selected(self, o, v):
|
def node_selected(self, o, v):
|
||||||
self.dispatch('on_selected', o.selected_node)
|
self.dispatch('on_press', o.selected_node)
|
||||||
|
|
||||||
def collapse_others(self, node):
|
def collapse_others(self, node):
|
||||||
for n in self.tree.iterate_open_nodes(node=node.parent_node):
|
for n in self.tree.iterate_open_nodes(node=node.parent_node):
|
||||||
@ -136,7 +136,7 @@ class Menu(Hirarchy):
|
|||||||
self.target_w = None
|
self.target_w = None
|
||||||
super(Menu, self).__init__(**kw)
|
super(Menu, self).__init__(**kw)
|
||||||
|
|
||||||
def on_selected(self, node):
|
def on_press(self, node):
|
||||||
data = {}
|
data = {}
|
||||||
dw = node.data.get('datawidget')
|
dw = node.data.get('datawidget')
|
||||||
if dw:
|
if dw:
|
||||||
|
@ -140,7 +140,6 @@ sub-widget's description file format
|
|||||||
bar_at='top',
|
bar_at='top',
|
||||||
enable_on_close=False,
|
enable_on_close=False,
|
||||||
left_menu=None, **kw):
|
left_menu=None, **kw):
|
||||||
print('PagePanel().__init__():', bar_size, bar_at, left_menu)
|
|
||||||
self.bar_size = bar_size
|
self.bar_size = bar_size
|
||||||
self.bar_at = bar_at
|
self.bar_at = bar_at
|
||||||
self.singlepage = singlepage
|
self.singlepage = singlepage
|
||||||
@ -243,6 +242,14 @@ sub-widget's description file format
|
|||||||
self.left_menu_showed = False
|
self.left_menu_showed = False
|
||||||
self.right_menu_showed = False
|
self.right_menu_showed = False
|
||||||
|
|
||||||
|
def get_subwidgets(self):
|
||||||
|
children = [self.bar]
|
||||||
|
if self.fixed_before:
|
||||||
|
children.append(self.fixed_before)
|
||||||
|
if self.fixed_after:
|
||||||
|
children.append(self.fixed_after)
|
||||||
|
return children + self.sub_widgets
|
||||||
|
|
||||||
def on_close_handle(self, o, *args):
|
def on_close_handle(self, o, *args):
|
||||||
print('app.on_close fired, ...')
|
print('app.on_close fired, ...')
|
||||||
if not self.enable_on_close:
|
if not self.enable_on_close:
|
||||||
@ -281,11 +288,12 @@ sub-widget's description file format
|
|||||||
|
|
||||||
def on_swipe_next_page(self, o, *args):
|
def on_swipe_next_page(self, o, *args):
|
||||||
if len(self.swipe_buffer) < 1:
|
if len(self.swipe_buffer) < 1:
|
||||||
return
|
return True
|
||||||
self.swipe_right = True
|
self.swipe_right = True
|
||||||
w = self.swipe_buffer[0]
|
w = self.swipe_buffer[0]
|
||||||
del self.swipe_buffer[0]
|
del self.swipe_buffer[0]
|
||||||
self.add_widget(w)
|
self.add_widget(w)
|
||||||
|
return True
|
||||||
|
|
||||||
def clear_widgets(self):
|
def clear_widgets(self):
|
||||||
self.bar_back.clear_widgets()
|
self.bar_back.clear_widgets()
|
||||||
@ -293,16 +301,18 @@ sub-widget's description file format
|
|||||||
self.bar_right_menu.clear_widgets()
|
self.bar_right_menu.clear_widgets()
|
||||||
|
|
||||||
def add_widget(self, w, *args):
|
def add_widget(self, w, *args):
|
||||||
|
print('here ....')
|
||||||
if not self.swipe_right:
|
if not self.swipe_right:
|
||||||
self.swipe_buffer = []
|
self.swipe_buffer = []
|
||||||
self.swipe_right = False
|
self.swipe_right = False
|
||||||
self.clear_widgets()
|
self.clear_widgets()
|
||||||
if len(self.sub_widgets) > 0:
|
|
||||||
pass
|
|
||||||
if self.singlepage:
|
if self.singlepage:
|
||||||
self.sub_widgets = []
|
self.sub_widgets = []
|
||||||
self.sub_widgets.append(w)
|
self.sub_widgets.append(w)
|
||||||
self.show_currentpage()
|
self.show_currentpage()
|
||||||
|
show_widget_info(self)
|
||||||
|
for w in self.get_subwidgets():
|
||||||
|
show_widget_info(w)
|
||||||
|
|
||||||
def show_left_menu(self, o):
|
def show_left_menu(self, o):
|
||||||
def x(*args):
|
def x(*args):
|
||||||
@ -345,6 +355,7 @@ sub-widget's description file format
|
|||||||
return True
|
return True
|
||||||
mc = MenuContainer()
|
mc = MenuContainer()
|
||||||
mc.add_widget(w.menu_widget)
|
mc.add_widget(w.menu_widget)
|
||||||
|
self.w.menu_widget.bind(on_press=mc.dismiss)
|
||||||
mc.size_hint = (None,None)
|
mc.size_hint = (None,None)
|
||||||
mc.height = self.content.height
|
mc.height = self.content.height
|
||||||
mc.width = self.width * 0.4
|
mc.width = self.width * 0.4
|
||||||
|
@ -83,10 +83,13 @@ class PageLoader(EventDispatcher):
|
|||||||
dir:'up' or 'down'
|
dir:'up' or 'down'
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
pass
|
|
||||||
|
|
||||||
def do_search(self,o,params):
|
def do_search(self,o,params):
|
||||||
self.newbegin = True
|
self.newbegin = True
|
||||||
|
self.total_cnt = 0
|
||||||
|
self.total_page = 0
|
||||||
|
self.curpage = 0
|
||||||
|
self.dir = 'down'
|
||||||
self.dispatch('on_newbegin')
|
self.dispatch('on_newbegin')
|
||||||
self.params.update(params)
|
self.params.update(params)
|
||||||
self.loadPage(1)
|
self.loadPage(1)
|
||||||
@ -102,12 +105,6 @@ class PageLoader(EventDispatcher):
|
|||||||
self.page_rows = row_cnt
|
self.page_rows = row_cnt
|
||||||
if self.total_cnt != 0:
|
if self.total_cnt != 0:
|
||||||
self.calculateTotalPage()
|
self.calculateTotalPage()
|
||||||
self.reload()
|
|
||||||
|
|
||||||
def reload(self):
|
|
||||||
if self.curpage == 0:
|
|
||||||
self.curpage = 1
|
|
||||||
self.loadPage(self.curpage)
|
|
||||||
|
|
||||||
def show_page(self,o,d):
|
def show_page(self,o,d):
|
||||||
p = (self.curpage - 1) * self.page_rows + 1
|
p = (self.curpage - 1) * self.page_rows + 1
|
||||||
@ -122,45 +119,49 @@ class PageLoader(EventDispatcher):
|
|||||||
"data":d['rows']
|
"data":d['rows']
|
||||||
}
|
}
|
||||||
self.dispatch('on_pageloaded',d)
|
self.dispatch('on_pageloaded',d)
|
||||||
|
self.loading = False
|
||||||
|
|
||||||
def onerror(self,o,e):
|
def onerror(self,o,e):
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
alert(str(e),title='alert')
|
alert(str(e),title='alert')
|
||||||
|
self.loading = False
|
||||||
|
|
||||||
def loadNextPage(self):
|
def loadNextPage(self):
|
||||||
|
if self.loading:
|
||||||
|
print('is loading, return')
|
||||||
|
return
|
||||||
|
|
||||||
if self.total_page > 0 and self.curpage >=self.total_page:
|
if self.total_page > 0 and self.curpage >=self.total_page:
|
||||||
return
|
return
|
||||||
p = self.curpage + 1
|
p = self.curpage + 1
|
||||||
self.loadPage(p)
|
self.loadPage(p)
|
||||||
|
|
||||||
def loadPreviousPage(self):
|
def loadPreviousPage(self):
|
||||||
|
if self.loading:
|
||||||
|
print('is loading, return')
|
||||||
|
return
|
||||||
|
|
||||||
if self.curpage <= 1:
|
if self.curpage <= 1:
|
||||||
return
|
return
|
||||||
p = self.curpage - 1
|
p = self.curpage - 1
|
||||||
self.loadPage(p)
|
self.loadPage(p)
|
||||||
|
|
||||||
def loadPage(self,p):
|
def loadPage(self,p):
|
||||||
|
if p == self.curpage:
|
||||||
|
return
|
||||||
|
|
||||||
|
if self.loading:
|
||||||
|
print('is loading, return')
|
||||||
|
return
|
||||||
|
|
||||||
|
self.loading = True
|
||||||
|
print(f'loading {p} page, {self.curpage}')
|
||||||
if self.curpage > p:
|
if self.curpage > p:
|
||||||
self.dir = 'up'
|
self.dir = 'up'
|
||||||
elif self.curpage == p:
|
|
||||||
self.dir = 'reload'
|
|
||||||
else:
|
else:
|
||||||
self.dir = 'down'
|
self.dir = 'down'
|
||||||
self.curpage = p
|
self.curpage = p
|
||||||
self.loading = True
|
|
||||||
self.loader.load()
|
self.loader.load()
|
||||||
"""
|
|
||||||
params = self.params.copy()
|
|
||||||
params.update({
|
|
||||||
"page":self.curpage,
|
|
||||||
"rows":self.page_rows
|
|
||||||
})
|
|
||||||
realurl = absurl(self.url,self.target.parenturl)
|
|
||||||
loader = HTTPDataHandler(realurl,params=params)
|
|
||||||
loader.bind(on_success=self.show_page)
|
|
||||||
loader.bind(on_failed=self.httperror)
|
|
||||||
loader.handle()
|
|
||||||
"""
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
{
|
{
|
||||||
@ -190,6 +191,13 @@ class RelatedLoader(PageLoader):
|
|||||||
self.widget = None
|
self.widget = None
|
||||||
self.register_event_type('on_deletepage')
|
self.register_event_type('on_deletepage')
|
||||||
|
|
||||||
|
def do_search(self,o,params):
|
||||||
|
self.objectPages = {}
|
||||||
|
self.totalObj = 0
|
||||||
|
self.MaxbufferPage = 3
|
||||||
|
self.locater = 1/self.MaxbufferPage
|
||||||
|
super().do_search(o, params)
|
||||||
|
|
||||||
def getLocater(self):
|
def getLocater(self):
|
||||||
if self.newbegin:
|
if self.newbegin:
|
||||||
self.newbegin = False
|
self.newbegin = False
|
||||||
@ -206,7 +214,6 @@ class RelatedLoader(PageLoader):
|
|||||||
def setPageRows(self,row_cnt):
|
def setPageRows(self,row_cnt):
|
||||||
if self.total_cnt != 0:
|
if self.total_cnt != 0:
|
||||||
self.calculateTotalPage()
|
self.calculateTotalPage()
|
||||||
self.reload()
|
|
||||||
|
|
||||||
def doBufferMaintain(self):
|
def doBufferMaintain(self):
|
||||||
siz = len(self.objectPages.keys())
|
siz = len(self.objectPages.keys())
|
||||||
@ -234,12 +241,8 @@ class RelatedLoader(PageLoader):
|
|||||||
self.doBufferMaintain()
|
self.doBufferMaintain()
|
||||||
self.totalObj += len(data['rows'])
|
self.totalObj += len(data['rows'])
|
||||||
super().show_page(o,data)
|
super().show_page(o,data)
|
||||||
self.loading = False
|
|
||||||
|
|
||||||
def loadPreviousPage(self):
|
def loadPreviousPage(self):
|
||||||
if self.loading:
|
|
||||||
return
|
|
||||||
|
|
||||||
pages = self.objectPages.keys()
|
pages = self.objectPages.keys()
|
||||||
if len(pages) < 1:
|
if len(pages) < 1:
|
||||||
return
|
return
|
||||||
@ -252,8 +255,6 @@ class RelatedLoader(PageLoader):
|
|||||||
self.loadPage(page)
|
self.loadPage(page)
|
||||||
|
|
||||||
def loadNextPage(self):
|
def loadNextPage(self):
|
||||||
if self.loading:
|
|
||||||
return
|
|
||||||
pages = self.objectPages.keys()
|
pages = self.objectPages.keys()
|
||||||
if len(pages) == 0:
|
if len(pages) == 0:
|
||||||
return
|
return
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
from kivy.uix.label import Label
|
from kivy.uix.label import Label
|
||||||
from kivy.properties import NumericProperty
|
from kivy.properties import NumericProperty, ColorProperty
|
||||||
from kivy.factory import Factory
|
from kivy.factory import Factory
|
||||||
|
|
||||||
from kivyblocks.uitype import view_register, get_value
|
from kivyblocks.uitype import view_register, get_value
|
||||||
|
|
||||||
class Price(Label):
|
class PriceView(Label):
|
||||||
dec = NumericProperty(4)
|
dec = NumericProperty(4)
|
||||||
old_price = NumericProperty(None)
|
old_price = NumericProperty(None)
|
||||||
price = NumericProperty(None)
|
price = NumericProperty(None)
|
||||||
@ -13,7 +13,7 @@ class Price(Label):
|
|||||||
inc_color = ColorProperty([0.9,0,0,1]) # red
|
inc_color = ColorProperty([0.9,0,0,1]) # red
|
||||||
dec_color = ColorProperty([0,0.9,0,1]) # green
|
dec_color = ColorProperty([0,0.9,0,1]) # green
|
||||||
def __init__(self, **kw):
|
def __init__(self, **kw):
|
||||||
super(Price, self).__init__(text='', **kw)
|
super(PriceView, self).__init__(text='', **kw)
|
||||||
|
|
||||||
def on_price(self, price):
|
def on_price(self, price):
|
||||||
if self.price is None:
|
if self.price is None:
|
||||||
@ -34,11 +34,17 @@ class Price(Label):
|
|||||||
self.color = nor_color
|
self.color = nor_color
|
||||||
self.old_price = self.price
|
self.old_price = self.price
|
||||||
|
|
||||||
Factory.register('Price', Price)
|
def getValue(self):
|
||||||
|
return self.price
|
||||||
|
|
||||||
|
def setValue(self, v):
|
||||||
|
self.price = v
|
||||||
|
|
||||||
|
Factory.register('PriceView', PriceView)
|
||||||
|
|
||||||
def build_view_price_widget(desc, rec=None):
|
def build_view_price_widget(desc, rec=None):
|
||||||
v = get_value(desc, rec=rec)
|
v = get_value(desc, rec=rec)
|
||||||
return Factory.Price(price=v,
|
return Factory.PriceView(price=v,
|
||||||
font_size=CSize(1),
|
font_size=CSize(1),
|
||||||
halign='right',
|
halign='right',
|
||||||
valign='middle'
|
valign='middle'
|
||||||
|
@ -41,7 +41,7 @@ from .paging import PageLoader
|
|||||||
from .dateinput import DateInput
|
from .dateinput import DateInput
|
||||||
from .block_test import BlockTest
|
from .block_test import BlockTest
|
||||||
from .hirarchy import Hirarchy
|
from .hirarchy import Hirarchy
|
||||||
from .price import Price
|
from .price import PriceView
|
||||||
|
|
||||||
r = Factory.register
|
r = Factory.register
|
||||||
if kivy.platform in ['win','linux', 'macosx']:
|
if kivy.platform in ['win','linux', 'macosx']:
|
||||||
|
@ -30,6 +30,9 @@ class ScrollPanel(WidgetCSS, ScrollView):
|
|||||||
self._inner.bind(
|
self._inner.bind(
|
||||||
minimum_width=self._inner.setter('width'))
|
minimum_width=self._inner.setter('width'))
|
||||||
|
|
||||||
|
def get_subwidgets(self):
|
||||||
|
return self._inner.children
|
||||||
|
|
||||||
def create_default_inner(self):
|
def create_default_inner(self):
|
||||||
kw = {
|
kw = {
|
||||||
'size_hint':(None,None),
|
'size_hint':(None,None),
|
||||||
|
@ -215,6 +215,11 @@ class ToolPage(Box):
|
|||||||
name = self.toolbar['tools'][0]['name']
|
name = self.toolbar['tools'][0]['name']
|
||||||
self.toolbar_w.select(name)
|
self.toolbar_w.select(name)
|
||||||
|
|
||||||
|
def get_subwidgets(self):
|
||||||
|
children = [ i for i in self.children]
|
||||||
|
x = [ i for i in self.content_widgets.values() ]
|
||||||
|
return children + x
|
||||||
|
|
||||||
def delete_content_widget(self, o, d):
|
def delete_content_widget(self, o, d):
|
||||||
w, dic = d
|
w, dic = d
|
||||||
self.del_tool(dic['name'])
|
self.del_tool(dic['name'])
|
||||||
|
@ -2,13 +2,14 @@ import os
|
|||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
|
from kivy.logger import Logger
|
||||||
from appPublic.jsonConfig import getConfig
|
from appPublic.jsonConfig import getConfig
|
||||||
from kivy.uix.popup import Popup
|
from kivy.uix.popup import Popup
|
||||||
from kivy.uix.button import Button
|
from kivy.uix.button import Button
|
||||||
from kivy.uix.label import Label
|
from kivy.uix.label import Label
|
||||||
from kivy.uix.boxlayout import BoxLayout
|
from kivy.uix.boxlayout import BoxLayout
|
||||||
from kivy.uix.modalview import ModalView
|
from kivy.uix.modalview import ModalView
|
||||||
from kivy.uix.image import Image
|
from kivy.uix.image import AsyncImage
|
||||||
from appPublic.dictObject import DictObject
|
from appPublic.dictObject import DictObject
|
||||||
|
|
||||||
from .kivysize import KivySizes
|
from .kivysize import KivySizes
|
||||||
@ -62,7 +63,8 @@ def loaded(widget):
|
|||||||
|
|
||||||
def loading(parent):
|
def loading(parent):
|
||||||
fp = os.path.join(os.path.dirname(__file__),'imgs','loading1.gif')
|
fp = os.path.join(os.path.dirname(__file__),'imgs','loading1.gif')
|
||||||
image = Image(source=fp,width=CSize(2),height=CSize(2),
|
image = AsyncImage(source=blockImage('loading1.gif'), \
|
||||||
|
width=CSize(2), height=CSize(2),
|
||||||
size_hint=(None,None))
|
size_hint=(None,None))
|
||||||
view = ModalView(auto_dismiss=False)
|
view = ModalView(auto_dismiss=False)
|
||||||
view.add_widget(image)
|
view.add_widget(image)
|
||||||
@ -213,3 +215,7 @@ def absurl(url,parent):
|
|||||||
paths.append(i)
|
paths.append(i)
|
||||||
return config.uihome + '/'.join(paths)
|
return config.uihome + '/'.join(paths)
|
||||||
|
|
||||||
|
def show_widget_info(w, tag='DEBUG'):
|
||||||
|
id = getattr(w, 'widget_id', 'null')
|
||||||
|
msg=f"""{tag}:size_hint={w.size_hint},size={w.size},pos={w.pos},widget_id={id}"""
|
||||||
|
Logger.info(msg)
|
||||||
|
Loading…
Reference in New Issue
Block a user