How running GTK for a beginner?

Hello guys :slight_smile:

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 :slight_smile:

Thanx you.

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs