我在Mac OS X 10.6上從Ruby 1.8.7上的ActiveTcl編碼Tk 8.5.9。Ruby/Tk:如何讓圖像獲得更小的按鈕部件
爲了滿足我的應用需求,我需要使按鈕小部件像GIF圖像一樣小,但我無法做到。我一直在搜索和試驗負面結果。
非常感謝任何線索提前。
以下是我試圖從中獲取小按鈕的代碼。
require 'tk'
require 'tkextlib/tile'
$up_img = TkPhotoImage.new("file"=>"arrowup-n.gif")
$down_img = TkPhotoImage.new("file"=>"arrowdown-n.gif")
root = TkRoot.new {title "Ek Composer"}
content = Tk::Tile::Frame.new(root).pack
Tk::Tile::Button.new(content) {width 1;image $up_img; command {move_up} }.pack
Tk::Tile::Button.new(content) {width 1;image $down_img;command {move_down}}.pack
def move_up
p "move up"
end
def move_down
p "move down"
end
Tk.mainloop
但按鍵仍然過大:(。
我會嘗試你的最新建議,添加綁定到標籤。 – Elias 2011-03-18 11:45:44
我添加了綁定到標籤。工作正常。謝謝。 – Elias 2011-03-28 04:54:46