From: Schelte Bron on 30 Nov 2009 14:06 MSEdit wrote: > I already have code connected to the <<ThemeChanged>> virtual > event (to change a couple of canvas backgrounds and a Bwidget > notebook) what I need is a list of the menus for each window > (preferably without changing all the menu creation code to record > the menu id's). > You are working too hard. Just add the virtual event to the widget class and it will automatically be called for each menu widget: bind Menu <<ThemeChanged>> {ChangeMenuColors %W} Schelte.
From: Bryan Oakley on 30 Nov 2009 14:14 On Nov 30, 10:07 am, MSEdit <mse...(a)gmail.com> wrote: > My problem is not to configure or find the colours but to be able to > loop over the menubar elements. > > I already have code connected to the <<ThemeChanged>> virtual event > (to change a couple of canvas backgrounds and a Bwidget notebook) what > I need is a list of the menus for each window (preferably without > changing all the menu creation code to record the menu id's). > > Is there no introspection command to give me a list of menus in the > menu bar and for each menu a list of indexes to configure. > > Martyn Yes, there is plenty of introspection. For example, [. cget -menu] will give you the menu associated with the main window. Given a menu you can use the index command like [$menu index end] to get the index of the last item. You can then loop from zero to that number, and use entrycget to get the value for each item. And so on. If you need to know what popup menus exist (ie: those not tied to a toplevel with the -menu option) you can get a list of all widgets (I'm usually lazy and do [info commands .*]) and pick out the ones you want by looking at the widget class. In the case of menus you need to exclude clones.
From: Alan Grunwald on 30 Nov 2009 14:16 MSEdit wrote: > My problem is not to configure or find the colours but to be able to > loop over the menubar elements. > > I already have code connected to the <<ThemeChanged>> virtual event > (to change a couple of canvas backgrounds and a Bwidget notebook) what > I need is a list of the menus for each window (preferably without > changing all the menu creation code to record the menu id's). > > Is there no introspection command to give me a list of menus in the > menu bar and for each menu a list of indexes to configure. > > > Martyn > Have you looked at set nEntries [$menu index end] for {set i 1} {$i <= $nEntries} {incr i} { puts stdout [join [$menu entryconfigure $i] \n] } For a cascade, there will be another menu widget entryconfigured as -menu and you can do the same thing to that menu. I seem to recall being confused by some of the things I found when I first did this kind of thing but a quick test just now held no surprises. Hope this helps! Alan
From: MSEdit on 1 Dec 2009 04:48 Thanks for all your replies, especially Schelte who shows the KISS rule of TCL. Everything is now working correctly. Martyn
First
|
Prev
|
Pages: 1 2 Prev: IPv6 address parsing/ validation Next: General low performance of wish in Windows |