Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > gtk interface (with glade) don't wanna run

Reply
Thread Tools

gtk interface (with glade) don't wanna run

 
 
Mathspeedy
Guest
Posts: n/a
 
      06-25-2009
Hi all, well I'm not really good with User interface, and I decided to
make one for this little program:

Code:
#!/usr/bin/ruby

class Programming_menu
#show a menu offering programming utilities
def show_menu()
puts "1. gedit (Text Editor...) **"
puts "2. Glade 3 (Interface designer) **"
puts "3. Terminal"
puts "4. IRB (interactive ruby)"
puts "5. Blender (3D modeler) **"
puts "6. Gimp (2D editor) **"
puts "7. GTKRadiant (Game map editor) **"
puts "8. Dia (diagram designer) **"
puts "9. Hex editor **"
puts "10. TOP (app monitor)"
puts "11. EXIT (please read the advertisement)"
puts "-=====================================-"
puts "if app return infos just press ENTER"
puts "EXITING this program will exit ** apps"
puts "-=====================================-"
end
#ask for the choice
def choice()
puts "Please enter the number of the wanted app."
choice = gets.to_i
if choice == 1
system("gedit &")
elsif choice == 2
system("glade-3 &")
elsif choice == 3
system("gnome-terminal")
elsif choice == 4
system("gnome-terminal -e irb")
elsif choice == 5
system("blender &")
elsif choice == 6
system("gimp &")
elsif choice == 7
system("/opt/gtkradiant/radiant.x86 &")
elsif choice == 8
system("dia &")
elsif choice == 9
system("ghex2 &")
elsif choice == 10
system("gnome-terminal -e top")
elsif choice == 11
break
end
end

#main process.

pc = Programming_menu.new
pc.show_menu()
pc.choice()
loop do
system("clear")
pc.show_menu()
pc.choice()
end
end
and this is the code with GUI
Code:
#!/usr/bin/ ruby
require 'libglade2'

class GpumGlade
include GetText

attr :glade

def initialize(path_or_data, root = nil, domain = nil, localedir =
nil, flag = GladeXML::FILE)
bindtextdomain(domain, localedir, nil, "UTF-8")
@glade = GladeXML.new(path_or_data, root, domain, localedir, flag)
{|handler| method(handler)}

end

def on_gimp_button_clicked(widget)
puts "on_gimp_button_clicked() is not implemented yet."
end
def on_window_delete_event(widget, arg0)
Gtk.main_quit
end
def on_gedit_button_clicked(widget)
system("gedit &")
end
def on_irb_button_clicked(widget)
system("gnome-terminal -e irb &")
end
def on_term_button_clicked(widget)
system("gnome-terminal &")
end
def on_top_button_clicked(widget)
system("gnome-terminal -e top &")
end
def on_blender_button_clicked(widget)
system("blender &")
end
def on_dia_button_clicked(widget)
system("dia &")
end
def on_glade_button_clicked(widget)
system("glade-3 &")
end
def on_radiant_button_clicked(widget)
system("/opt/gtkradiant/radiant.x86 &")
end
def on_hex_button_clicked(widget)
system("ghex2 &")
end
end

# Main program
if __FILE__ == $0
# Set values as your own application.
PROG_PATH = "GPUM.glade"
PROG_NAME = "YOUR_APPLICATION_NAME"
GpumGlade.new(PROG_PATH, nil, PROG_NAME)
Gtk.main
end
Can someone could tell me why it is not working ...
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ruby GTK Fortune Cookies (gtk-fortune-0.1.1) Alex Shulgin Ruby 1 11-21-2007 01:05 AM
GTK+, segmentation fault in gtK-editable_get_chars zombek@gmail.com C Programming 2 05-29-2007 03:27 PM
User Interface Designer for GTK+ and GNOME Felipe Ureta Ruby 3 08-21-2006 12:27 AM
freeze.py builds, but binary doesn't even run locally (shared GTK problem?) kristian.hermansen@gmail.com Python 1 04-08-2006 09:58 AM
compiling ruby under windows (+ gtk stuff, is the gtk list dead?) Gergely Kontra Ruby 2 06-18-2004 10:20 PM



Advertisments