gtk interface (with glade) don't wanna run

Discussion in 'Ruby' started by Mathspeedy, Jun 25, 2009.

  1. Mathspeedy

    Mathspeedy Guest

    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 ...
    Mathspeedy, Jun 25, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave Walker

    Problems with pygtk/gtk.glade

    Dave Walker, Jul 22, 2004, in forum: Python
    Replies:
    1
    Views:
    348
    Haim Ashkenazi
    Jul 22, 2004
  2. Sridhar  R

    Re: Problems with pygtk/gtk.glade

    Sridhar R, Jul 23, 2004, in forum: Python
    Replies:
    1
    Views:
    327
    Dave Walker
    Jul 23, 2004
  3. John Doe

    looking for gtk.glade documenation

    John Doe, Nov 5, 2004, in forum: Python
    Replies:
    2
    Views:
    317
    Francesco Bochicchio
    Nov 6, 2004
  4. lkcl
    Replies:
    0
    Views:
    600
  5. Patrick Spence
    Replies:
    2
    Views:
    178
    Patrick Spence
    Nov 17, 2006
Loading...

Share This Page