The preferred size of the wx.TreeCtrl seems to be the minimum size into which all elements will fit when the tree is completely collapsed. Is there a good (ie cross-platform compatible) way to compute the width of the tree with everything expanded? My current solution is this:
def max_width(self):
dc = wx.ScreenDC()
dc.SetFont(self.GetFont())
widths = []
for item, depth in self.__walk_items():
if item != self.root:
width = dc.GetTextExtent(self.GetItemText(item))[0] + self.GetIndent()*depth
widths.append(width)
return max(widths) + self.GetIndent()
This works great in win32, but no good under linux. Is there some way to get the TreeCtrl itself to tell me its size so that I can override the size it reports? (ALways returning the maximally expanded width)
edit: pardon me for not providing the functions I use above, but you get the idea, I'm walking the tree, and getting the width of every label, and returning the total width of the widest one (accounting for indent)