K
Kenneth McDonald
OK, I dug up an answer to my previous question; here's code to
implement a window with scrollbars:
require 'tk'
root = TkRoot.new() { title "(Sc)rolling, (sc)rolling),
(sc)rolling..." }
xbar = TkScrollbar.new(root, 'orient'=>'h').pack('side'=>'bottom',
'fill'=>'x')
ybar = TkScrollbar.new(root, 'orient'=>'v').pack('side'=>'right',
'fill'=>'y')
text = TkText.new(root, 'wrap'=>'none',
'width'=>20).pack('fill'=>'both', 'expand'=>true)
text.insert('end', "A string that is longer than fits on one line...")
xbar.command(proc {|*args| text.xview(*args)})
text.xscrollcommand(proc {|first, last| xbar.set(first, last)})
ybar.command(proc {|*args| text.yview(*args)})
text.yscrollcommand(proc {|first, last| ybar.set(first, last)})
Tk.mainloop
Next question; how does one access the new 'themed' widgets in the
modern releases of Tk? Something like ttk::entry, I mean; I assume the
double colon wouldn't be used in Ruby (and I certainly couldn't get it
to work.)
Thanks,
Ken
implement a window with scrollbars:
require 'tk'
root = TkRoot.new() { title "(Sc)rolling, (sc)rolling),
(sc)rolling..." }
xbar = TkScrollbar.new(root, 'orient'=>'h').pack('side'=>'bottom',
'fill'=>'x')
ybar = TkScrollbar.new(root, 'orient'=>'v').pack('side'=>'right',
'fill'=>'y')
text = TkText.new(root, 'wrap'=>'none',
'width'=>20).pack('fill'=>'both', 'expand'=>true)
text.insert('end', "A string that is longer than fits on one line...")
xbar.command(proc {|*args| text.xview(*args)})
text.xscrollcommand(proc {|first, last| xbar.set(first, last)})
ybar.command(proc {|*args| text.yview(*args)})
text.yscrollcommand(proc {|first, last| ybar.set(first, last)})
Tk.mainloop
Next question; how does one access the new 'themed' widgets in the
modern releases of Tk? Something like ttk::entry, I mean; I assume the
double colon wouldn't be used in Ruby (and I certainly couldn't get it
to work.)
Thanks,
Ken