From: Kevin A. <al...@se...> - 2005-04-04 16:52:26
|
On Apr 4, 2005, at 5:48 AM, Phil Edwards wrote: > On Sun, 2005-04-03 at 12:04, Alex Tweedly wrote: >> Is there any way to control the tab order for components created >> dynamically from the app ? >> > > AFAIK, Alex, it's just down to the order they appear in > self.components. > So if you have: > > ['button1', 'button2', 'button3'] > > and you then do self.components.insert(1, 'button4'), you should end up > with > > ['button1', 'button4', 'button2', 'button3'] > > then that's your TAB order, reading from left to right. > Actually, that won't work. self.components is a WidgetDict object as defined in model.py, it is not a simple list, it is a subclass of UserDict, so it is basically a glorified dictionary. Furthermore, the order of the components on the background is kept in the 'order' key and what it should do is have a list of the order the components (wxPython controls) were added to the background (wxPython Panel). You should never manipulate the order list directly! In order to modify the tab order dynamically, you basically have to destroy the controls and repopulate the panel which is what the resourceEditor does and it isn't particularly pretty, but if you need to do that sort of thing, then that's the code to look at. wxPython used to have a bug/feature where you could change the tab order simply by hiding and showing the controls, but that is long gone. I don't know why this never came up before, but I bet there is a problem if you want to have a component named parent, data, or order, so I probably need to test that, then change them to have leading underscores or something like that in the future, which also means updating the resourceEditor and perhaps some other tools. I'm not sure if I'll get to that this week before I leave for the UK or not. ka |