I am just starting using wxPython on windows platform and have some questions. You should regard me as a complete newbie, not just in wxPython but in GUI programming in general. I won’t be offended by any paternalism - in fact I appreciate it!
Ok, the questions:
-
Where should one place the event helper functions? For example, In M. Hammond’s book “Programming on win32” the helper functions for menu selections EVT_MENU are placed in the class deriving from wxFrame. If i derived a class from wxMenu could I place the EVT_MENU there? Or even in wxMenuItem (which seems to me to be the proper place)?
-
Can there be any clash between ID’s? Or do I have to ensure that throughout the whole application the id’s are globally unique? If not, what is the “level” at which i have to ensure they are unique?
My thanx in advance for the help,
Gonçalo Rodrigues
I am just starting using wxPython on windows platform and have some questions. You should regard me as a complete newbie, not just in wxPython but in GUI programming in general. I won't be offended by any paternalism - in fact I appreciate it!
Okay, fine. I'm your father 
1. Where should one place the event helper functions? For example, In M. Hammond's book "Programming on win32" the helper functions for menu selections EVT_MENU are placed in the class deriving from wxFrame. If i derived a class from wxMenu could I place the EVT_MENU there? Or even in wxMenuItem (which seems to me to be the proper place)?
Why would you want to derive from wxMenu? I suppose you could place them there, but why? I typically put them with the menu definitions, hence keeping the whole mess together in one place. Since a wxFrame is a common place to create menus (on the menubar) this is why you will often see them there.
2. Can there be any clash between ID's? Or do I have to ensure that throughout the whole application the id's are globally unique? If not, what is the "level" at which i have to ensure they are unique?
I believe ID's must be unique, for event handling purposes (if you aren't assigning events to the widgets, I'm not really sure if it's necessary or not - but I wouldn't tempt fate). If you don't care what the ID will be, use -1 and let wxPython assign an ID for you. Typically I use either -1 (and if I want the ID later, I use w.GetId() ) or wxNewId() which will give you a new, unique ID. It's probably not good practice to explicitly assign ID's since then it falls on you to ensure their uniqueness.
···
On Sat, 22 Dec 2001 00:07:21 -0000 GonçaloRodrigues <op73418@mail.telepac.pt> wrote:
--
Cliff Wells
Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308
(800) 735-0555 x308
[snip]
Cliff answered your questions well, but both of them (esp the one about
wxMenu) is very explicitly shown in the demo shipped with wxPython.
I know, I know . . . the demo code looks pretty daunting at first. But look
over it and you will see that it's pretty simple and does a great job
showing How Things Work. After that, the wxWindows documentation (which
is annoted with wxPython as well) is the second place to look. A lot of
times I thought, "Well, it would be easy to do things this way . . . "
and I look there and sure enough, it is already built into the widget.
wxPython is cool and, in a lot of ways, spoils you. (Motif anyone??)
My $0.02 . . .
Mike
···
On Sat, Dec 22, 2001 at 12:07:21AM -0000, GonçaloRodrigues wrote:
I am just starting using wxPython on windows platform and have some questions. You should regard me as a complete newbie, not just in wxPython but in GUI programming in general. I won't be offended by any paternalism - in fact I appreciate it!