From 51315fdaee2053eec63187b56c99d1bdc13c8abd Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 26 Jan 2021 13:59:30 +0800 Subject: [PATCH] bugfix --- kivyblocks/bgcolorbehavior.py | 3 +- kivyblocks/blocks.py | 22 ++++++++--- kivyblocks/imgs/backword.png | Bin 0 -> 9343 bytes kivyblocks/imgs/right_menu.png | Bin 0 -> 11761 bytes kivyblocks/register.py | 2 + kivyblocks/toolbar.py | 66 +++++++++++++++++++++++++++------ 6 files changed, 74 insertions(+), 19 deletions(-) create mode 100644 kivyblocks/imgs/backword.png create mode 100644 kivyblocks/imgs/right_menu.png diff --git a/kivyblocks/bgcolorbehavior.py b/kivyblocks/bgcolorbehavior.py index b71bbd0..8fd1881 100644 --- a/kivyblocks/bgcolorbehavior.py +++ b/kivyblocks/bgcolorbehavior.py @@ -20,10 +20,11 @@ class BGColorBehavior(object): fg,bg= getColors(color_level,selected=True) self.selected_bgcolor = bg self.selected_fgcolor = fg - self.on_bgcolor() + # self.on_bgcolor() self.bind(size=self.onSize_bgcolor_behavior, pos=self.onSize_bgcolor_behavior) + self.bind(children=self.on_bgcolor) def onSize_bgcolor_behavior(self,o,v=None): if not hasattr(self,'rect'): diff --git a/kivyblocks/blocks.py b/kivyblocks/blocks.py index 6a712e1..e7b36fd 100755 --- a/kivyblocks/blocks.py +++ b/kivyblocks/blocks.py @@ -543,11 +543,15 @@ class Blocks(EventDispatcher): return None # desc = self.valueExpr(desc) - widget = self.w_build(desc) - self.dispatch('on_built',widget) - if hasattr(widget,'ready'): - widget.ready() - return widget + try: + widget = self.w_build(desc) + self.dispatch('on_built',widget) + if hasattr(widget,'ready'): + widget.ready() + return widget + except Exception as e: + self.dispatch('on_failed',e) + return None if not (isinstance(desc, DictObject) or isinstance(desc, dict)): print('Block: desc must be a dict object', @@ -555,7 +559,8 @@ class Blocks(EventDispatcher): self.dispatch('on_failed',Exception('miss url')) return - while desc['widgettype'] == "urlwidget": + widgettype = desc.get('widgettype') + while widgettype == "urlwidget": opts = desc.get('options',{}).copy() extend = desc.get('extend') addon = None @@ -578,6 +583,11 @@ class Blocks(EventDispatcher): if addon: desc = dictExtend(desc,addon) + widgettype = desc.get('widgettype') + if widgettype is None: + print('Block: desc must be a dict object', + desc,type(desc)) + return None return doit(desc) @classmethod diff --git a/kivyblocks/imgs/backword.png b/kivyblocks/imgs/backword.png new file mode 100644 index 0000000000000000000000000000000000000000..6c1a60b308cc72227c928de3d00593b8dc4dd67f GIT binary patch literal 9343 zcmeHNd0dR^+kfWqV5XuelD(;{i9&>=5tSv`E2YIRN|8k5D9wx(YwFmdq#Un8QBG3H zXdDNJv^bG0El%1*Q7KbXz2Ezp&Ut_TzyBVe&wOyt^?a}GdtKLk-_IObWoI);Wuyv4 zQG=E)S-gg#X#A6=xC8K4+rF2b6eXaRE?&59pX-e6%}x#6Nn*AFmew@H!bS8`LI$9yOz%WV65CDAT=xqRPPQcI%~?9j+^r zZf3l$D012=4Y*L~-D1IT`2wL>I9IYZM?1)vLzDj-^QZ_hMgBc>D4$Z9U4Dv3gv6Bl z0HyRo4kyvQ#QZ!f!=*g`75+CG|8k?RQueK_3SN*Gn6t5`@k>@^NQ}Bfg{Fn!(}MIl zbd*Z)T}85YXHT+@%d{9B70!U9gJNpcrTmH|Vp%Bd=GtRqp-HRR_D6wP#z=prBtiX~ zoO>+Ao37~zsC5mu12qL-kIFpq-MGevS_~sracQ@vnPEmEU0Lz*X#(na#inL`VO4F7 z5i|Va&;1$k&$*4h3^&yk7`h|Z3#s9m85LGynI}Q8)mPzC`g>o+artGza#c=*j|qq4 ze*46Jbq<|76_7h4#{u%?3O`+;dk2C1bv1OZp4Tvj;r@O$kMCY)&F53r^}m?%1$;NC zxYXz(r0S)iO)JH+O+-boxhj`34=gI@@#nBA(jDO1>%tsU4qadf6~^t81XNqutiTDv z#2ljHSp`&7%&Wc6a7}U*;nc%7r^Hn8+N}3yC`oM$bS??f;8Xh>P6ufUiVIq_X|-+Y zh_AZKE*qM;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@3vG=C~vI{4LPVMd@BL zR!(GQ0@HqQ?srpgE3jIR&|(+R3Q?EguO^|TVM+H;bl}y$(-g>uD!HLu{gSSNYdrS) z)P40I#@e4B;H;GMLWn4;4qi~~!^auw*~7n4Hwfr;-@v_1 zoCT&O7{D~xE{hHwvr_!O`olxg$dyeaD1d%o+@PVr+O~}CkF5#jLzS7;8zOBMbUCCb~WPCPoUZ)ha+e5sVu) zP&5d`T~-~w_X>a76O;|_#Lzi>!Qo8tnf=WAfO|XD?qIlrJOir0cF$CyGF%BFV(NA4 zOA$K4a4sHoGR`E0T)^2$q8qs;fMHmz7W#F355tLV_ltQM!6JZ15h}DLVv+Xq@j>d!+oKnkBKh$J?;3SlDK>Y5V276dsQYc zAhT+chb=Z$$d^Kyo*-(=eNK?%VmE(bsbhTQ(4-FreV< zsedE*I7L7g0hMAuP=OjW zKhK>$bEf$LYH{arp$@h2Zqxkqr3H1R;wPwJ3lr2yF3~djdV38FC2vN`!pOB#K*h8- z)oow9{3`{8Nn5q`>pAug{6D&1T)!OpKe`-JTl_i!-Vu1leivZuYW6@20N5T>HQJcJQM3#OA?^^F{g{ Q5coTyXF$o)wf*^j0Q^8vJ^%m! literal 0 HcmV?d00001 diff --git a/kivyblocks/register.py b/kivyblocks/register.py index 168bb95..f0fe8ac 100644 --- a/kivyblocks/register.py +++ b/kivyblocks/register.py @@ -22,8 +22,10 @@ from .graph import Graph, MeshLinePlot, MeshStemPlot, LinePlot, \ from .mapview import MapView from .chart2d import Chart2d from .message import Conform +from .pagepanel import PagePanel r = Factory.register +r('PagePanel', PagePanel) r('Conform', Conform) r('Chart2d', Chart2d) r('Popup', Popup) diff --git a/kivyblocks/toolbar.py b/kivyblocks/toolbar.py index 8b7f6b8..72dbd6c 100644 --- a/kivyblocks/toolbar.py +++ b/kivyblocks/toolbar.py @@ -7,6 +7,7 @@ from kivy.uix.gridlayout import GridLayout from kivy.uix.label import Label from kivy.app import App from kivy.clock import Clock +from kivy.factory import Factory from appPublic.dictObject import DictObject @@ -107,15 +108,17 @@ class Toolbar(BoxLayout): """ Toolpage options { - img_size=1.5, - text_size=0.7, + img_size:1.5, + text_size:0.7, tool_at:"left","right","top","bottom", - color_level=0, + color_level:0, + show_name: tools:[ { "name":"myid", "img_src":"gggggg", "text":"gggggg" + "flush":true "url":"ggggggggg" }, ... @@ -123,12 +126,21 @@ Toolpage options """ class ToolPage(BGColorBehavior, BoxLayout): - def __init__(self,color_level=-1,radius=[],tool_at='top', **opts): + def __init__(self,color_level=-1,radius=[], + show_name=None, tool_at='top', **opts): self.opts = DictObject(**opts) if tool_at in [ 'top','bottom']: orient = 'vertical' else: orient = 'horizontal' + names = [i.name for i in self.opts.tools] + + if not show_name or \ + not show_name not in names: + show_name = self.opts.tools[0].name + + self.content_widgets = {} + self.show_name = show_name self.color_level=self.opts.color_level or 0 self.sub_radius = self.opts.radius self.tool_at = tool_at @@ -139,8 +151,15 @@ class ToolPage(BGColorBehavior, BoxLayout): self.content = None self.toolbar = None self.init() - # self.show_firstpage() + Clock.schedule_once(self.show_page, 0.5) + def show_page(self, *args): + toggle_items = self.toolbar.toggle_items + for c in toggle_items.children: + cvalue = c.getValue() + if cvalue == self.show_name: + c.dispatch('on_press') + def on_size(self,obj,size): if self.content is None: return @@ -153,13 +172,6 @@ class ToolPage(BGColorBehavior, BoxLayout): self.content.height = self.height self.content.width = self.width - self.toolbar.width - def showPage(self,obj): - self._show_page(obj.opts) - - def show_firstpage(self,t=None): - d = self.children[0] - d.dispatch('on_press', d) - def init(self): self.initFlag = True self.mywidgets = {} @@ -185,4 +197,34 @@ class ToolPage(BGColorBehavior, BoxLayout): else: self.add_widget(self.content) self.add_widget(self.toolbar) + toggle_items = self.toolbar.toggle_items + for t in toggle_items.children: + t.bind(on_press=self.on_press_handle) + + def get_tool_by_name(self,name): + for t in self.opts.tools: + if t.name == name: + return t + return None + + def build_widget(self, url): + desc = { + "widgettype":"urlwidget", + "options":{ + "url":url + } + } + b = Factory.Blocks() + return b.widgetBuild(desc) + + def on_press_handle(self, o): + name = o.getValue() + t = self.get_tool_by_name(name) + w = self.content_widgets.get(name) + if w is None or t.fresh: + w = self.build_widget(t.url) + self.content_widgets[name] = w + if w: + self.content.clear_widgets() + self.content.add_widget(w)