Hidetoshi NAGAI
2/5/2009 2:37:00 AM
From: Albert Schlef <albertschlef@gmail.com>
Subject: Re: A Tk window
Date: Wed, 4 Feb 2009 22:40:16 +0900
Message-ID: <8e4169fd337e5c6f2f00f947a74c508b@ruby-forum.com>
> dead-end. (It has an ingeniously simple API, I admit, but the facts that
> I struggled yesterday to fetch the selcted item from a TkListbox, and
> even more to add scrollbars,
Hmm... I think that it not so difficult.
Possibly, Ruby/Tk is easier than Tcl/Tk.
-------------------------------------------------------------------
require 'tk'
f = TkFrame.new.pack(:expand=>true, :fill=>:both)
lbox = TkListbox.new(f)
lbox.yscrollbar(TkScrollbar.new(f).pack(:side=>:right, :fill=>:y))
lbox.pack(:side=>:right, :expand=>true, :fill=>:both)
lbox.bind('<ListboxSelect>', :widget){|w|
# :widget equal to "%W" (see Tcl/Tk's "bind" manual).
# current Ruby/Tk supports accessor-names of Tk::Event object instead of
# "%" substitutions.
p [w.curselection, w.get(w.curselection[0])]
}
lbox.value = %w(a b c foo bar baz hoge fuga zzz asdf qwer zxcv)
lbox.focus
Tk.mainloop
-------------------------------------------------------------------
> and that the fonts are so ugly and
> unreadable, show that Tk has been dormant for at least 15 years.)
Well, I recommend you to use Tcl/Tk8.5 for your Ruby/Tk.
Tcl/Tk8.5 supports anti-aliased fonts on X window systems,
and includes Tile (Ttk) extension (widget styling engine) as default.
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)