What is the use of widget id on wxpython?

I am 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 read something that says when it is set to -1, it is automatically generated, but what is the real use of id and how will it be useful for the event?

+3
source share
1 answer

The identifier is intended for identification and is used inside wxPython to track widgets and bind events or to generate events, etc. But most of the time as a wxPython user, you don’t need to set or use an identifier anywhere, since most of the time when you will use python objects to refer to widgets and not to identifiers, for example

>>> btn = wx.Button(win, label="click me")
>>> btn.Bind(wx.EVT_BUTTON, on_click)

, .

+8

Source: https://habr.com/ru/post/1727093/


All Articles