def addwidget(self, location="sibling", kwargs=None, *args): index, widget = self.tree.wselection()[0] uiname = uidict["uilist"]._list[uidict["uilist"].curselection()[0]] logging.debug("Adding %s %s %s %s %s", widget, kwargs, uiname, eval(uiname), uidict["child params"].text.split(",")) # Need to think of something safer than eval. if location == "child": newelem = UI(eval(uiname), **kwargs) widget.add(newelem, 0) elif widget.parent != self.tree._tree: newelem = UI(eval(uiname), **kwargs) newindex = widget.parent.index(widget) + 1 widget.parent.add(newelem, newindex) else: # Make sure to have a name to retrieve this one! logging.debug("Adding new toplevel") newelem = UI(eval(uiname), **kwargs) fakeroot.append(newelem) newelem.makeelem() newelem.elem.bind("<Button-3>", click) newelem.elem.bind("<B3-Motion>", drag)
UI(Button, text='+', command=addwidget), UI(Button, text='+c', command=addchild), UI(Button, text='-', command=delwidget) ]) ]), UI(tkui.BoxedTree, name="tree"), ]) ]) uiroot.makeelem() setfonts() terp.bind_keys(uidict["tkterp"]) uidict['hint terp'].bind('<Return>', tkguide.next_hint) uidict['hint terp'].bind('<KP_Enter>', tkguide.next_hint) tkuilist = observed_list(["Entry"]) treeelem = uidict["tree"] treeelem._tree.append(uiroot) treeelem._tree.elem = None treeelem.redraw() style = ttk.Style(uidict["root"]) style.configure('Treeview', rowheight=14 * 2) treeelem.column("#0", minwidth=0, width=800) uitree = tkui.UITree(uiroot, treeelem) uidict["tree"].bind('<<TreeviewSelect>>', select_callback)