tags:

views:

181

answers:

1

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.

+3  A: 

When I ran the above code it works as expected on my linux desktop with a connected display. If I had to guess, I'd say that Xming has extremely limited font support, maybe only supplying a handful of bitmapped (read: non-scaleable) fonts.

So, I would say the code is correct and the problem is related to the X server configuration.

Bryan Oakley
You are so right. Should have thought about it myself. I looked into Xming settings but couldn't find any clues there. I'd guess it's hopeless, but maybe you have, by chance, any idea how to make it work on Xming too?
FireAphis