[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Gtk not work

Pokkai Dokkai

10/1/2007 7:32:00 AM

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
--
Posted via http://www.ruby-....

3 Answers

Pokkai Dokkai

10/1/2007 7:35:00 AM

0

sorry i did't tell my problem

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

--
Posted via http://www.ruby-....

Stefano Crocco

10/1/2007 7:44:00 AM

0

Alle lunedì 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 = 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
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 the
button or using the close button on the dialog's frame) doesn't quit your
application, as it is now. To do so, you should connect the dialog destroy
signal with the method Gtk.main_quit: in the method quick_message, add the
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

Pokkai Dokkai

10/1/2007 8:32:00 AM

0



yes i got it....

thank you Stefano
--
Posted via http://www.ruby-....