Python Forum
[WxPython] [Very Basic Example Only] Hello World
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[WxPython] [Very Basic Example Only] Hello World
#6
About the only time I don't use -1 for the id is for menu and toolbar items.
for instance my menu and toolbar has an edit the menu item would use wx.ID_EDIT.
menu_edit = wx.MenuItem(menu_edit_group, wx.ID_EDIT, 'Edit',
    'Edit the selected item')
and then the toolbar widget would be
tool_bar.AddTool(wx.ID_EDIT, 'Edit', page_edit16.GetBitmap(), wx.NullBitmap,
    wx.ITEM_NORMAL, 'Edit the selected item', 'Edit the selected item')
then an event that enables/disable the controls         
self.Bind(wx.EVT_UPDATE_UI, self.on_update_on_selection, id=wx.ID_EDIT)
which is bound to
def on_update_on_selection(self, event):
    event.Enable(self.has_selection)
In general setting your own id is not needed because you access the widget by the python object linked to them.
The id is just used internally by wxwidgets to track widgets and tie events to widgets ect.

Note: there is a default attribute that can be used which has a value of -1
>>> wx.ID_ANY
-1
Reply


Messages In This Thread
[Very Basic Example Only] Hello World - by Yoriz - Oct-03-2016, 09:55 PM
RE: [wxPython Example] Hello World very basic - by Yoriz - Oct-08-2016, 06:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] [Very Basic Example Only] Hello World Yoriz 2 6,653 Oct-08-2016, 08:32 AM
Last Post: Yoriz

Forum Jump:

User Panel Messages

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