def add_menus(self): menubar = QtGui.QMenuBar() self.w.mframe.addWidget(menubar, stretch=0) # create a File pulldown menu, and add it to the menu bar filemenu = menubar.addMenu("File") item = QtGui.QAction("Load Image", menubar) item.triggered.connect(self.gui_load_file) filemenu.addAction(item) item = QtGui.QAction("Save image as PNG", menubar) item.triggered.connect( lambda: self.save_file('/tmp/fitsimage.png', 'png')) filemenu.addAction(item) sep = QtGui.QAction(menubar) sep.setSeparator(True) filemenu.addAction(sep) item = QtGui.QAction("Quit", menubar) item.triggered.connect(self.windowClose) filemenu.addAction(item) # create a Channel pulldown menu, and add it to the menu bar chmenu = menubar.addMenu("Channel") item = QtGui.QAction("Add Channel", menubar) item.triggered.connect(self.gui_add_channel) chmenu.addAction(item) item = QtGui.QAction("Delete Channel", menubar) item.triggered.connect(self.gui_delete_channel) chmenu.addAction(item) # create a Window pulldown menu, and add it to the menu bar winmenu = menubar.addMenu("Window") item = QtGui.QAction("New Workspace", menubar) item.triggered.connect(self.gui_add_ws) winmenu.addAction(item) # # create a Option pulldown menu, and add it to the menu bar # optionmenu = menubar.addMenu("Option") # # create a Workspace pulldown menu, and add it to the menu bar # wsmenu = menubar.addMenu("Workspace") # item = QtGui.QAction("Panes as Tabs", menubar) # item.triggered.connect(self.tabstoggle_cb) # item.setCheckable(True) # # TODO: check the state of the workspace first # item.setChecked(True) # wsmenu.addAction(item) # item = QtGui.QAction("Tile Panes", menubar) # item.triggered.connect(self.tile_panes_cb) # wsmenu.addAction(item) # item = QtGui.QAction("Cascade Panes", menubar) # item.triggered.connect(self.cascade_panes_cb) # wsmenu.addAction(item) # create a Help pulldown menu, and add it to the menu bar helpmenu = menubar.addMenu("Help") item = QtGui.QAction("About", menubar) item.triggered.connect(self.banner) helpmenu.addAction(item)
def add_menus(self, holder): menubar = QtGui.QMenuBar() # NOTE: Special hack for Mac OS X, otherwise the menus # do not get added to the global OS X menu macos_ver = platform.mac_ver()[0] if len(macos_ver) > 0: self.w['top'].layout().addWidget(menubar, stretch=0) else: holder.layout().addWidget(menubar, stretch=1) # create a File pulldown menu, and add it to the menu bar filemenu = menubar.addMenu("File") item = QtGui.QAction("Load Image", menubar) item.triggered.connect(self.gui_load_file) filemenu.addAction(item) sep = QtGui.QAction(menubar) sep.setSeparator(True) filemenu.addAction(sep) item = QtGui.QAction("Quit", menubar) item.triggered.connect(self.windowClose) filemenu.addAction(item) # create a Channel pulldown menu, and add it to the menu bar chmenu = menubar.addMenu("Channel") item = QtGui.QAction("Add Channel", menubar) item.triggered.connect(self.gui_add_channel) chmenu.addAction(item) item = QtGui.QAction("Add Channels", menubar) item.triggered.connect(self.gui_add_channels) chmenu.addAction(item) item = QtGui.QAction("Delete Channel", menubar) item.triggered.connect(self.gui_delete_channel) chmenu.addAction(item) # create a Window pulldown menu, and add it to the menu bar winmenu = menubar.addMenu("Workspace") item = QtGui.QAction("Add Workspace", menubar) item.triggered.connect(self.gui_add_ws) winmenu.addAction(item) # # create a Option pulldown menu, and add it to the menu bar # optionmenu = menubar.addMenu("Option") ## # create a Workspace pulldown menu, and add it to the menu bar ## wsmenu = menubar.addMenu("Workspace") ## item = QtGui.QAction("Panes as Tabs", menubar) ## item.triggered.connect(self.tabstoggle_cb) ## item.setCheckable(True) ## # TODO: check the state of the workspace first ## item.setChecked(True) ## wsmenu.addAction(item) ## item = QtGui.QAction("Tile Panes", menubar) ## item.triggered.connect(self.tile_panes_cb) ## wsmenu.addAction(item) ## item = QtGui.QAction("Cascade Panes", menubar) ## item.triggered.connect(self.cascade_panes_cb) ## wsmenu.addAction(item) # create a Plugins pulldown menu, and add it to the menu bar plugmenu = menubar.addMenu("Plugins") self.w.menu_plug = plugmenu # create a Help pulldown menu, and add it to the menu bar helpmenu = menubar.addMenu("Help") item = QtGui.QAction("About", menubar) item.triggered.connect(lambda: self.banner(raiseTab=True)) helpmenu.addAction(item) item = QtGui.QAction("Documentation", menubar) item.triggered.connect(lambda: self.help()) helpmenu.addAction(item) return menubar