def __init__(self, dialog, parent, key, default, font=None, width=-1, height=-1, hbar=2, vbar=3): self.dialog = dialog self.default = default self.n_selections = 0 self.n_expansions = 0 # disty = 16 if width < 0: width = 400 if height < 0: height = 20 * disty if parent and parent.winfo_screenheight() >= 600: height = 25 * disty if parent and parent.winfo_screenheight() >= 800: height = 30 * disty self.lines = height / disty MfxTreeInCanvas.__init__(self, parent, self.data.rootnodes, width=width, height=height, hbar=hbar, vbar=vbar) self.style.distx = 20 self.style.disty = disty self.style.width = 16 # width of symbol self.style.height = 14 # height of symbol if font: self.style.font = font f = tkFont.Font(parent, font) h = f.metrics()["linespace"] self.style.disty = max(self.style.width, h) self.draw() self.updateSelection(key) if self.hbar: ##print self.data.tree_yview ##print self.canvas.xview() self.canvas.xview_moveto(self.data.tree_xview[0]) if self.vbar: ##print self.data.tree_yview ##print self.canvas.yview() self.canvas.yview_moveto(self.data.tree_yview[0])
def destroy(self): 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)