English 中文(简体)
Duncan/Tk:如何获得带图像的较小的纽顿植被。
原标题:Ruby/Tk: how to get smaller button widget with image

I m coding on Tk 8.5.9 from ActiveTcl on Ruby 1.8.7 on a Mac OS X 10.6.

满足我的申请要求 我需要把 but子作为小块植被,而我却无法做到。 我有数小时的搜索和实验结果。

Greatly thankful in advance for any clues.

下面是一部法典,试图从小县获得。

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

但是,各州仍然过于庞大:

问题回答

它 s。 <really的OSX主题希望在纽伦两端增加额外空间。

你可以尝试转向传统的纽芬兰语(见tk本身),但这会使空间更垂直,看上去比本土更远。 或者,你可以把图像贴在标签上(你可以确切地缩小这一形象),并在标签上添加约束力,使之对点火做出反应。

我在标签上增加了约束力。 工作罚款。 感谢。 遵循具有装成吨的标签准则。

require  tk 


$resultsVar = TkVariable.new
root = TkRoot.new
root.title = "Window"

$up_img = TkPhotoImage.new("file"=>"arrowup-n.gif")
$down_img = TkPhotoImage.new("file"=>"arrowdown-n.gif")

Lbl = TkLabel.new(root) do
  image $up_img
  borderwidth 0
  font TkFont.new( times 20 bold )
  foreground  "red"
  relief      "groove"
  pack("side" => "right",  "padx"=> "50", "pady"=> "50")
end

Lbl.bind("ButtonPress-1")  {
    Lbl.configure("image"=>$down_img) 
}

Lbl.bind("ButtonRelease-1") { 
    Lbl.configure("image"=>$up_img) 
}

Lbl[ textvariable ] = $resultsVar
$resultsVar.value =  New value to display 

Tk.mainloop




相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签