Gizmos TreeListCtrl Bug

Hi,

I am pretty well stuck here, and hoping someone can help me out.

I am having an issue with the TreeList Ctrl leaving items at the
bottom of my list. It mostly happens when collapsing, but it can also
happen when:

1) I delete the last item while being scrolled all the way to the
bottom. In this case when you select the last item after the delete,
the text will change.
2) Removing the root item, replacing it with a new list, and then
expanding items.

In the expand and collapse events I have tried Refresh() and Update(),
as well as running Refresh and Update in a CallAfter().

I am running Linux version 2.6.9-89.ELsmp (Red Hat 3.4.6-11)

This post seems related, and has some code and directions:
Possible bug in wx.gizmos.TreeListCtrl
http://groups.google.com/group/wxpython-users/browse_thread/thread/b7

Please make a small runnable sample that demonstrates the problem. MakingSampleApps - wxPyWiki

···

On 3/15/10 9:31 AM, yl wrote:

Hi,

I am pretty well stuck here, and hoping someone can help me out.

I am having an issue with the TreeList Ctrl leaving items at the
bottom of my list. It mostly happens when collapsing, but it can also
happen when:

1) I delete the last item while being scrolled all the way to the
bottom. In this case when you select the last item after the delete,
the text will change.
2) Removing the root item, replacing it with a new list, and then
expanding items.

In the expand and collapse events I have tried Refresh() and Update(),
as well as running Refresh and Update in a CallAfter().

I am running Linux version 2.6.9-89.ELsmp (Red Hat 3.4.6-11)

This post seems related, and has some code and directions:
Possible bug in wx.gizmos.TreeListCtrl
http://groups.google.com/group/wxpython-users/browse_thread/thread/b7

--
Robin Dunn
Software Craftsman

Here is the sample code you asked for. Please follow the below steps
to display the 2 bugs.

Bug 1:
1) run code to open gui
2) Use scroll bar to scroll to bottom of the gui
3) Collapse "folder2". You should notice the TreeListCtrl now has bad
entries at the bottom.

Bug 2:
1) run code to open gui
2) Use scroll bar to scroll to bottom of the gui
3) Double click "file2" under "folder2" to delete that item. You
should notice the TreeListCtrl now has bad entries at the bottom.

Please pardon me putting the code right in here. I could not find the
"attachment" widget.

The version of wx I am running is: 2.8.9.1 (gtk2-unicode)

···

######################################
#!/usr/local/bin/python

import wx
import wx.gizmos as gizmos

print wx.version()

class Window(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self,None,wx.ID_ANY)
        self.SetSize(wx.Size(200,200))
        FileTree(self)
        self.Show(True)

class FileTree(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)
        self.Bind(wx.EVT_SIZE, self.OnSize)

        #Create Gizmo
        self.tree = gizmos.TreeListCtrl(self, -1,
                    style =
                    wx.TR_FULL_ROW_HIGHLIGHT
                    >wx.TR_MULTIPLE
                    >wx.TR_TWIST_BUTTONS
                    )
        self.Bind(wx.EVT_TREE_ITEM_COLLAPSED,
            self.EvtItemCollapsed, self.tree)
        self.tree.GetMainWindow().Bind(
            wx.EVT_LEFT_DCLICK, self.EvtLeftDClick)

        #Add Root
        self.tree.AddColumn("File")
        self.root = self.tree.AddRoot('ROOT')
        self.tree.SetItemHasChildren(self.root, True)

        #Add Children
        for i in range(3):
            item = self.tree.AppendItem(self.root, 'folder%s'%i)
            self.tree.SetItemHasChildren(item, True)
            for j in range(3):
                file = self.tree.AppendItem(item, 'file%s'%j)

        self.tree.ExpandAll(self.root)

    def OnSize(self, evt):
        self.tree.SetSize(self.GetSize())

    def EvtItemCollapsed(self, event):
        self.Refresh()
        self.Update()
        wx.CallAfter(self.MyRefresh)

    def EvtLeftDClick(self, event):
        item = self.tree.GetSelections()[0]
        self.tree.Delete(item)

    def MyRefresh(self):
        self.Refresh()
        self.Update()

app = wx.PySimpleApp()
Window()
app.MainLoop()
######################################

On Mar 15, 12:15 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 3/15/10 9:31 AM, yl wrote:

> Hi,

> I am pretty well stuck here, and hoping someone can help me out.

> I am having an issue with the TreeList Ctrl leaving items at the
> bottom of my list. It mostly happens when collapsing, but it can also
> happen when:

> 1) I delete the last item while being scrolled all the way to the
> bottom. In this case when you select the last item after the delete,
> the text will change.
> 2) Removing the root item, replacing it with a new list, and then
> expanding items.

> In the expand and collapse events I have tried Refresh() and Update(),
> as well as running Refresh and Update in a CallAfter().

> I am running Linux version 2.6.9-89.ELsmp (Red Hat 3.4.6-11)

> This post seems related, and has some code and directions:
> Possiblebugin wx.gizmos.TreeListCtrl
>http://groups.google.com/group/wxpython-users/browse_thread/thread/b7

Please make a small runnable sample that demonstrates the problem.MakingSampleApps - wxPyWiki

--
Robin Dunn
Software Craftsmanhttp://wxPython.org