From: Isaac Toothyxdip Date: 2008-03-11T01:34:39+09:00 Subject: Re: Reading pick from option menu Isaac Toothyxdip wrote: > Thanks. > > My question was are you able to do this with a entry box or even just a > TkVariable instead of a canvas? > I've been trying to intertwine your method with what im trying to do and > have had no luck. Im going to keep trying and do some more searching. > > (What im doing is i have 2 entry boxes, 1 button, and 1 optionmenubutton > and in the top entry you type a number and then you pick an option from > the menu then you press the button and it multiplies the number you > inputed by a variable and the variable changes with the selection of the > menu) WOO got it to work i just completely started over and this is what my code is now: require 'tk' root = Tk.root root.title('Hello') @entry = TkVariable.new @menu_chosen = TkVariable.new menu_choices = ["Yes", "No"] menu_chosen = TkVariable.new menu = TkOptionMenubutton.new(root, menu_chosen, *menu_choices) menu.pack('pady'=>10) @number = menu_chosen entry = TkEntry.new(root) entry.pack('pady'=>10) entry.textvariable = @entry def multiply case @number.value when "Yes" @menu_chosen = 50 when "No" @menu_chosen = 30 end @entry.numeric *= @menu_chosen end button = TkButton.new(root) button.text = "Hello" button.pack('pady'=>10) button.command { multiply } #geometry min_w, min_h = 200, 200 root.resizable(flase,false) root_x = (root.winfo_screenwidth - min_w) / 2 root.geometry("#{min_w}x#{min_h}+#{root_x}") Tk.mainloop I tried something like this before but i dont think i had .value so it didnt work. Thanks for your help. -- Posted via http://www.ruby-forum.com/.