Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Quick GTK+ Example
Index -> Programming, Ruby -> Ruby Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
rdrake




PostPosted: Mon Jun 05, 2006 9:57 pm   Post subject: Quick GTK+ Example

Doesn't get into packing or any of that fun stuff, just something to get your feet wet.
code:
# Include required library
require 'gtk2'

# Initialize the mighty GTK+
Gtk.init

# Create the window, inform the user of this
@win = Gtk::Window.new
puts "creating window"

# Obviously we want this to be the title
@win.title = "Window Test"

# Create a virtual box
#hbox = Gtk::HBox.new(false, 0)
#@win.add(hbox)
#hbox.show

# Create a quit button
@quit = Gtk::Button.new("Please don't kill me :(")
@quit.signal_connect("clicked") {
    puts "Destroying window"
    # Destroy the window
    Gtk.main_quit
}

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

# Place the quit button in the virtual window
#hbox.pack_start(@quit, false, false, 0)

# Display everything
@win.add(@quit)
@win.show_all

# Add some padding to the border
@win.border_width=10

# Kinda pointless, but it makes it fairly big
@win.resize(500, 500)
# Finish up and execute GTK+
Gtk.main
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Ruby -> Ruby Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: