Reputation: 3651
I've been trying to learn wxpython and I see this id when creating widgets like:
menubar = wx.MenuBar()
file = wx.Menu()
file.Append(-1, 'Quit', 'Quit application')
menubar.Append(file, '&File')
I've read something that says when it is set to -1, its automatically generated but what's the real use of id and how will it be useful to the event?
Upvotes: 3
Views: 1572
Reputation: 88727
ID is for identification, and is used internally by wxPython to track widgets and bind events or emit events etc BUT most of the time as a user of wxPython you don't need to set or use ID in any place, because most of the time you will be using python objects to refer to widgets not the IDs e.g.
>>> btn = wx.Button(win, label="click me")
>>> btn.Bind(wx.EVT_BUTTON, on_click)
So you don't need to set ID to anything or need to refer it.
Upvotes: 8