From: RedShift <redshift / pandora.be>
Subject: Ruby draw fullscreen windows
Date: Mon, 17 Apr 2006 19:28:42 +0900
Message-ID: <44436E1E.4040603 / pandora.be>
> I still need one thing though, something to draw windows with. Like GTK, 
> QT, TK, etc... 

In the case of Ruby/Tk, 

>                 Easily skinnable would be nice. 

Maybe, Tile extension is useful for customizable skin.

>                                                 It should also be easy to 
> control by keyboard, the goal of the GUI is that it can be used with 
> only four arrow keys (up, down, left, right) and an enter button.

For example, 
---------------------------------------------------------------------------
require 'tk'

btag = TkBindTag.new

widgets = (0..4).collect{|y|
  f = TkFrame.new.pack
  (0..6).collect{|x|
    b = TkButton.new(f, :text=>"(#{x},#{y})", 
                     :command=>proc{puts "press (#{x},#{y})"}, 
                     :takefocus=>true).pack(:side=>:left)
    b.bindtags_unshift(btag)
    b.instance_variable_set('@coords', [x, y])
    b
  }
}

btag.bind('Return', proc{|w| w.invoke}, '%W')
btag.bind('FocusIn', proc{|w| w.state('active')}, '%W')
btag.bind('FocusOut', proc{|w| w.state('normal')}, '%W')
btag.bind('Left', proc{|w|
             x, y = w.instance_variable_get('@coords')
             size = widgets[y].size
             widgets[y][(x+size-1)%size].focus
          }, '%W')
btag.bind('Right', proc{|w|
             x, y = w.instance_variable_get('@coords')
             size = widgets[y].size
             widgets[y][(x+1)%size].focus
          }, '%W')
btag.bind('Up', proc{|w|
             x, y = w.instance_variable_get('@coords')
             size = widgets.size
             widgets[(y+size-1)%size][x].focus
          }, '%W')
btag.bind('Down', proc{|w|
             x, y = w.instance_variable_get('@coords')
             size = widgets.size
             widgets[(y+1)%size][x].focus
          }, '%W')

widgets[0][0].focus

Tk.mainloop
---------------------------------------------------------------------------

>                                                                   And it 
> should be able to draw windows fullscreen without borders. Any suggestions?

For example, 
--------------------------------------------------------------------------
requrie 'tk'
TkButton.new(:text=>'quit', :command=>proc{exit}).pack
r = Tk.root
r.withdraw
r.overrideredirect = true
r.deiconify
r.geometry = "#{r.winfo_screenwidth}x#{r.winfo_screenheight}+0+0"
Tk.mainloop
--------------------------------------------------------------------------

# On windows, "Tk.root.state = 'zoomed'" is useful.

-- 
Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp)