Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Login

tut-gtk-helloworld

Ruby/GTK2 Hello World

helloworld.png

Here is a typical "Hello World" style program for Ruby/GTK2.

This program is also available in the file "gtk/sample/misc/helloworld.rb" in the ruby-gnome2 package.

#!/usr/bin/env ruby
=begin
  helloworld.rb - Ruby/GTK first sample script.

  Copyright (c) 2002,2003 Ruby-GNOME2 Project Team
  This program is licenced under the same licence as Ruby-GNOME2.

  $Id: helloworld.rb,v 1.4 2003/02/01 16:46:22 mutoh Exp $
=end

require 'gtk2'

button = Gtk::Button.new("Hello World")
button.signal_connect("clicked") {
  puts "Hello World"
}

window = Gtk::Window.new
window.signal_connect("delete_event") {
  puts "delete event occurred"
  #true
  false
}

window.signal_connect("destroy") {
  puts "destroy event occurred"
  Gtk.main_quit
}

window.border_width = 10
window.add(button)
window.show_all

Gtk.main
Last modified:2006/07/02 14:25:11
Keyword(s):
References:[tut-gtk]