[ruby-gnome2-doc-cvs] [Hiki] update - tut-gtk2-packing-tables-demo

アーカイブの一覧に戻る

ruby-****@sourc***** ruby-****@sourc*****
2004年 4月 3日 (土) 07:30:12 JST


-------------------------
REMOTE_ADDR = 200.216.151.125
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/en/?tut-gtk2-packing-tables-demo
-------------------------
- {{link "tut-gtk2-packing-tables", "tut-gtk2-packing-intro", "tut-gtk", nil}}
  = Table Packing Example
+ {{link "tut-gtk2-packing-tables", "tut-gtk2-packing-intro", "tut-gtk", nil}}
  
  {{image_right("tablepack.png")}}
  
  Here we make a window with three buttons in a 2x2 table. The first two buttons will be placed in the upper row. A third, quit button, is placed in the lower row, spanning both columns.
  
  Here is the source code:
  
    #!/usr/bin/env ruby
  
    require 'gtk2'
  
    Gtk.init
  
    window = Gtk::Window.new
    window.title = "Table"
    window.signal_connect("delete_event") do
        Gtk.main_quit
        false
    end
    window.border_width = 20
  
    # Creates a 2x2 table.
    table = Gtk::Table.new(2, 2, true)
    window.add(table)
  
    [1, 2].each do |i|
        button = Gtk::Button.new("button #{i}")
        button.signal_connect("clicked") do
            puts "Hello again - button #{i} was pressed"
        end
        # Insert button 1 into the upper left quadrant of the table,
        # and button 2 into the upper right quadrant of the table.
        table.attach_defaults(button, i - 1, i, 0, 1)
    end
  
    button = Gtk::Button.new("Quit")
    button.signal_connect("clicked") do
        Gtk::main_quit
    end
  
    # Insert the quit button into the both lower quadrants of the table.
    table.attach_defaults(button, 0, 2, 1, 2)
  
    window.show_all
    Gtk.main





ruby-gnome2-cvs メーリングリストの案内
アーカイブの一覧に戻る