I'm trying to learn how to use TkOptionButtonmenu and haven't found sufficient documentation yet. I know that I can specify the items to add to the TkOptionButtonmenu using constructor parameters. I can also add them one at a time using the add method.
Is there a method I can invoke after the constructor to add more than one? I can call the menu method on the TkOptionButtonmenu to get the OptionMenu. Other kinds of menus support a menuitems option for adding all the items at once, but it doesn't seem that TkOptionButtonmenu or OptionMenu support this.
In the simple code below, when I select something from the TkOptionMenubutton, it should cause the value in the TkEntry to be modified through the TkVariable named entry_var. However, the change isn't visible until I click the TkOptionMenubutton a second time. What am I missing? Is there a better way to listen for a selection to be made from the TkOptionMenubutton?
Thanks!
···
---
require 'tk'
root = TkRoot.new
entry_var = TkVariable.new(0)
option_var = TkVariable.new('other')
w = TkOptionMenubutton.new(root, option_var)
w.add('Marathon')
w.add('10K')
w.add('other')
w.pack
w.menu.bind('<MenuSelect>') do
entry_var.value =
if option_var.value == 'Marathon' then '26.2'
elsif option_var.value == '10K' then '6.2'
else '0'
end
end
TkEntry.new(root) do
pack
textvariable entry_var
end
Tk.mainloop
Hi,
From: "Mark Volkmann" <volkmann2@charter.net>
Subject: update delay related to TkOptionMenu
Date: Mon, 15 Nov 2004 03:05:54 +0900
Message-ID: <030d01c4ca74$94cc4a90$0200a8c0@MarkDesktop>
However, the change isn't visible until I click the TkOptionMenubutton
a second time. What am I missing?
Hmmm...
On my environment (Linux, Ruby 1.8 HEAD, Tcl/Tk 8.4.7),
it seems working properly.
Maybe it fails to update widgets on your environment.
Please try to add 'Tk.update' at last of the callback.
Thanks for the suggestion. Unfortunately, that didn't change anything. I still don't see the update to the TkEntry until I click the TkOptionButtonmenu a second time. Is there a different event I could bind to instead?
···
----- Original Message ----- From: "Hidetoshi NAGAI" <nagai@ai.kyutech.ac.jp>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Sunday, November 14, 2004 8:12 PM
Subject: Re: update delay related to TkOptionMenu
w.menu.bind('<MenuSelect>') do
entry_var.value =
if option_var.value == 'Marathon' then '26.2'
elsif option_var.value == '10K' then '6.2'
else '0'
end
Tk.update # <== HERE
end
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
Message-ID: <20041115.120457.71083440.nagai@ai.kyutech.ac.jp>
You can use TkVariable.trace.
^^^^^^^^^^^^^^^^
TkVariable#trace
Sorry.
···
From: Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
Subject: Re: update delay related to TkOptionMenu
Date: Mon, 15 Nov 2004 12:04:58 +0900
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
Is there any way to template RDOC's output? I don't mind the output it gives by default, but sometimes I would like to be able to list and navigate modules and classes differently then what is normally there.
Zach
Zach Dennis wrote:
Is there any way to template RDOC's output? I don't mind the output it gives by default, but sometimes I would like to be able to list and navigate modules and classes differently then what is normally there.
Zach
As a matter of fact, you can. Use the -T (or --template) option to rdoc to specify a template.
rdoc only comes with a few templates by default (looking in rdoc/generators/template/html I see 'hefss', 'html', 'kilmer', 'old_html', and 'one_page_html'), but you can make your own. Just look at those existing templates to get an idea of how to make your own.
- Jamis
···
--
Jamis Buck
jgb3@email.byu.edu
http://www.jamisbuck.org/jamis