"Christmas - the time to fix the computers of your loved ones" « Lord Wyrm

Ruby + Gtk2 -> Menü sitzt falsch

moidaschl 14.04.2006 - 18:43 572 2
Posts

moidaschl

Vollzeit-Hackler
Avatar
Registered: Aug 2002
Location: 1210, ABK-D/L
Posts: 4029
Ich habe mit gtk2 ein menü erstellt und das ganze in eine vbox gepackt, aber ich hab keine ahnung warum das menü nicht ganz links sitzt wie es soll !?

Anbei der Code (etwas länger). Wenn ich jetzt einen button in die vbox werfe, geht dieser allerdings bis ans ende.

Code:
class Ndc < Window

    def initialize
        super       
   
    self.title = Info.name + " - v" + Info.version      # Windowtitle
    self.set_size_request(800, 600)     # Windowsize
   
   
    mainvbox = VBox.new(false, 0)     # The Vbox between the Main Stuff and the Menue at the top
    menubar = MenuBar.new
    mainvbox.pack_start(menubar, false, false, 0)
    # Create the Menu-Bars
    filemenubar = MenuItem.new("_File", true)
    viewmenubar = MenuItem.new("_View", true)
    helpmenubar = MenuItem.new("_Help", true)
    # Append the Menue-Bars
    menubar.append(filemenubar) # "File"
    menubar.append(viewmenubar) # "View"
    menubar.append(helpmenubar) # "Help"
    # Create the Menues
    filemenu = Menu.new
    viewmenu = Menu.new
    helpmenu = Menu.new
    # Create the Submenues
     # (1) Filemenu
     filemenu_connect = MenuItem.new("_Connect", true)
     filemenu_disconnect = MenuItem.new("_Disconnect", true)
     filemenu_savelog = MenuItem.new("Save _Log", true)
     filemenu_settings = MenuItem.new("_Settings", true)
     filemenu_quit = MenuItem.new("_Quit", true)
     # (2) Viewmenu
     viewmenu_overview = MenuItem.new("_Overview", true)
     viewmenu_statistics = MenuItem.new("_Statistics", true)
     viewmenu_terminal = MenuItem.new("_Terminal", true)
     # (3) Helpmenu
     helpmenu_help = MenuItem.new("_Help", true)
     helpmenu_about = MenuItem.new("_About", true)
    # Set the names, so we can identify them later
     # (1) Filemenu
     filemenu_connect.set_name("filemenu_connect")
     filemenu_disconnect.set_name("filemenu_disconnect")
     filemenu_savelog.set_name("filemenu_savelog")
     filemenu_settings.set_name("filemenu_settings")
     filemenu_quit.set_name("filemenu_quit")
     # (2) Viewmenu
     viewmenu_overview.set_name("viewmenu_overview")
     viewmenu_statistics.set_name("viewmenu_statistics")
     viewmenu_terminal.set_name("viewmenu_terminal")
     # (3) Helpmenu
     helpmenu_help.set_name("helpmenu_help")
     helpmenu_about.set_name("helpmenu_about")
    # Append the submenues to the menues
     # (1) Filemenu
     filemenu.append(filemenu_connect)
     filemenu.append(filemenu_disconnect)
     filemenu.append(filemenu_savelog)
     filemenu.append(filemenu_settings)
     filemenu.append(SeparatorMenuItem.new) # Separator
     filemenu.append(filemenu_quit)
     # (2) Viewmenu
     viewmenu.append(viewmenu_overview)
     viewmenu.append(viewmenu_statistics)
     viewmenu.append(viewmenu_terminal)
     # (3) Helpmenu
     helpmenu.append(helpmenu_help)
     helpmenu.append(helpmenu_about)
    # Append the Menues to the Menubar
    filemenubar.set_submenu(filemenu)
    viewmenubar.set_submenu(viewmenu)
    helpmenubar.set_submenu(helpmenu)
    # Append the Bars to the Menu itself
    menubar.append(filemenubar)
    menubar.append(viewmenubar)
    menubar.append(helpmenubar)
   
   
    # Add the Main Vbox
    self.add(mainvbox)
        self.show_all     # Show The Main Window
    end

end 

Anbei das Foto zur veranschaulichung
click to enlarge

mfg & tia
daschl
Bearbeitet von moidaschl am 15.04.2006, 11:50

Luzandro

OC Addicted
Avatar
Registered: Mar 2006
Location: 2482
Posts: 708
was für mich falsch aussieht, ist dass du diesen Abschnitt doppelt hast:
Code:
    
    menubar.append(filemenubar)
    menubar.append(viewmenubar)
    menubar.append(helpmenubar)

moidaschl

Vollzeit-Hackler
Avatar
Registered: Aug 2002
Location: 1210, ABK-D/L
Posts: 4029
Zitat von Luzandro
was für mich falsch aussieht, ist dass du diesen Abschnitt doppelt hast:
Code:
    
    menubar.append(filemenubar)
    menubar.append(viewmenubar)
    menubar.append(helpmenubar)

:eek: funktioniert! hab ich das doch glatt doppelt gemacht!

vielen danke :)
Kontakt | Unser Forum | Über overclockers.at | Impressum | Datenschutz