wxToolBar and EVT_UPDATE_UI

Running the attached code on a linux machine with wxGTK2.4 and Python2.3, I
have observed that the frame that owns the toolbar doesn't receive the
UPDATE_UI events. If I run the code on a Win2k machine with wxPython2.4 and
Python2.2 everything's OK, the frame receives the MENU and UPDATE_UI
events.

Any ideas what's wrong with this code?

Thanks!

···

++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#!/usr/bin/env python

from wxPython.wx import *

##########################################################################

# The data for the icons. These functions were generated by img2py,
# which comes with the wxPython distribution, in the tools directory.
# It is a pretty handy way to imbed icons in your Python code.

from wxPython.wx import wxBitmapFromXPMData, wxImageFromBitmap

import cPickle, zlib

def GetHandData():
    return cPickle.loads(zlib.decompress(
'x\xda\xd3\xc8)0\xe4\nV72T\x00!\x05Cu\xae\xc4`u=\x85d\x05\xa7\x9c\xc4\xe4l0O\
\x01\xc8S\xb6t\x06A(\x1f\x0b\xa0\xa9\x8c\x9e\x1e6\x19\xa0\xa8\x1e\x88\xd4C\
\x97\xd1\x83\xe8\x80 \x9c2zh\xa6\xc1\x11X\n\xab\x8c\x02\x8a\x0cD!\x92\x12\
\x98\x8c\x1e\x8a\x8b\xd1d\x14\xf4\x90%\x90LC\xf6\xbf\x1e\xba\xab\x91%\xd0\
\xdc\x86C\x06\xd9m\xe8!\xaa\x87S\x86\x1a1\xa7\x07\x00v\x0f[\x17' ))

def GetHandBitmap():
    return wxBitmapFromXPMData(GetHandData())

def GetHandImage():
    return wxImageFromBitmap(GetHandBitmap())

################################################################################

ID_TEST = wxNewId()

class testToolbar(wxToolBar):
    def __init__(self, parent):
        wxToolBar.__init__(self, parent, -1)
        self.AddSimpleTool(ID_TEST, GetHandBitmap(), "Test toolbar", "Test
toolbar")
        self.Realize()

#################################################################################

class testFrame(wxFrame):
    def __init__(self, parent):
        wxFrame.__init__(self, parent, -1, "Main Frame", wxDefaultPosition,
wxDefaultSize, wxDEFAULT_FRAME_STYLE)

        self.theToolbar = testToolbar(self)
        self.SetToolBar(self.theToolbar)

        EVT_MENU(self, ID_TEST, self.OnTool)
        EVT_UPDATE_UI(self, ID_TEST, self.OnUpdateTool)

    def OnTool(self, event):
        print "OnTool"

    def OnUpdateTool(self, event):
        print "OnUpdateTool"

##################################################################################

class testApp(wxApp):
    def OnInit(self):
        wxInitAllImageHandlers()
        mainFrame = testFrame(NULL)
        mainFrame.Show(true)

        self.SetTopWindow(mainFrame)
        return true
###################################################################################

if __name__ == '__main__':
    app = testApp(0)
    app.MainLoop()

TMoldovan@Speech-Design.de wrote:

Running the attached code on a linux machine with wxGTK2.4 and Python2.3, I
have observed that the frame that owns the toolbar doesn't receive the
UPDATE_UI events. If I run the code on a Win2k machine with wxPython2.4 and
Python2.2 everything's OK, the frame receives the MENU and UPDATE_UI
events.

Any ideas what's wrong with this code?

I don't know. Please enter a bug report about it with a category of wxGTK, and specify that it is for the 2.4.2 version. The good news is that it does work in 2.5

···

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