From: florentis on 9 Feb 2010 03:48 # 1. Problem in mixing namespace separator in widget path proc Proc_test {} { toplevel .:: ttk::combobox .::.cb0 -values [list 1 2 3 4 5 6 7 8 9 10 11 12 13 14] pack .::.cb0 -expand 1 } # Don't work. # because combobox command is named "ttk::combobox::.::.cb0" instead of # .::.cb0 as expected. So the path of the widget arn't the same any more ! # Note that "winfo children .::.cb0" return ".::.cb0" as expected. # It seems that the namespace separator in the path name of the widget make # the window command be interpreted as relative to the current namespace. # I had to patch the proc ttk::combobox::PopdownWindow this way proc ttk::combobox::PopdownWindow {cb} { variable scrollbar if {![winfo exists $cb.popdown]} { set poplevel [namespace eval :: [list ttk::combobox::PopdownToplevel $cb.popdown]] set popdown [namespace eval :: [list ttk::frame $poplevel.f - style ComboboxPopdownFrame]] namespace eval :: [list $scrollbar $popdown.sb \ -orient vertical -command [list $popdown.l yview]] namespace eval :: [list listbox $popdown.l \ -listvariable ttk::combobox::Values($cb) \ -yscrollcommand [list $popdown.sb set] \ -exportselection false \ -selectmode browse \ -activestyle none\ ;] bindtags $popdown.l \ [list $popdown.l ComboboxListbox Listbox $popdown all] grid $popdown.l -row 0 -column 0 -padx {1 0} -pady 1 -sticky nsew grid $popdown.sb -row 0 -column 1 -padx {0 1} -pady 1 -sticky ns grid columnconfigure $popdown 0 -weight 1 grid rowconfigure $popdown 0 -weight 1 grid $popdown -sticky news -padx 0 -pady 0 grid rowconfigure $poplevel 0 -weight 1 grid columnconfigure $poplevel 0 -weight 1 } return $cb.popdown } # Similarily, the problem occur, even if ttk::combobox is patched to go the # good way, in ensemble and objects. # For instance, this is incorrect namespace eval ensemble0 { proc test {} { toplevel .:: ttk::combobox .::.cb0 -values [list 1 2 3 4 5 6 7 8 9 10 11 12 13 14] pack .::.cb0 -expand 1 } namespace export * namespace ensemble create } # executing : "ensemble0 test" lead to a combobox command result in # ::ensemble0::.::.cb0 (wheras the path given by "winfo children" is correct) # But this is correct (with the ttk patch above): namespace eval ensemble1 { proc test {} { namespace eval :: [list toplevel .::] namespace eval :: [list ttk::combobox .::.cb0 -values [list 1 2 3 4 5 6 7 8 9 10 11 12 13 14]] pack .::.cb0 -expand 1 } namespace export * namespace ensemble create } # And this is incorrect too oo::class create object0 { constructor {} { puts [self namespace] my variable compte toplevel .:: ttk::combobox .::.cb0 -values [list 1 2 3 4 5 6 7 8 9 10 11 12 13 14] pack .::.cb0 -expand 1 } } # executing : object0 create test # combobox command result in something like ::oo::Obj14::.::.cb0 # whereas this is correct (with the ttk patch above): oo::class create object1 { constructor {} { puts [self namespace] my variable compte namespace eval :: [list toplevel .::] namespace eval :: [list ttk::combobox .::.cb0 -values [list 1 2 3 4 5 6 7 8 9 10 11 12 13 14]] pack .::.cb0 -expand 1 } } console show # Questions : # Is-it a bug ? Are namespace separator forbidden in widget path ? This # would be sad : adding namespace separator in the widget path is a good way # to avoid a pollution of the :: namespace. A widget .::top, for instance, is # automatically in a . namespace (at least in tcl8.6) # The work around is to always eval the widget command in the :: namespace. # Normaly, widget path and widget command should always be the same, no ? # if this was corrected, all widgets could be put in a ".::" namespace, so # not visible anymore in the root namespace, for example : # pack [frame .::f] # pack [text .::f.t] # are valid path (with the restrictions described above) # and aren't visible trought "info command ::*" but throught # "info command .::*" # 2. Other bug (tested with windows XP) # Doing : namespace eval "." {namespace ensemble create} # make wish instantaneously desappear. # What do you think about this ? # Cordialy, FM
|
Pages: 1 Prev: high cpu with wish Next: How to read a number from a line? |