我想使用滚动条滚动连续的数字。 我已经设法通过更改一个足够大的可滚动列表框来一次只显示一个数字,但我想知道是否可以将滚动条设置为textvariable或其他东西,以使列表框只是TkLabels。
到目前为止,这是我的代码:
require 'tk'
require 'tkextlib/tile'
root = TkRoot.new
$l = TkListbox.new(root) {height 1; width 2;
yscrollcommand proc{|*args| $s.set(*args)} }.grid :column => 0, :row => 0, :padx => 50, :pady => 10
$s = Tk::Tile::Scrollbar.new(root) {orient 'horizontal';
command proc{|*args| $l.yview(*args)}}.grid :column => 0, :row => 1, :sticky => 'ew'
sz = Tk::Tile::SizeGrip.new(root).grid :column => 1, :row => 1, :sticky => 'se'
TkGrid.columnconfigure root, 0, :weight => 1
TkGrid.rowconfigure root, 0, :weight => 1
(0..10).each {|i| $l.insert 'end', "#{i}"}
Tk.mainloop