[clue-cert] another simple Ruby Gk program
Dennis J Perkins
dennisjperkins at comcast.net
Fri Oct 26 22:20:40 MDT 2007
#! /usr/bin/env ruby
require "gtk2"
# Initialize GTK.
Gtk.init
# Create the toplevel window and make assign title.
win = Gtk::Window.new "Button Example 1"
win.border_width = 5
# Set the default size to a more convenient size. Note that the button
# size grows and shrinks based on the parameters passed to this method.
win.set_default_size 150, 80
# Note the underscore preceding the O. This causes the following letter
# to be underlined, representing a keyboard accelerator.
# To activate the accelerator, press Alt and the key.
button = Gtk::Button.new "_OK"
# Assign an action to the "clicked" signal, otherwise the button will
# not do anything.
button.signal_connect("clicked") { puts "button clicked" }
# Assign an action to the "destroy" signal that is generated when
# The Close button is clickd. If we don't do this, the pogram does not
# die when the window is destroyed.
win.signal_connect("destroy") {
Gtk.main_quit
}
# Add button to toplevel window.
win.add button
# Show all widgets. Compare this to the show method used in the first
# program.
win.show_all
# Start event loop.
Gtk.main
More information about the clue-cert
mailing list