Ruby 继承 Gtk::Window

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

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