Mombu the Programming Forum

Go Back   Mombu the Programming Forum > Programming > event occurs on tk_optionmenu change of value?
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 15th September 00:12
tfoxusenet
External User
 
Posts: 1
Default event occurs on tk_optionmenu change of value?



Hello,

I have a tcl application that includes the use of tk_optionmenus.
There are times when I would like something to happen when a user
selects something on the tk_optionmenu, for example, if I have a
tk_optionmenu called .top.fruits, and the user selects apples, I might
want to populate another tk_optionmenu .top.type with "granny_smith
golden_delicious", etc -- for oranges I might want "mandarin navel,"
etc. Right now, I am doing this, but I have to put a button next to
the tk_optionmenu called "form" which, when pressed, calls a tcl
procedure to then apply the appropriate widgets based on the users
choices. This seems to work okay, but Windows users are used to
drop-down-list-boxes that automatically change widgets when a new value
is selected without having to resort to using a "form" button or
something. Users are complaining about its presence there.

I'm sure there is a way to do this in tcl also. What I need is some
way to set an event on the change of value of the variable behind the
tk_optionmenu, so when it changes, it will then change the other
widgets based on the value of the first optionmenu. Trouble is, I
don't know how to do that. Is there anyone who can show me how?

Thanks!
  Reply With Quote


 


2 15th September 00:12
bryan oakley
External User
 
Posts: 1
Default event occurs on tk_optionmenu change of value?



You want to set a trace on the variable associated with the menu. When
the variable changes your proc will be called and you can do whatever
you want.

trace man page: http://www.tcl.tk/man/tcl8.4/TclCmd/trace.htm

--
Bryan Oakley
http://www.tclscripting.com
  Reply With Quote
Reply


Thread Tools
Display Modes




666