# How running GTK for a beginner?

**URL:** <https://www.ruby-forum.com/t/how-running-gtk-for-a-beginner/222282>\
**Category:** Ruby-Gnome 2\
**Created:** [August 21, 2012, 1:23pm UTC](https://www.ruby-forum.com/t/how-running-gtk-for-a-beginner/222282 "2012-08-21T13:23:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [August 21, 2012, 1:23pm UTC](https://www.ruby-forum.com/t/how-running-gtk-for-a-beginner/222282/1 "2012-08-21T13:23:13Z")

</div>

Hello guys 🙂

Im learning GTK and im doing ruby project with GTK2 so how to use GTK2  
with my ruby script?

I create windows for the user but when the user cliked on the buttom i  
would like the result appear in the same GTK windows.  
For example this is a part of my script which work fine without GTK in a  
simply shell:

def menu  
puts “ ~~~~~~~~~~~~~~~~~~ 0 - start”  
puts “ ~~~~~~~~~~~~~~~~~~ 1 - see”  
puts “ ~~~~~~~~~~~~~~~~~~ 2 - take”  
puts “ ~~~~~~~~~~~~~~~~~~ 3 - more?”  
puts “ ~~~~~~~~~~~~~~~~~~ 4 - Convert GIF to PNG”  
puts “ ~~~~~~~~~~~~~~~~~~ 5 -Convert PNG to GIF”  
puts “ ~~~~~~~~~~~~~~~~~~ 6 - Choose mor options”  
end  
menu  
opt=""  
while (opt!=“0” && opt!=“1” && opt!=“2” && opt!=“3” && opt!=“4” &&  
opt!=“5” && opt!=“6”)  
puts “Choose your option (between 0 et 6)”  
opt=gets.chomp  
end

So now i would like to have six windows in GTK2 for the user wich using  
“gets.chomp” or another like this to save the user option and starting  
it.

I don’t know start a command of the script with GTK.So help me please im  
beginner 🙂

Thanx you.

---

<div class="post-metadata">

**Author:** ![revlob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c77e96/32.png) [@revlob](https://www.ruby-forum.com/u/revlob)\
**Post date:** [August 24, 2012, 8:38pm UTC](https://www.ruby-forum.com/t/how-running-gtk-for-a-beginner/222282/2 "2012-08-24T20:38:57Z")

</div>

Download the official source.

In ruby-gnome look at gtk2/ directory

there is a sample/ subdirectory.

You will find a few hundred different .rb files in total

I learned a lot from studying them.

You should look through them and run them. Then you know what ruby-gnome  
can do for you.

To your question:

“I don’t know start a command of the script with GTK.”

First, make a simple layout of what you need.

Then use specific widgets.

In your example, you could use a Gtk::Table and buttons into  
that table.
