Gtk not work

P

Pokkai Dokkai

my os --> ubuntu 7.04
my ruby--> ruby 1.8.5 (2006-08-25) [i486-linux]

recently i download "ruby-gtk2-0.16.0" and install it


in terminal...

mani@user-UBUNTU704:~$ vim welcome.rb

require "gtk2"
include Gtk
def quick_message(message)
# Create the dialog
dialog = Gtk::Dialog.new("Message",
$main_application_window,
Gtk::Dialog::DESTROY_WITH_PARENT,
[ Gtk::Stock::OK,
Gtk::Dialog::RESPONSE_NONE ])
# Ensure that the dialog box is destroyed when the user responds.
dialog.signal_connect('response') { dialog.destroy }
# Add the message in a label, and show everything we've added to the
dialog.
dialog.vbox.add(Gtk::Label.new(message))
dialog.show_all
end
quick_message("welcome")
puts("checking")

mani@user-UBUNTU704:~$ ruby welcome.rb
checking
mani@user-UBUNTU704:~$

what is wrong here...

thank you for help
 
P

Pokkai Dokkai

sorry i did't tell my problem

my problem is i did't get any output window
thats alll
 
S

Stefano Crocco

Alle luned=C3=AC 1 ottobre 2007, Pokkai Dokkai ha scritto:
my os --> ubuntu 7.04
my ruby--> ruby 1.8.5 (2006-08-25) [i486-linux]

recently i download "ruby-gtk2-0.16.0" and install it


in terminal...

mani@user-UBUNTU704:~$ vim welcome.rb

require "gtk2"
include Gtk
def quick_message(message)
# Create the dialog
dialog =3D Gtk::Dialog.new("Message",
$main_application_window,
Gtk::Dialog::DESTROY_WITH_PARENT,
[ Gtk::Stock::OK,
Gtk::Dialog::RESPONSE_NONE ])
# Ensure that the dialog box is destroyed when the user responds.
dialog.signal_connect('response') { dialog.destroy }
# Add the message in a label, and show everything we've added to the
dialog.
dialog.vbox.add(Gtk::Label.new(message))
dialog.show_all
end
quick_message("welcome")
puts("checking")

mani@user-UBUNTU704:~$ ruby welcome.rb
checking
mani@user-UBUNTU704:~$

what is wrong here...

thank you for help

Your code lacks a call to the method which starts the event loop, that is=20
Gtk.main. Adding it to the end of your program should make it work.

You may not be aware of the fact that closing the dialog (either clicking t=
he=20
button or using the close button on the dialog's frame) doesn't quit your=20
application, as it is now. To do so, you should connect the dialog destroy=
=20
signal with the method Gtk.main_quit: in the method quick_message, add the=
=20
code

dialog.signal_connect('destroy'){Gtk.main_quit}

at any point after the creation of the dialog and it should work.

I hope this helps

Stefano
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top