hi i dont have idea what do when pass events from the frame class to
other definition i have this
class frame(wx.Frame):
etc.
self.createtoolbar()
and in the other file have the toolbar
def createtoolbar(self):
hi i dont have idea what do when pass events from the frame class to
other definition i have this
class frame(wx.Frame):
etc.
self.createtoolbar()
and in the other file have the toolbar
def createtoolbar(self):
hi i dont have idea what do when pass events from the frame class to
other definition i have thisclass frame(wx.Frame):
etc.
self.createtoolbar()and in the other file have the toolbar
def createtoolbar(self):
If this toolbar belongs to the frame, why is the function in another
file? It could and probably should just go in one .py file if it is a
simple toolbar, probably just as a method of the Frame.
But if it is something complex, and you want to keep it in its own
module, you can make it a class, save it in a module, then import the
class from the module. So in the frame:
from MyWidgetsModule import MyToolbar
class Frame(wx.Frame):
etc...
toolbar = MyToolbar(self)
Now the frame has a reference to the toolbar ("toolbar") and the
toolbar has a reference to the frame (its parent). I think you can
pass tool events to the main frame in the event handler, like
#from inside the module's code
self.Bind(EVT_TOOL, id, parent.OnTool)
And then have an OnTool handler in your Frame class.
This does create a dependence of one on the other, though, which is
not a great coding practice. You could also just use pubsub.
HTH,
Che