Sizers and their removal.

I want to deattach a sizer from another sizer which I have previously
added it to:

sizer.AddSizer(childsizer)
sizer.RemoveSizer(childsizer)

But now has the childsizer been deleted and can't be used anymore? How do
I deattach the childsizer from the sizer without it being deleted?

/Ragnar

Ragnar Ouchterlony wrote:

I want to deattach a sizer from another sizer which I have previously
added it to:

sizer.AddSizer(childsizer)
sizer.RemoveSizer(childsizer)

But now has the childsizer been deleted and can't be used anymore? How do
I deattach the childsizer from the sizer without it being deleted?

Not in 2.4. 2.5 will have a Detach method that will do what you expect.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi all,

I have a wxTreeCtrl, and I am using EVT_TREE_BEGIN_LABEL_EDIT and
EVT_TREE_END_LABEL_EDIT.

Under MSW it works fine. Under GTK2, there are two errors.

1. The END_LABEL_EDIT event is triggered twice. I know that some events are
generated twice due to platform-specific issues, but I thought I would
report it in case it is a bug. I can figure out a workaround, but it is a
bit of a nuisance, as I perform an update on completion, and I do not want
to update twice.

2. After the edit is completed, the tree control no longer responds to the
up/down arrow keys. You have to use the mouse to reactivate it. I tried to
'select' the item in the end label edit routine, even using wxCallAfter, but
it made no difference.

I attach a program to show the effect. It is more than just a tree - it
incorporates a grid and a text area as well. It took me a while to get it
working and I am fairly pleased with the way it came out, so I thought I
would post the whole program in case anyone finds it of interest.

Frank Millman

splitter4.py (3.11 KB)

Hi all,

I have a wxTreeCtrl, and I am using EVT_TREE_BEGIN_LABEL_EDIT and
EVT_TREE_END_LABEL_EDIT.

Under MSW it works fine. Under GTK2, there are two errors.

1. The END_LABEL_EDIT event is triggered twice. I know that some events

are

generated twice due to platform-specific issues, but I thought I would
report it in case it is a bug. I can figure out a workaround, but it is a
bit of a nuisance, as I perform an update on completion, and I do not want
to update twice.

2. After the edit is completed, the tree control no longer responds to the
up/down arrow keys. You have to use the mouse to reactivate it. I tried to
'select' the item in the end label edit routine, even using wxCallAfter,

but

it made no difference.

I attach a program to show the effect. It is more than just a tree - it
incorporates a grid and a text area as well. It took me a while to get it
working and I am fairly pleased with the way it came out, so I thought I
would post the whole program in case anyone finds it of interest.

Frank Millman

Since sending this message, I have found two more errors with editing a
label using GTK2.

1. While in edit mode, you can press the up/down arrow and control is passed
to the next/previous item without generating an END_LABEL_EDIT event. MSW
ignores the up/down arrow while in edit mode, which seems the correct
behaviour.

2. If you create a new item using InsertItemBefore, and then edit the new
item, the edit box is very small, so that you can hardly see what you are
typing.

Frank

Frank Millman wrote:

Hi all,

I have a wxTreeCtrl, and I am using EVT_TREE_BEGIN_LABEL_EDIT and
EVT_TREE_END_LABEL_EDIT.

Under MSW it works fine. Under GTK2, there are two errors.

1. The END_LABEL_EDIT event is triggered twice. I know that some events are
generated twice due to platform-specific issues, but I thought I would
report it in case it is a bug. I can figure out a workaround, but it is a
bit of a nuisance, as I perform an update on completion, and I do not want
to update twice.

It does it with GTK1 too. Please enter a wxWindows bug report about this with a category of "Generic".

2. After the edit is completed, the tree control no longer responds to the
up/down arrow keys. You have to use the mouse to reactivate it. I tried to
'select' the item in the end label edit routine, even using wxCallAfter, but
it made no difference.

Instead of Select you should be using SetFocus to get the focus back to the tree control, but using wxCallAfter to do it doesn't seem to be working either. Probably because of the second end edit event. However if I set a timer from the end edit handler to call SetFocus then it does:

         wxFutureCall(100, self.tree.SetFocus)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Frank Millman wrote:

Since sending this message, I have found two more errors with editing a
label using GTK2.

1. While in edit mode, you can press the up/down arrow and control is passed
to the next/previous item without generating an END_LABEL_EDIT event. MSW
ignores the up/down arrow while in edit mode, which seems the correct
behaviour.

2. If you create a new item using InsertItemBefore, and then edit the new
item, the edit box is very small, so that you can hardly see what you are
typing.

Please enter a wxWindows bug report for each of these too.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Frank Millman wrote:
> Hi all,
>
> I have a wxTreeCtrl, and I am using EVT_TREE_BEGIN_LABEL_EDIT and
> EVT_TREE_END_LABEL_EDIT.
>
> Under MSW it works fine. Under GTK2, there are two errors.
>
> 1. The END_LABEL_EDIT event is triggered twice. I know that some events

are

> generated twice due to platform-specific issues, but I thought I would
> report it in case it is a bug. I can figure out a workaround, but it is

a

> bit of a nuisance, as I perform an update on completion, and I do not

want

> to update twice.

Robin Dunn wrote:

It does it with GTK1 too. Please enter a wxWindows bug report about
this with a category of "Generic".

Done.

>
> 2. After the edit is completed, the tree control no longer responds to

the

> up/down arrow keys. You have to use the mouse to reactivate it. I tried

to

> 'select' the item in the end label edit routine, even using wxCallAfter,

but

> it made no difference.

Instead of Select you should be using SetFocus to get the focus back to
the tree control, but using wxCallAfter to do it doesn't seem to be
working either. Probably because of the second end edit event. However
if I set a timer from the end edit handler to call SetFocus then it does:

         wxFutureCall(100, self.tree.SetFocus)

Works perfectly - thanks very much.

Frank

Frank Millman wrote:
>
> Since sending this message, I have found two more errors with editing a
> label using GTK2.
>
> 1. While in edit mode, you can press the up/down arrow and control is

passed

> to the next/previous item without generating an END_LABEL_EDIT event.

MSW

> ignores the up/down arrow while in edit mode, which seems the correct
> behaviour.
>
> 2. If you create a new item using InsertItemBefore, and then edit the

new

> item, the edit box is very small, so that you can hardly see what you

are

> typing.
>

Robin Dunn wrote:

Please enter a wxWindows bug report for each of these too.

I have entered a bug report for 1. I find that 2 is intermittent, so I will
try to nail it down to a reproducible problem before I submit it.

Frank

Folks,

I have a wxPython app that uses a wxTreeCtrl. A couple of my functions are
required to traverse the tree and visit every node. I developed it using
Win2k, Python 2.2, wxPython 2.4.0.x and it worked great. I later upgraded
to Python 2.3/wxPython 2.4.2.4 and it still worked great. I tried to use it
under Red Hat 8/Python 2.2/wxPython 2.4.2.4 and it fails. It's not
generating an error, but it's not visiting all the tree nodes.

As an example, I'm using the wxPython wxTreeCtrl demo (but I've reduced the
number of children of the root from 15 to 5). In the constructor, I added a
call to a method I added, self.printTree(self.tree.GetRootItem(), 0). That
method is implemented as follows:

    def printTree(self, treeNode, cookie):
      '''Recursively traverses a tree and prints the node labels.'''
      print "printTree(" + self.tree.GetItemText(treeNode) + ", " +
str(cookie) + ")"
      if treeNode:
        print "Visiting treeNode", self.tree.GetItemText(treeNode)
        print "Checking for child of", self.tree.GetItemText(treeNode)
        child, cookie = self.tree.GetFirstChild(treeNode, cookie)
        if not child:
          print "No child found"
        while child:
          print "Found child:", self.tree.GetItemText(child)
          self.printTree(child, cookie)
          print "Checking for additional child of",
self.tree.GetItemText(treeNode)
          child, cookie = self.tree.GetNextChild(child, cookie)
          if not child:
            print "No additional child found"

I intentionally made it verbose to see exactly what was going on. When I
run this under Win2K, it shows that it properly visits all the tree nodes:

Root
0
0-a
0-a-0
0-a-1
0-a-2
0-a-3
0-a-4
0-b
0-b-0
  .
  .
  .
4-e-4 (remember I shortened the tree to only 5 children of the root, 0 thru
4, so this is the end)

However, when I run this same code on my Linux configuration, it only visits
the following nodes:

Root
0
0-a
0-a-0
0-a-1
0-b
0-b-0
0-b-2

then it stops (without signalling any kind of error).

Does anyone have any idea what is causing this? The actual code used to run
this test is attached. It runs from within the demo (just stick the file
into the wxPython/demo dir and add the module name to
wxPython/demo/Main.py).

Thanks.

Paul

MyWxTreeCtrl.py (8.17 KB)

Paul Gardella wrote:

Folks,

I have a wxPython app that uses a wxTreeCtrl. A couple of my functions are
required to traverse the tree and visit every node. I developed it using
Win2k, Python 2.2, wxPython 2.4.0.x and it worked great. I later upgraded
to Python 2.3/wxPython 2.4.2.4 and it still worked great. I tried to use it
under Red Hat 8/Python 2.2/wxPython 2.4.2.4 and it fails. It's not
generating an error, but it's not visiting all the tree nodes.

Don't pass the cookie down recursivly, it is only needed for each parent node.

     def printTree(self, treeNode):
         '''Recursively traverses a tree and prints the node labels.'''
         print 'printTree:', self.tree.GetItemText(treeNode)
         if self.tree.GetChildrenCount(treeNode, False):
             cookie = -1
             child, cookie = self.tree.GetFirstChild(treeNode, cookie)
             while child:
                 self.printTree(child)
                 child, cookie = self.tree.GetNextChild(treeNode, cookie)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Thanks for the reply; I tried your suggested code, but it gives me the same
