Python Forum
[WxPython] Which def is executed?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[WxPython] Which def is executed?
#10
Thanks to both of you!
I can't say that I understand what's happening with the IDs, but it works.

It guess that I was led into this trap by the "Style Guide" from https://wiki.wxpython.org/wxPython%20Style%20Guide. It's more or less the only site where I could find something about the usage of ids in wxpython at all. There, it's written:
Quote:Don't use IDs. There is very rarely a good reason to use them.
...
If the id is a required argument, use wx.ID_ANY.
...
EXCEPTION: (there's always an exception!) Use standard IDs for standard menus, buttons, etc. It is useful to use the standard IDs because they may turn on standard functionality, such as menu item remapping for wxMac, automatic Dialog completion or cancellation, using stock button labels and images, etc.  
...
By using your own ids you just block this ability to play by the rules.

If I use the menu build-up pattern I had in the beginnig, the id seems to be a 'required argument'. Unfortunately, the guide only writes something about the standard menus, but nothing is mentioned for other (own) menu items. So, I did what it writes - I used wx.ID_ANY. I have seen that other people use 'fixed' ids in that case, but I rated the style guide higher. I assume that there is a secret list of 'fixed' ids, and I would prefer to avoid collisions that may lead to hard-to-detect misfunctions if I accidentally hit a predefined id.

And if I understand, Yoritz' code allows to circumvent this by naming the object that is created by the 'Append' and used the id that is 'packed' into it, therefore no more being an (explicit) 'required argument'.


Well, now I wonder more that most of the code was working well, and the misfunction was completely reproducable. I would have guessed that in the case of an assignment of 'random' ids there would be a more 'random' behaviour, too.

And: Does someone know a place where one can learn more about the secrets of ids in wxpython? I searched the docs, but the seem to write nothing at all about ids.
Reply


Messages In This Thread
Which def is executed? - by merlem - Feb-09-2017, 01:57 PM
RE: Which def is executed? - by Larz60+ - Feb-09-2017, 02:25 PM
RE: Which def is executed? - by merlem - Feb-09-2017, 03:14 PM
RE: Which def is executed? - by Larz60+ - Feb-09-2017, 06:44 PM
RE: Which def is executed? - by merlem - Feb-09-2017, 07:00 PM
RE: Which def is executed? - by Larz60+ - Feb-09-2017, 07:51 PM
RE: Which def is executed? - by merlem - Feb-09-2017, 08:13 PM
RE: Which def is executed? - by Larz60+ - Feb-09-2017, 09:22 PM
RE: Which def is executed? - by Yoriz - Feb-09-2017, 09:59 PM
RE: Which def is executed? - by merlem - Feb-10-2017, 10:26 AM
RE: Which def is executed? - by Yoriz - Feb-10-2017, 11:28 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] messagebox is not being executed please help erwinsiuda 2 2,319 Apr-02-2020, 01:56 AM
Last Post: Larz60+
  [Tkinter] Window unresponsive when executed. fawazcode 2 3,818 Sep-11-2017, 12:29 AM
Last Post: Larz60+
  [xbmc] How to block the code from executed twice under the loop chris0147 29 23,281 Oct-26-2016, 05:34 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020