Subclass Gtk::Window : gtk « GUI « Ruby






Subclass Gtk::Window


require "gtk"

class SampleWindow < Gtk::Window

  def initialize
    super
    set_title("Ruby/GTK Sample")
    signal_connect("destroy") { Gtk::main_quit }

    entry = Gtk::Entry.new

    button = Gtk::Button.new("All Caps!")
    button.signal_connect("clicked") { cmdAllCaps(entry) }

    box = Gtk::HBox.new
    box.add(Gtk::Label.new("Text:"))
    box.add(entry)
    box.add(button)

    add(box)
    show_all
  end

  def cmdAllCaps(textField)
    textField.set_text(textField.get_text.upcase)
  end
end

SampleWindow.new
Gtk::main

 








Related examples in the same category

1.Ruby/GTK version of "Hello, World":