results as before on Linux; namely, it only visits the following nodes:

The Root Item
Item 0
item 0-a
item 0-a-0
item 0-a-1
item 0-b
item 0-b-0
item 0-b-2

...then it stops without signalling an error of any kind. Works great under
Win2K, though. Any ideas? Thanks.

Paul Gardella

···

-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Friday, October 17, 2003 1:34 PM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] wxTreeCtrl tree node traversal works under
MSW, fails under Linux

Paul Gardella wrote:

Folks,

I have a wxPython app that uses a wxTreeCtrl. A couple of my functions

are

required to traverse the tree and visit every node. I developed it using
Win2k, Python 2.2, wxPython 2.4.0.x and it worked great. I later upgraded
to Python 2.3/wxPython 2.4.2.4 and it still worked great. I tried to use

it

under Red Hat 8/Python 2.2/wxPython 2.4.2.4 and it fails. It's not
generating an error, but it's not visiting all the tree nodes.

Don't pass the cookie down recursivly, it is only needed for each parent
node.

     def printTree(self, treeNode):
         '''Recursively traverses a tree and prints the node labels.'''
         print 'printTree:', self.tree.GetItemText(treeNode)
         if self.tree.GetChildrenCount(treeNode, False):
             cookie = -1
             child, cookie = self.tree.GetFirstChild(treeNode, cookie)
             while child:
                 self.printTree(child)
                 child, cookie = self.tree.GetNextChild(treeNode, cookie)

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Paul Gardella wrote:

Thanks for the reply; I tried your suggested code, but it gives me the same
results as before on Linux; namely, it only visits the following nodes:

The Root Item
Item 0
item 0-a
item 0-a-0
item 0-a-1
item 0-b
item 0-b-0
item 0-b-2

...then it stops without signalling an error of any kind. Works great under
Win2K, though. Any ideas? Thanks.

Well, I ran my code on Linux using 2.4.2.4 so I know it works. Are you sure you're actually using 2.4.2.4 and are executing the new code and not the old?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin,

Thanks again for your reply.

I'm sure I'm running the new code because I added some print statements and
they appeared in the output. I'm also sure I'm using wxPython 2.4.2.4
because I added a "print wx.__version__" statement into the code and the
output showed 2.4.2.4.

I'm running Python 2.2.2.

On Windows, I'm running Python 2.3 with wxPython 2.4.2.4, but I used to run
the same app on Python 2.2.2/wxPython 2.4.0.2, and the tree traversal worked
fine in both cases (again, in Windows).

To test my code, I'm just using a copy of wxTreeCtrl.py from the /demo
directory of the wxPython distribution that I've modified by adding the
method printTree(wxTreeItemId) that now contains the code you sent in your
previous email in this thread, and a statement at the end of the
TestTreeControlPanel constructor calling the printTree method with the root
item as an arg. I run it by executing "python MyWxTreeCtrl.py" from the
wxPython-2.4.2.4/demo dir in a Linux terminal window. Does any of this help
you understand where the problem may be? Thanks.

Paul Gardella

···

-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Tuesday, October 21, 2003 12:16 PM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] wxTreeCtrl tree node traversal works under
MSW, fails under Linux

Paul Gardella wrote:

Thanks for the reply; I tried your suggested code, but it gives me the

same

results as before on Linux; namely, it only visits the following nodes:

The Root Item
Item 0
item 0-a
item 0-a-0
item 0-a-1
item 0-b
item 0-b-0
item 0-b-2

...then it stops without signalling an error of any kind. Works great

under

Win2K, though. Any ideas? Thanks.

Well, I ran my code on Linux using 2.4.2.4 so I know it works. Are you
sure you're actually using 2.4.2.4 and are executing the new code and
not the old?

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

The reason why I see this code work on Windows and fail on Linux is
a error on my part. I use this_item in the GetFirstChild call, but
not in the GetNextChild call.

I guess on windows the GetNextChild call ignores the item param and
uses the cookie.

I have some observations:

1) I wish this had failed on Windows as well as Linux.
2) The cookie arg to GetFirstChild is unnecessary in python.
3) It would be nice to have an iterator for walking the children
    that hide the procedural cookie function call stuff.

Barry

···

def updateTreeItem( self, this_item ):
        print 'updateTreeItem: start'
        if this_item is None:
                return

        handler = self.tree_ctrl.GetPyData( this_item )
        pi = handler.getProjectInfo()
        if not pi:
                return

        project_info_list = handler.getExpansion()
        # remove any items that are no longer present
        del_items =
        found_pi =

        cookie = -1
        item, cookie = self.tree_ctrl.GetFirstChild( this_item, cookie )

        print
        while item.IsOk():
                tree_pi = self.tree_ctrl.GetPyData( item ).getProjectInfo()

                found = False
                for index, pi in enumerate( project_info_list ):
                        if tree_pi.isEqual( pi ):
                                found = True
                                found_pi.append( index )
                                break
                if not found:
                        del_items.append( item )

                item, cookie = self.tree_ctrl.GetNextChild( item, cookie )