# Gtk not work

**URL:** <https://www.ruby-forum.com/t/gtk-not-work/115982>\
**Category:** Ruby\
**Created:** [October 1, 2007, 9:32am UTC](https://www.ruby-forum.com/t/gtk-not-work/115982 "2007-10-01T09:32:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [October 1, 2007, 9:32am UTC](https://www.ruby-forum.com/t/gtk-not-work/115982/1 "2007-10-01T09:32:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [October 1, 2007, 9:35am UTC](https://www.ruby-forum.com/t/gtk-not-work/115982/2 "2007-10-01T09:35:13Z")

</div>

sorry i did’t tell my problem

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

---

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [October 1, 2007, 9:45am UTC](https://www.ruby-forum.com/t/gtk-not-work/115982/3 "2007-10-01T09:45:04Z")

</div>

Alle lunedÃ¬ 1 ottobre 2007, Pokkai D. ha scritto:

> require “gtk2”  
> # Add the message in a label, and show everything we’ve added to the
> 
> 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

---

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [October 1, 2007, 10:31am UTC](https://www.ruby-forum.com/t/gtk-not-work/115982/4 "2007-10-01T10:31:59Z")

</div>

yes i got it…

thank you Stefano
