bugfix
This commit is contained in:
parent
19fe20ac35
commit
76cdce99e3
@ -13,31 +13,33 @@ from .scrollpanel import ScrollPanel
|
|||||||
from .clickable import SingleCheckBox
|
from .clickable import SingleCheckBox
|
||||||
from .baseWidget import Text
|
from .baseWidget import Text
|
||||||
from .utils import CSize
|
from .utils import CSize
|
||||||
|
from .command_action import cmd_action
|
||||||
|
|
||||||
from appPublic.registerfunction import getRegisterFunctionByName
|
from appPublic.registerfunction import getRegisterFunctionByName
|
||||||
|
|
||||||
class TreeViewComplexNode(BoxLayout, TreeViewLabel):
|
class TreeViewComplexNode(BoxLayout, TreeViewNode):
|
||||||
otext = StringProperty(None)
|
otext = StringProperty(None)
|
||||||
|
font_size_c = NumericProperty(1)
|
||||||
|
node_height = NumericProperty(2)
|
||||||
checkbox = BooleanProperty(False)
|
checkbox = BooleanProperty(False)
|
||||||
icon = StringProperty(None)
|
icon = StringProperty(None)
|
||||||
data = DictProperty(None)
|
data = DictProperty(None)
|
||||||
def __init__(self, **kw):
|
def __init__(self, **kw):
|
||||||
super(TreeViewComplexNode, self).__init__(**kw)
|
super(TreeViewComplexNode, self).__init__(**kw)
|
||||||
self.orientation = 'horizontal'
|
self.orientation = 'horizontal'
|
||||||
self.size_hint_x = None
|
|
||||||
if self.checkbox:
|
if self.checkbox:
|
||||||
cb = SingleCheckBox(size_hint=(None,None))
|
cb = SingleCheckBox(size_hint=(None,None))
|
||||||
cb.bind(on_press=self.set_checked)
|
cb.bind(on_press=self.set_checked)
|
||||||
self.add_widget(cb)
|
self.add_widget(cb)
|
||||||
if self.icon:
|
if self.icon:
|
||||||
img = AsyncImage(source=self.icon, size_hint=(None,None))
|
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)
|
self.add_widget(img)
|
||||||
txt = Text(otext=self.otext, i18n=True)
|
txt = Text(otext=self.otext, i18n=True,
|
||||||
txt.texture_update()
|
font_size=CSize(self.font_size_c),halign='left')
|
||||||
txt.size_hint = (None, None)
|
|
||||||
txt.size = txt.texture_size
|
|
||||||
self.add_widget(txt)
|
self.add_widget(txt)
|
||||||
|
self.size_hint_y = None
|
||||||
|
self.height = CSize(self.node_height)
|
||||||
|
|
||||||
def set_checked(self, o):
|
def set_checked(self, o):
|
||||||
if not self.data:
|
if not self.data:
|
||||||
@ -52,6 +54,8 @@ class Hierarchy(ScrollPanel):
|
|||||||
params = DictProperty(None)
|
params = DictProperty(None)
|
||||||
method = StringProperty('get')
|
method = StringProperty('get')
|
||||||
idField = StringProperty(None)
|
idField = StringProperty(None)
|
||||||
|
node_height = NumericProperty(2)
|
||||||
|
font_size_c = NumericProperty(1)
|
||||||
textField = StringProperty(None)
|
textField = StringProperty(None)
|
||||||
data = ListProperty(None)
|
data = ListProperty(None)
|
||||||
checkbox = BooleanProperty(False)
|
checkbox = BooleanProperty(False)
|
||||||
@ -95,6 +99,8 @@ class Hierarchy(ScrollPanel):
|
|||||||
def create_new_node(self, data, node=None):
|
def create_new_node(self, data, node=None):
|
||||||
n = TreeViewComplexNode(otext=data[self.textField],
|
n = TreeViewComplexNode(otext=data[self.textField],
|
||||||
checkbox=self.checkbox,
|
checkbox=self.checkbox,
|
||||||
|
node_height=self.node_height,
|
||||||
|
font_size_c=self.font_size_c,
|
||||||
icon=data.get('icon') or self.icon
|
icon=data.get('icon') or self.icon
|
||||||
)
|
)
|
||||||
n.data = data
|
n.data = data
|
||||||
@ -148,9 +154,15 @@ class Menu(Hierarchy):
|
|||||||
def on_press(self, node):
|
def on_press(self, node):
|
||||||
self.tree.deselect_node()
|
self.tree.deselect_node()
|
||||||
data = {}
|
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')
|
dw = node.data.get('datawidget')
|
||||||
if dw:
|
if dw:
|
||||||
data_widget = Factory.Blocks.getWidgetById(dw)
|
data_widget = id2widget(dw)
|
||||||
if data_widget:
|
if data_widget:
|
||||||
vn = node.data.get('datamethod', 'getValue')
|
vn = node.data.get('datamethod', 'getValue')
|
||||||
if hasattr(data_widget, vn):
|
if hasattr(data_widget, vn):
|
||||||
@ -160,7 +172,7 @@ class Menu(Hierarchy):
|
|||||||
data = {}
|
data = {}
|
||||||
|
|
||||||
url = node.data.get('url')
|
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:
|
if url:
|
||||||
params = node.data.get('params',{})
|
params = node.data.get('params',{})
|
||||||
params.update(data)
|
params.update(data)
|
||||||
@ -187,7 +199,7 @@ class Menu(Hierarchy):
|
|||||||
script = node.data.get('script')
|
script = node.data.get('script')
|
||||||
if script:
|
if script:
|
||||||
target_name = node.data.get('target', self.target)
|
target_name = node.data.get('target', self.target)
|
||||||
target = Factory.Blocks.getWidgetById(target_name, self)
|
target = id2widget(target_name, self)
|
||||||
data.update({'self':target})
|
data.update({'self':target})
|
||||||
if target:
|
if target:
|
||||||
eval(script,data)
|
eval(script,data)
|
||||||
|
@ -145,4 +145,3 @@ def register_blocks(name, value):
|
|||||||
except:
|
except:
|
||||||
Logger.info(f'plugin : register_blocks():{name} register error')
|
Logger.info(f'plugin : register_blocks():{name} register error')
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,16 +67,22 @@ class Toolbar(ScrollPanel):
|
|||||||
self.register_event_type('on_delete_tool')
|
self.register_event_type('on_delete_tool')
|
||||||
if self.toolbar_orient == 'H':
|
if self.toolbar_orient == 'H':
|
||||||
self._inner.orientation = 'horizontal'
|
self._inner.orientation = 'horizontal'
|
||||||
|
self.size_hint_x = 1
|
||||||
else:
|
else:
|
||||||
self._inner.orientation = 'vertical'
|
self._inner.orientation = 'vertical'
|
||||||
|
self.size_hint_y = 1
|
||||||
self.clear_widgets()
|
self.clear_widgets()
|
||||||
for t in self.tools:
|
for t in self.tools:
|
||||||
self.add_tool(t)
|
self.add_tool(t)
|
||||||
|
|
||||||
self.bar_width = 0
|
self.bar_width = 0
|
||||||
if self.toolbar_orient == 'H':
|
if self.toolbar_orient == 'H':
|
||||||
|
self.size_hint_y = None
|
||||||
|
self.height = self._inner.height * 1.6
|
||||||
self.do_scroll_y = False
|
self.do_scroll_y = False
|
||||||
else:
|
else:
|
||||||
|
self.size_hint_x = None
|
||||||
|
self.width = self._inner.width * 1.6
|
||||||
self.do_scroll_x = False
|
self.do_scroll_x = False
|
||||||
|
|
||||||
def on_children_size(self, o, size):
|
def on_children_size(self, o, size):
|
||||||
|
@ -1 +1 @@
|
|||||||
__version__ = '0.3.20'
|
__version__ = '0.3.21'
|
||||||
|
Loading…
Reference in New Issue
Block a user