i’m working on gui using ruby/tk.
Everything went fine (exept the poor documentation), but now i have a
problem with submenus. A small example-code to demonstrate the issue:
menu = TkMenu.new
menu.add_command(‘label’ => ‘Foo’, ‘command’ => lambda { p “foo” })
sub = TkMenu.new
sub.add_command(‘label’ => ‘Bar’, ‘command’ => lambda { p “bar” })
menu.add_cascade(‘label’ => ‘submenu’, ‘menu’ => sub)
The code works nearly as expected, menu appears an has correct content.
If i click on “Foo”, text “foo” is written to the console, but if i
click on
“Bar” nothing happens
Any idea what’s going wrong?
Ruby: ruby 1.8.5 (2006-08-25) [i486-linux]
Linux: Linux version 2.6.12 (root@louipaz) (gcc version 3.3.6 (Debian
1:3.3.6-13))
Any reason you aren’t using Qt? I don’t want to sound like a broken
record
here, but Qt’s documentation is much better than for Tk, the apps look
better, and so forth.
The code works nearly as expected, menu appears an has correct content.
If i click on “Foo”, text “foo” is written to the console, but if i
click on
“Bar” nothing happens
Any idea what’s going wrong?
Ruby: ruby 1.8.5 (2006-08-25) [i486-linux]
Linux: Linux version 2.6.12 (root@louipaz) (gcc version 3.3.6 (Debian
1:3.3.6-13))
That is NOT a bug of Ruby/Tk. Tcl/Tk will give you a same result.
Probably, your trouble depends on the relationship between the
menu and the cascade menu.
Please try to make the cascade menu as a daughter of the menu
(e.g. “sub = TkMenu.new(menu)”).
^^^^
That is NOT a bug of Ruby/Tk. Tcl/Tk will give you a same result.
Probably, your trouble depends on the relationship between the
menu and the cascade menu.
Please try to make the cascade menu as a daughter of the menu
(e.g. “sub = TkMenu.new(menu)”).
^^^^
That’s it, thanks a lot!
One thing i noticed while testing:
it also depends on the windowmanager. On KDE (for example) the “bad”
code works fine, on fluxbox it doesn’t…
best regards,
Matthias
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.