Combobox in tcl gives error when any item is selected in it

756 views Asked by At

I'm using tk widget Combobox and whenever I select any item in it it gives

invalid command name .top47.not48.fpage2.sw.sf.frame.cf2.frame.c.shell.listb

my code looks like this:-

ComboBox $mainframe.cf2.frame.c -textvariable variable1 \
        -values Corners -modifycmd "new_values"

This is the main combobox that controls all the values of other combobox'es present in it which don't give any error like this.

1

There are 1 answers

0
patthoyts On

This is very likely due to an error in the "new_values" function you have omitted. As a sample to show this:

package require BWidget
proc modify {} {.xyzzy something}
ComboBox .c -textvariable v -values Corners -modifycmd modify
pack .c

Now when you run this and select an entry from the dropdown you get 'Error: invalid command name ".xyzzy"'. The window you are trying to address is evidently digging into the internal implementation of this BWidgets class as winfo children .c shows me that .c.shell.listb exists. However, this is unsafe - the implementation may change from one version to the next and you don't control when the dropdown is created and destroyed. Check for the existence of your target window using winfo exists $combo.shell.listb as a minimum. You may want to ensure a compatible version of the BWidgets package too by using package require -exact BWidget 1.M.N