In addition to the solutions already posted, you can create the
widgets and then retrieve the ID for use elsewhere.
However, in wxPython, I tend to ignore IDs almost totally and simply
pass the widget itself anywhere I need it.
···
On 3/30/07, DomDom <BestDomDom@neuf.fr> wrote:
Hello,
Until now, I put -1 or wx.NewId() in the widgets' contructors.
Based on some events or buttons, I need to get the IDs and the contents of
the widgets to reuse them somewhere else.
How do the automatic setting of the Ids work ?
Can I set an arbitrary Id for each widget (1,2,3,...) and in that case, are
there rules I should follow or Id numbers I should avoid ?
Until now, I put -1 or wx.NewId() in the widgets' contructors.
I think the cleanest way to do it is to not specify an id at all, and use keyword args for the stuff you do need to specify:
MyButton = wx.Button(parent, label="ALabel")
There are a few places where an id must be specified, wx.Menu.Append() for instance. IN that case, use:
wx.ID_ANY
(which equals -1, but I think it's clearer and more future proof.)
Chris Mellon wrote:
in wxPython, I tend to ignore IDs almost totally and simply
pass the widget itself anywhere I need it.
me too, but if you really do need it:
id = MyButton.GetId()
-Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception