Cannot change font size in Tk
        Posted  
        
            by FireAphis
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by FireAphis
        
        
        
        Published on 2010-03-20T11:59:22Z
        Indexed on 
            2010/03/20
            12:01 UTC
        
        
        Read the original article
        Hit count: 753
        
Hello,
I'm trying, for the first time, to create a GUI in Ruby using Tk. I've copied a code snippet from one of the numerous web tutorials and try to change the font for one of the labels, but nothing seems to affect how the text is presented.
Here's the code:
require 'tk'
root = TkRoot.new('title'=>'MCIS')
defaultFont = TkFont.new("weight"=>'bold', "size"=>20)
Lbl = TkLabel.new(root) do
    text "Boooo"
    borderwidth 5
    font defaultFont
    foreground  "red"
    relief      "groove"
    grid('column'=>3, 'row'=>0)
end
Tk.mainloop()
I see the effects of all the parameters of the label but not the font. I've tried to change the size, the weight, give different family names, leave just one parameter; nothing works - the font stays default as it was. Surprisingly it doesn't report any errors, everything looks fine. Maybe it's versions problem? I run these:
- Linux Centos 5
- Tk 8.4.13
- Ruby 1.8.5
- ruby-tcltk 1.8.5
Also, don't know if it is important, I ran it via Xming from WinXP machine.
© Stack Overflow or respective owner