hey 🙂
ok im looking for a way to create a large number of panels in wxpython and append a hold to them in a list but am not sure how best to do this. for example
for i in list:
wx.Panel(self, -1, pos, size) #create the panel
somehow store a hold to it e.g
anotherlist.append(a) #where a is the hold to the panel
when i say hold i mean say the variable name is x, so
x = wx.Panel. i would call x the hold cos x can be used for any manipulation of the widget, e.g x.SetPosition etc.. i was thinking maybe using a class something(wx.Panel) that creates the panel and saves the id of the panel.. problem is having the id i have no idea how to access the widget. say the panels id is -206. how do i do something like widgetid(-206).SetBackgroundColour(“RED”)
Some people solve these sorts of things by creating the ids at the beginning of the file:
And then doing something like myPanel = wx.FindWindowById(panelOneId). Of course, if all you’re doing is setting panel attributes, it might just behoove you to create a helper method like this:
You can also use wx.FindWindowByName, if you’ve given the panels unique name parameters.