I have a three questions about using wxPython. I hope someone can help.
1. In a program I am writing, I subclassed wxPanel and wxFrame and put the panel in the frame. I want to be able to access the frame from methods within the panel. For example, I want to set the status bar text from a panel method.
Is it proper to handle this by saving a reference to the frame in the panel from within the panel's __init__ method? For example...
def __init__(self, parent):
wxPanel.__init__(self, parent, -1)
self.frame = parent
Since the frame already has a reference to the panel, this causes a circular reference between the panel and frame. Will the garbage collector handle this properly when it is time to clean up these objects?
2. I want to trap a button's mouse-down and mouse-up events. There seems to be no predefined EVT_* procedure to hook these events on buttons. I hunted around and discovered the following way to accomplish this.
# Create a button (a bitmap button in this case)
btnMoveLeft = wxBitmapButton(self, 1001, bmpLeft, wxPoint(0, 245), wxSize(bmpLeft.GetWidth(), bmpLeft.GetHeight()) )
# Hook the events
btnMoveLeft.Connect(-1, -1, wxEVT_LEFT_DOWN, self.OnMouseDown)
btnMoveLeft.Connect(-1, -1, wxEVT_LEFT_UP, self.OnMouseUp)
# Implement the events
def OnMouseDown(self, event):
# do stuff here
event.Skip() # Continue handling event
def OnMouseUp(self, event):
# do stuff here
event.Skip() # Continue handling event
As you can see, I had to call event.Skip in order to make the button appear to depress.
Is this the proper way to hook these mouse events on buttons? Or, is there a better way to do this?
3. Are there any commerical programs written using wxPython?
Thanks for your help.
Mark
···
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp