diff --git a/pysollib/tile/selecttree.py b/pysollib/tile/selecttree.py index b9ab869e..d5116f2f 100644 --- a/pysollib/tile/selecttree.py +++ b/pysollib/tile/selecttree.py @@ -23,9 +23,6 @@ __all__ = ['SelectDialogTreeData'] -# imports -import tkFont - # Toolkit imports from tktree import MfxTreeLeaf, MfxTreeNode, MfxTreeInCanvas @@ -35,15 +32,23 @@ from pysollib.ui.tktile.selecttree import BaseSelectDialogTreeLeaf, BaseSelectDi # * Nodes # ************************************************************************ -class SelectDialogTreeLeaf(MfxTreeLeaf, BaseSelectDialogTreeLeaf): +class SelectDiagCommon: + def _calc_MfxTreeNode(self): + return MfxTreeNode + def _calc_MfxTreeInCanvas(self): + return MfxTreeInCanvas + def _calc_MfxTreeLeaf(self): + return MfxTreeLeaf + +class SelectDialogTreeLeaf(SelectDiagCommon, BaseSelectDialogTreeLeaf, MfxTreeLeaf): pass -class SelectDialogTreeNode(MfxTreeNode, BaseSelectDialogTreeNode): +class SelectDialogTreeNode(SelectDiagCommon, BaseSelectDialogTreeNode, MfxTreeNode): pass # ************************************************************************ # * Canvas that shows the tree (left side) # ************************************************************************ -class SelectDialogTreeCanvas(MfxTreeInCanvas, BaseSelectDialogTreeCanvas): +class SelectDialogTreeCanvas(SelectDiagCommon, BaseSelectDialogTreeCanvas, MfxTreeInCanvas): pass diff --git a/pysollib/ui/tktile/selecttree.py b/pysollib/ui/tktile/selecttree.py index 80483699..a7da6eb4 100644 --- a/pysollib/ui/tktile/selecttree.py +++ b/pysollib/ui/tktile/selecttree.py @@ -25,6 +25,9 @@ # * Nodes # ************************************************************************ +# imports +import tkFont + class BaseSelectDialogTreeLeaf: def drawSymbol(self, x, y, **kw): if self.tree.nodes.get(self.symbol_id) is not self: @@ -35,7 +38,7 @@ class BaseSelectDialogTreeLeaf: class BaseSelectDialogTreeNode: def __init__(self, tree, text, select_func, expanded=0, parent_node=None): - MfxTreeNode.__init__(self, tree, parent_node, text, key=None, expanded=expanded) + self._calc_MfxTreeNode().__init__(self, tree, parent_node, text, key=None, expanded=expanded) # callable or a tuple/list of MfxTreeNodes self.select_func = select_func @@ -92,7 +95,7 @@ class BaseSelectDialogTreeCanvas: if parent and parent.winfo_screenheight() >= 800: height = 30 * disty self.lines = height / disty - MfxTreeInCanvas.__init__(self, parent, self.data.rootnodes, + self._calc_MfxTreeInCanvas().__init__(self, parent, self.data.rootnodes, width=width, height=height, hbar=hbar, vbar=vbar) self.style.distx = 20 @@ -120,14 +123,14 @@ class BaseSelectDialogTreeCanvas: if self.n_expansions > 0: # must save updated xyview self.data.tree_xview = self.canvas.xview() self.data.tree_yview = self.canvas.yview() - MfxTreeInCanvas.destroy(self) + self._calc_MfxTreeInCanvas().destroy(self) def getContents(self, node): return node.getContents() def singleClick(self, event=None): node = self.findNode() - if isinstance(node, MfxTreeLeaf): + if isinstance(node, self._calc_MfxTreeLeaf()): if not node.selected and node.key is not None: oldcur = self.canvas["cursor"] self.canvas["cursor"] = "watch" @@ -136,7 +139,7 @@ class BaseSelectDialogTreeCanvas: self.updateSelection(node.key) self.dialog.updatePreview(self.selection_key) self.canvas["cursor"] = oldcur - elif isinstance(node, MfxTreeNode): + elif isinstance(node, self._calc_MfxTreeNode()): self.n_expansions = self.n_expansions + 1 node.expanded = not node.expanded self.redraw() @@ -144,12 +147,12 @@ class BaseSelectDialogTreeCanvas: def doubleClick(self, event=None): node = self.findNode() - if isinstance(node, MfxTreeLeaf): + if isinstance(node, self._calc_MfxTreeLeaf()): if node.key is not None: self.n_selections = self.n_selections + 1 self.updateSelection(node.key) self.dialog.mDone(self.default) - elif isinstance(node, MfxTreeNode): + elif isinstance(node, self._calc_MfxTreeNode()): self.n_expansions = self.n_expansions + 1 node.expanded = not node.expanded self.redraw()