Forum: Ruby Ruby draw fullscreen windows

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
RedShift (Guest)
on 2006-04-17 14:30
(Received via mailing list)
Hello

Seeing the current state of "mediacenter" software, I decided to write
my own. For playing multimedia, I decided on xine-lib using
http://xiron.sourceforge.net/

I still need one thing though, something to draw windows with. Like GTK,
QT, TK, etc... Easily skinnable would be nice. 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. And it
should be able to draw windows fullscreen without borders. Any
suggestions?

I would also like to know if it were able to access v4l (video for
linux) devices from ruby, this thing has got to be able to make use of a
  TV card.

Thanks

Glenn
Hidetoshi NAGAI (Guest)
on 2006-04-20 18:03
(Received via mailing list)
From: RedShift <removed_email_address@domain.invalid>
Subject: Ruby draw fullscreen windows
Date: Mon, 17 Apr 2006 19:28:42 +0900
Message-ID: <removed_email_address@domain.invalid>
> 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.
This topic is locked and can not be replied to.