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. thanks a lot for your help! here is the code that I am using, I realize that it is a bit convoluted, but the parts where I am setting the text should be evident. 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) # images of the tree isz = (16,16) il = wx.ImageList(isz[0], isz[1]) self.fldridx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, isz)) self.fldropenidx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, isz)) self.fileidx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, isz)) self.selidx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_CROSS_MARK, wx.ART_OTHER, isz)) self.tree.SetImageList(il) self.il = il # 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.SetItemImage(self.root, self.fldridx, which = wx.TreeItemIcon_Normal) self.tree.SetItemImage(self.root, self.fldropenidx, which = wx.TreeItemIcon_Expanded) self.connectionsName = [] self.connections = [] self.registers = [] self.tree.Expand(self.root) self.tree.GetMainWindow().Bind(wx.EVT_RIGHT_UP, self.OnRightUp) self.Show() # testing self.AddConnection("Dummy") self.AddRegister("Dummy", "R5") self.AddAlarm("Dummy", "R5", "LOA", "10") self.UpdateAlarm("Dummy", "R5", "LOA", "14") self.AddAlarm("Dummy", "R5", "LOS", "1354") self.AddRegister("Dummy", "R6") self.AddAlarm("Dummy", "R6", "LOA", "15") self.AddConnection("DUMMY @#2") self.AddRegister("DUMMY @#2", "R0") self.AddAlarm("DUMMY @#2", "R0", "LSKJDF", "S:LKJDF") # tree control def OnRightUp(self, evt): pos = evt.GetPosition() item, flags, col = self.tree.HitTest(pos) if item: print('Flags: %s, Col:%s, Text: %s' % (flags, col, self.tree.GetItemText(item, col))) # tree control def OnSize(self, evt): self.tree.SetSize(self.GetSize()) # adds a section to the logger def AddConnection(self, name): self.connectionsName.append(name) self.connections.append([]) child = self.tree.AppendItem(self.root, name) self.connections[(len(self.connectionsName)-1)].append(child) self.tree.SetItemText(child, name) self.tree.SetItemImage(child, self.fldridx, which = wx.TreeItemIcon_Normal) self.tree.SetItemImage(child, self.fldropenidx, which = wx.TreeItemIcon_Expanded) # adds a register def AddRegister(self, connection, name): # find the connection index = -1 for i in range(len(self.connectionsName)): if self.connectionsName[i] == connection: index = i break if index != -1: self.connections[index].append([self.tree.AppendItem(self.connections[index][0], name)]) # adds a message to a specific section def AddAlarm(self, connection, register, alarm, value): # find the connection for i in range(len(self.connectionsName)): if self.connectionsName[i] == connection: # find the register for j in range(1, len(self.connections[i])): if self.tree.GetItemText((self.connections[i][j])[0]) == register: x = self.tree.AppendItem(self.connections[i][j][0], "") self.connections[i][j].append([x, alarm]) self.tree.SetItemImage(x, self.fileidx, wx.TreeItemIcon_Normal) self.tree.SetItemText(x, alarm, 1) self.tree.SetItemText(x, value, 2) # updates the alarm's window def UpdateAlarm(self, connection, register, alarm, value): # find the connection for i in range(len(self.connectionsName)): if self.connectionsName[i] == connection: # find the register for j in range(1, len(self.connections[i])): if self.tree.GetItemText(self.connections[i][j][0]) == register: # find the alarm for k in range(1, len(self.connections[i][j])): if self.connections[i][j][k][1] == alarm: self.tree.SetItemImage(self.connections[i][j][k][0], self.fileidx, wx.TreeItemIcon_Normal) self.tree.SetItemText(self.connections[i][j][k][0], value, 2) return 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() -- http://mail.python.org/mailman/listinfo/python-list