wxPython, tree Control text cutoff

Kiran Kiran.Karra at gmail.com
Wed Jun 14 17:00:35 EDT 2006


Ah, dang.  Nice find!

thanks a lot for your help.  Also, your note is completely called for.
I realize that my code was very complicated, and I just pasted what I
had instead of simplifying it down.  Next time, I will do so.

thanks again!
Kiran

jean-michel bain-cornu wrote:
> Kiran a écrit :
> >  Hello all,
> > I am using a tree to display stuff, and it is constantly updated, but
> > what I have noticed is in the lowest level, there is clearly noticable
> > cutoff of the text I place there. The cutoff is existent even if I do
> > not update the text inside the tree constantly. It seems that the text
> > is halfway below where it should line up. I tried placing an image to
> > see if that would correct it, but it does not. The image is perfectly
> > lined up, but the text is still misaligned.
> >
> > Any known issues of this and how to fix it? By the way, it happens in
> > both Linux and Windows.
> Hi Kiran,
> It works fine if you change :
> 	x = self.tree.AppendItem(self.connections[i][j][0], "")
> to
> 	x = self.tree.AppendItem(self.connections[i][j][0], " ")
> I let you imagine the explanation...
> Regards,
> jm
>
> Just a hint : it'd be helpfull to solve such a bug if you make your
> program more simple. To find out the solution, I reduced your program to
> what's following, and the light came :
>
> import wx
> import wx.gizmos as gizmos
>
> class AlarmsWindow(wx.MDIChildFrame):
>      def __init__(self, parent, title, size, pos):
>          wx.MDIChildFrame.__init__(self, parent, -1, title, size = size,
> pos =pos)
>          self.tree = gizmos.TreeListCtrl(self, -1, style =
> wx.TR_DEFAULT_STYLE| wx.TR_FULL_ROW_HIGHLIGHT)
>      # create some columns
>          self.tree.AddColumn("Connection")
>          self.tree.AddColumn("Alarm")
>          self.tree.AddColumn("Value")
>          self.tree.SetMainColumn(0)
>
>          self.root = self.tree.AddRoot("Connections")
>          self.tree.Expand(self.root)
>          self.tree.GetMainWindow().Bind(wx.EVT_RIGHT_UP, self.OnRightUp)
>          self.Show()
>
>          child = self.tree.AppendItem(self.root, 'name')
>          self.tree.SetItemText(child, 'name')
>          child2= self.tree.AppendItem(child,'name2')
> ##        x = self.tree.AppendItem(child2, "")
>          x = self.tree.AppendItem(child2, "XXX")
>          self.tree.SetItemText(x, 'alarm', 1)
>          self.tree.SetItemText(x, 'value', 2)
>
>      def OnRightUp(self, evt):
>          pass
>
> class MDIFrame(wx.MDIParentFrame):
>      def __init__(self):
>          wx.MDIParentFrame.__init__(self, None, -1, "MDI Parent", size
> =(600, 400))
>          child = AlarmsWindow(self, "Alarm", (400, 300), (0, 0))
>
>
> if __name__=='__main__':
>      app = wx.PySimpleApp()
>      frame = MDIFrame()
>      frame.Show()
>      app.MainLoop()




More information about the Python-list mailing list