From 76cdce99e35dc35118e46b30583fe4f4dc2236ef Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 22 Sep 2022 13:06:46 +0800 Subject: [PATCH] bugfix --- kivyblocks/hierarchy.py | 32 ++++++++++++++++++++++---------- kivyblocks/register.py | 1 - kivyblocks/toolbar.py | 6 ++++++ kivyblocks/version.py | 2 +- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/kivyblocks/hierarchy.py b/kivyblocks/hierarchy.py index 338964a..4c82a24 100644 --- a/kivyblocks/hierarchy.py +++ b/kivyblocks/hierarchy.py @@ -13,31 +13,33 @@ from .scrollpanel import ScrollPanel from .clickable import SingleCheckBox from .baseWidget import Text from .utils import CSize +from .command_action import cmd_action from appPublic.registerfunction import getRegisterFunctionByName -class TreeViewComplexNode(BoxLayout, TreeViewLabel): +class TreeViewComplexNode(BoxLayout, TreeViewNode): otext = StringProperty(None) + font_size_c = NumericProperty(1) + node_height = NumericProperty(2) checkbox = BooleanProperty(False) icon = StringProperty(None) data = DictProperty(None) def __init__(self, **kw): super(TreeViewComplexNode, self).__init__(**kw) self.orientation = 'horizontal' - self.size_hint_x = None if self.checkbox: cb = SingleCheckBox(size_hint=(None,None)) cb.bind(on_press=self.set_checked) self.add_widget(cb) if self.icon: img = AsyncImage(source=self.icon, size_hint=(None,None)) - img.size = CSize(1,1) + img.size = CSize(self.font_size_c,self.font_size_c) self.add_widget(img) - txt = Text(otext=self.otext, i18n=True) - txt.texture_update() - txt.size_hint = (None, None) - txt.size = txt.texture_size + txt = Text(otext=self.otext, i18n=True, + font_size=CSize(self.font_size_c),halign='left') self.add_widget(txt) + self.size_hint_y = None + self.height = CSize(self.node_height) def set_checked(self, o): if not self.data: @@ -52,6 +54,8 @@ class Hierarchy(ScrollPanel): params = DictProperty(None) method = StringProperty('get') idField = StringProperty(None) + node_height = NumericProperty(2) + font_size_c = NumericProperty(1) textField = StringProperty(None) data = ListProperty(None) checkbox = BooleanProperty(False) @@ -95,6 +99,8 @@ class Hierarchy(ScrollPanel): def create_new_node(self, data, node=None): n = TreeViewComplexNode(otext=data[self.textField], checkbox=self.checkbox, + node_height=self.node_height, + font_size_c=self.font_size_c, icon=data.get('icon') or self.icon ) n.data = data @@ -148,9 +154,15 @@ class Menu(Hierarchy): def on_press(self, node): self.tree.deselect_node() data = {} + data = node.data.copy() + if self.target and data.get('target') is None: + data['target'] = self.target + return cmd_action(data, self) + ###### change to use cmd_action ######## + id2widget = Factory.Blocks.getWidgetById dw = node.data.get('datawidget') if dw: - data_widget = Factory.Blocks.getWidgetById(dw) + data_widget = id2widget(dw) if data_widget: vn = node.data.get('datamethod', 'getValue') if hasattr(data_widget, vn): @@ -160,7 +172,7 @@ class Menu(Hierarchy): data = {} url = node.data.get('url') - target = Factory.Blocks.getWidgetById(node.data.get('target',self.target),self) + target = id2widget(node.data.get('target',self.target),self) if url: params = node.data.get('params',{}) params.update(data) @@ -187,7 +199,7 @@ class Menu(Hierarchy): script = node.data.get('script') if script: target_name = node.data.get('target', self.target) - target = Factory.Blocks.getWidgetById(target_name, self) + target = id2widget(target_name, self) data.update({'self':target}) if target: eval(script,data) diff --git a/kivyblocks/register.py b/kivyblocks/register.py index a69dded..0219800 100644 --- a/kivyblocks/register.py +++ b/kivyblocks/register.py @@ -145,4 +145,3 @@ def register_blocks(name, value): except: Logger.info(f'plugin : register_blocks():{name} register error') - diff --git a/kivyblocks/toolbar.py b/kivyblocks/toolbar.py index ec3d940..1e248d5 100644 --- a/kivyblocks/toolbar.py +++ b/kivyblocks/toolbar.py @@ -67,16 +67,22 @@ class Toolbar(ScrollPanel): self.register_event_type('on_delete_tool') if self.toolbar_orient == 'H': self._inner.orientation = 'horizontal' + self.size_hint_x = 1 else: self._inner.orientation = 'vertical' + self.size_hint_y = 1 self.clear_widgets() for t in self.tools: self.add_tool(t) self.bar_width = 0 if self.toolbar_orient == 'H': + self.size_hint_y = None + self.height = self._inner.height * 1.6 self.do_scroll_y = False else: + self.size_hint_x = None + self.width = self._inner.width * 1.6 self.do_scroll_x = False def on_children_size(self, o, size): diff --git a/kivyblocks/version.py b/kivyblocks/version.py index 35e8cf2..ca81af4 100644 --- a/kivyblocks/version.py +++ b/kivyblocks/version.py @@ -1 +1 @@ -__version__ = '0.3.20' +__version__ = '0.3.21'