当前位置: 首页>>代码示例>>Python>>正文


Python QMenuBar.addMenu方法代码示例

本文整理汇总了Python中PyQt4.QtGui.QMenuBar.addMenu方法的典型用法代码示例。如果您正苦于以下问题:Python QMenuBar.addMenu方法的具体用法?Python QMenuBar.addMenu怎么用?Python QMenuBar.addMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtGui.QMenuBar的用法示例。


在下文中一共展示了QMenuBar.addMenu方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: BaseFenetrePrinc

# 需要导入模块: from PyQt4.QtGui import QMenuBar [as 别名]
# 或者: from PyQt4.QtGui.QMenuBar import addMenu [as 别名]
class BaseFenetrePrinc(QMainWindow):
    """ Classe BaseFenetrePrinc

    Cette classe définit les widgets contenus dans la fenetre principale de
    PyFt. Elle est héritée par fen.FenetrePrinc.
    """

    def __init__(self, parent=None):
        """ Fait des initialisations """
        super(BaseFenetrePrinc, self).__init__(parent)
        self.resize(800, 600)
        self.setWindowTitle('PyFt - 0.1')

        # barre de menu
        self.menuBar = QMenuBar()
        self.mFic = QMenu('Fichier')

        self.a_quit = QAction('Quitter', self)

        self.menuBar.addMenu(self.mFic)
        self.setMenuBar(self.menuBar)

        # zone centrale
        self.mdi = QMdiArea()
        self.setCentralWidget(self.mdi)
开发者ID:Calmacil,项目名称:python-FullThrust,代码行数:27,代码来源:base_fenetre_princ.py

示例2: menubar

# 需要导入模块: from PyQt4.QtGui import QMenuBar [as 别名]
# 或者: from PyQt4.QtGui.QMenuBar import addMenu [as 别名]
def menubar():
    """Return a newly created parent-less menu bar that's used when there is no main window."""
    m = QMenuBar()
    m.addMenu(menu_file(m))
    m.addMenu(menu_edit(m))
    m.addMenu(menu_window(m))
    m.addMenu(menu_sessions(m))
    m.addMenu(menu_help(m))
    return m
开发者ID:EdwardBetts,项目名称:frescobaldi,代码行数:11,代码来源:globalmenu.py

示例3: __init__

# 需要导入模块: from PyQt4.QtGui import QMenuBar [as 别名]
# 或者: from PyQt4.QtGui.QMenuBar import addMenu [as 别名]
    def __init__(self, config):
        # Initialize the object as a QWidget and
        # set its title and minimum width

        QWidget.__init__(self)

        self.config = config
        self.peerList = config.peerList
        self.setWindowTitle('BlastShare')
        self.setMinimumSize(320, 480)
        self.setMaximumWidth(320)
        self.prefw = None
        
        # connects the signals!
        self.connect(self.peerList,
                     SIGNAL("initTransfer"), self.sendFileToPeer)

        ''' Will add feature in future version '''
        '''
        shareFilesAction = QAction(QIcon('exit.png'), '&Share File(s)', self)
        shareFilesAction.setShortcut('Ctrl+O')
        shareFilesAction.setStatusTip('Share File(s)')
        shareFilesAction.triggered.connect(quitApp)
        '''
        
        preferencesAction = QAction(QIcon('exit.png'), '&Preferences', self)
        preferencesAction.setShortcut('Ctrl+P')
        preferencesAction.setStatusTip('Preferences')
        preferencesAction.triggered.connect(self.editPreferences)

        exitAction = QAction(QIcon('exit.png'), '&Exit', self)
        exitAction.setShortcut('Ctrl+Q')
        exitAction.setStatusTip('Exit application')
        exitAction.triggered.connect(quitApp)

        menubar = QMenuBar()
        fileMenu = menubar.addMenu('&File')
        
        ''' Will enable in future versions '''
        # fileMenu.addAction(shareFilesAction)
        
        fileMenu.addAction(preferencesAction)
        fileMenu.addAction(exitAction)

        layout = QVBoxLayout()
        layout.setContentsMargins(QMargins(0, 0, 0, 0))
        self.setLayout(layout)
        
        statusBar = QStatusBar()
        statusBar.showMessage('Ready')
        
        layout.addWidget(menubar)
        layout.addWidget(self.peerList)
        layout.addWidget(statusBar)
开发者ID:arminhammer,项目名称:teiler,代码行数:56,代码来源:teiler.py

示例4: create_menu_bar

# 需要导入模块: from PyQt4.QtGui import QMenuBar [as 别名]
# 或者: from PyQt4.QtGui.QMenuBar import addMenu [as 别名]
    def create_menu_bar ( self, parent, controller = None ):
        """ Creates a menu bar representation of the manager.
        """
        # If a controller is required it can either be set as a facet on the
        # menu bar manager (the facet is part of the 'ActionManager' API), or
        # passed in here (if one is passed in here it takes precedence over the
        # facet).
        if controller is None:
            controller = self.controller

        menu_bar = QMenuBar( parent )

        # Every item in every group must be a menu manager:
        for group in self.groups:
            for item in group.items:
                menu = item.create_menu( parent, controller )
                menu.menuAction().setText( item.name )
                menu_bar.addMenu( menu )

        return menu_bar

#-- EOF ------------------------------------------------------------------------
开发者ID:davidmorrill,项目名称:facets,代码行数:24,代码来源:menu_bar_manager.py

示例5: initMenuBar

# 需要导入模块: from PyQt4.QtGui import QMenuBar [as 别名]
# 或者: from PyQt4.QtGui.QMenuBar import addMenu [as 别名]
 def initMenuBar(self):
     menuBar = QMenuBar()
     file = menuBar.addMenu("&File")
     quit = file.addAction("&Quit", QApplication.instance().quit)
     quit.setShortcutContext(Qt.ApplicationShortcut)
     quit.setShortcut(QKeySequence.Quit)
     self.changeName = QAction("Change Name", self, triggered=self.__changeName)
     self.changeColor = QAction("Change Color", self, triggered=self.__changeColor)
     self.cashCards = QAction("Cash in Cards", self, enabled=False, triggered=self.__cashCards)
     self.endAttack = QAction("End Attack", self, enabled=False, triggered=self.endAttackReleased)
     self.endTurn = QAction("End Turn", self, enabled=False, triggered=self.endTurnReleased)
     menuBar.addAction(self.changeName)
     menuBar.addAction(self.changeColor)
     menuBar.addAction(self.cashCards)
     menuBar.addAction(self.endAttack)
     menuBar.addAction(self.endTurn)
     self.setMenuBar(menuBar)
开发者ID:dhrosa,项目名称:empyre_old,代码行数:19,代码来源:mainwindow.py

示例6: MainWindow

# 需要导入模块: from PyQt4.QtGui import QMenuBar [as 别名]
# 或者: from PyQt4.QtGui.QMenuBar import addMenu [as 别名]
class MainWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
        
        self.menubar = QMenuBar()
        file_ = self.menubar.addMenu(u"&Fichier")
        exit = QAction(u"Quitter", self)
        exit.setShortcut("Ctrl+Q")
        exit.setToolTip("Quitter l'application")
        self.menubar.connect(exit, SIGNAL("triggered()"), \
                                         self, \
                                         SLOT("close()"))

        file_.addAction(exit)
        self.setMenuBar(self.menubar)
        self.web = QWebView()
        self.web.load(QUrl(APP_URL))
        self.setCentralWidget(self.web)
    
    def goto(self, url):
        self.web.load(QUrl(url))
开发者ID:fadiga,项目名称:site_gestion_stock,代码行数:23,代码来源:gestock.py

示例7: MainWindow

# 需要导入模块: from PyQt4.QtGui import QMenuBar [as 别名]
# 或者: from PyQt4.QtGui.QMenuBar import addMenu [as 别名]
class MainWindow(QMainWindow):

    def __init__(self, app, radarwidget):
        super(MainWindow, self).__init__()
        self.app = app
        uic.loadUi("./data/graphics/mainwindow.ui", self)

        # list of buttons to connect to, give icons, and tooltips
        #           the button         the icon      the tooltip    the callback
        buttons = { self.zoomin  :    ['zoomin.svg', 'Zoom in', self.buttonClicked],
                    self.zoomout :    ['zoomout.svg', 'Zoom out', self.buttonClicked],
                    self.panleft :    ['panleft.svg', 'Pan left', self.buttonClicked],
                    self.panright :   ['panright.svg', 'Pan right', self.buttonClicked],
                    self.panup :      ['panup.svg', 'Pan up', self.buttonClicked],
                    self.pandown :    ['pandown.svg', 'Pan down', self.buttonClicked],
                    self.ic :         ['stop.svg', 'Initial condition', self.buttonClicked],
                    self.op :         ['play.svg', 'Operate', self.buttonClicked],
                    self.hold :       ['pause.svg', 'Hold', self.buttonClicked],
                    self.fast :       ['fwd.svg', 'Enable fast-time', self.buttonClicked],
                    self.fast10 :     ['ffwd.svg', 'Fast-forward 10 seconds', self.buttonClicked],
                    self.sameic :     ['frwd.svg', 'Restart same IC', self.buttonClicked],
                    self.showac :     ['AC.svg', 'Show/hide aircraft', self.buttonClicked],
                    self.showpz :     ['PZ.svg', 'Show/hide PZ', self.buttonClicked],
                    self.showapt :    ['apt.svg', 'Show/hide airports', self.buttonClicked],
                    self.showwpt :    ['wpt.svg', 'Show/hide waypoints', self.buttonClicked],
                    self.showlabels : ['lbl.svg', 'Show/hide text labels', self.buttonClicked],
                    self.showmap :    ['geo.svg', 'Show/hide satellite image', self.buttonClicked]}

        for b in buttons.iteritems():
            # Set icon
            if not b[1][0] is None:
                b[0].setIcon(QIcon('data/graphics/icons/' + b[1][0]))
            # Set tooltip
            if not b[1][1] is None:
                b[0].setToolTip(b[1][1])
            # Connect clicked signal
            b[0].clicked.connect(b[1][2])

        self.menubar = QMenuBar(self)

        # File menu
        self.fileMenu = self.menubar.addMenu('&File')
        self.open_action = self.fileMenu.addAction('&Open')
        self.open_action.triggered.connect(self.app.show_file_dialog)
        self.save_action = self.fileMenu.addAction('&Save')

        # View Menu
        self.viewMenu = self.menubar.addMenu('&View')
        self.resetview_action = self.viewMenu.addAction('&Reset view')
        self.fullscreen_action = self.viewMenu.addAction('Fullscreen')

        # Analysis and metrics menu
        self.analysisMenu = self.menubar.addMenu('&Analysis')
        self.SD_action = self.analysisMenu.addAction('Static Density')
        self.DD_action = self.analysisMenu.addAction('Dynamic Density')
        self.SSD_action = self.analysisMenu.addAction('SSD Metric')
        self.lyu_action = self.analysisMenu.addAction('Lyapunov analysis')

        # Connections menu
        self.connectionsMenu = self.menubar.addMenu('Connections')
        self.connectionsMenu.addAction('Connect to ADS-B server')
        self.connectionsMenu.addAction('Enable output to UDP')

        self.setMenuBar(self.menubar)

        self.radarwidget = radarwidget
        radarwidget.setParent(self.centralwidget)
        self.verticalLayout.insertWidget(0, radarwidget, 1)

    @pyqtSlot()
    def buttonClicked(self):
        if self.sender() == self.zoomin:
            self.app.notify(self.app, PanZoomEvent(zoom=1.4142135623730951))
        elif self.sender() == self.zoomout:
            self.app.notify(self.app, PanZoomEvent(zoom=0.70710678118654746))
        elif self.sender() == self.pandown:
            self.app.notify(self.app, PanZoomEvent(pan=(-0.5,  0.0)))
        elif self.sender() == self.panup:
            self.app.notify(self.app, PanZoomEvent(pan=( 0.5,  0.0)))
        elif self.sender() == self.panleft:
            self.app.notify(self.app, PanZoomEvent(pan=( 0.0, -0.5)))
        elif self.sender() == self.panright:
            self.app.notify(self.app, PanZoomEvent(pan=( 0.0,  0.5)))
        elif self.sender() == self.ic:
            self.app.show_file_dialog()
        elif self.sender() == self.sameic:
            self.app.stack('IC IC')
        elif self.sender() == self.hold:
            self.app.stack('HOLD')
        elif self.sender() == self.op:
            self.app.stack('OP')
        elif self.sender() == self.fast:
            print('Fast clicked')
        elif self.sender() == self.fast10:
            self.app.stack('RUNFT')
        elif self.sender() == self.showac:
            self.radarwidget.show_traf = not self.radarwidget.show_traf
        elif self.sender() == self.showpz:
            self.radarwidget.show_pz = not self.radarwidget.show_pz
        elif self.sender() == self.showapt:
#.........这里部分代码省略.........
开发者ID:espinielli,项目名称:bluesky,代码行数:103,代码来源:mainwindow.py

示例8: setupMainWindow

# 需要导入模块: from PyQt4.QtGui import QMenuBar [as 别名]
# 或者: from PyQt4.QtGui.QMenuBar import addMenu [as 别名]
    def setupMainWindow(self):
        self.resize(800, 600)
        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((
            screen.width()-size.width())/2, (screen.height()-size.height())/2)
        self.setWindowTitle(
            '{} - {}'.format(self.settings.notebookName, __appname__))

        self.viewedList.setFixedHeight(25)
        self.noteSplitter.addWidget(self.notesEdit)
        self.noteSplitter.addWidget(self.notesView)
        mainSplitter = QSplitter(Qt.Vertical)
        mainSplitter.setChildrenCollapsible(False)
        mainSplitter.addWidget(self.viewedList)
        mainSplitter.addWidget(self.noteSplitter)
        mainSplitter.addWidget(self.findBar)
        self.setCentralWidget(mainSplitter)

        self.searchEdit.returnPressed.connect(self.searchNote)
        self.quickNoteNav.returnPressed.connect(self.openFuncWrapper)
        searchLayout = QVBoxLayout()
        searchLayout.addWidget(self.searchEdit)
        searchLayout.addWidget(self.searchView)
        self.searchTab.setLayout(searchLayout)
        self.tocTree.header().close()

        indexLayout = QVBoxLayout(self.notesTab)
        indexLayout.addWidget(self.quickNoteNav)
        indexLayout.addWidget(self.notesTree)

        self.dockIndex.setObjectName("Index")
        self.dockIndex.setWidget(self.notesTab)
        self.dockSearch.setObjectName("Search")
        self.dockSearch.setWidget(self.searchTab)
        self.dockToc.setObjectName("TOC")
        self.dockToc.setWidget(self.tocTree)
        self.dockAttachment.setObjectName("Attachment")
        self.dockAttachment.setWidget(self.attachmentView)

        self.setDockOptions(QMainWindow.VerticalTabs)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.dockIndex)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.dockSearch)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.dockToc)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.dockAttachment)
        self.tabifyDockWidget(self.dockIndex, self.dockSearch)
        self.tabifyDockWidget(self.dockSearch, self.dockToc)
        self.tabifyDockWidget(self.dockToc, self.dockAttachment)
        self.setTabPosition(Qt.LeftDockWidgetArea, QTabWidget.North)
        self.dockIndex.raise_()      # Put dockIndex on top of the tab stack

        menuBar = QMenuBar(self)
        self.setMenuBar(menuBar)
        menuFile = menuBar.addMenu(self.tr('&File'))
        menuEdit = menuBar.addMenu(self.tr('&Edit'))
        menuView = menuBar.addMenu(self.tr('&View'))
        menuHelp = menuBar.addMenu(self.tr('&Help'))
        # menuFile
        menuFile.addAction(self.actions['newPage'])
        menuFile.addAction(self.actions['newSubpage'])
        menuFile.addAction(self.actions['NBSettings'])
        menuFile.addAction(self.actions['MDSettings'])
        menuFile.addAction(self.actions['importPage'])
        menuFile.addAction(self.actions['openNotebook'])
        menuFile.addAction(self.actions['reIndex'])
        menuFile.addSeparator()
        menuFile.addAction(self.actions['save'])
        menuFile.addAction(self.actions['saveAs'])
        menuFile.addAction(self.actions['print_'])
        menuExport = menuFile.addMenu(self.tr('&Export'))
        menuExport.addAction(self.actions['html'])
        menuFile.addSeparator()
        menuFile.addAction(self.actions['renamePage'])
        menuFile.addAction(self.actions['delPage'])
        menuFile.addSeparator()
        menuFile.addAction(self.actions['quit'])
        # menuEdit
        menuEdit.addAction(self.actions['undo'])
        menuEdit.addAction(self.actions['redo'])
        menuEdit.addAction(self.actions['findText'])
        menuEdit.addSeparator()
        menuEdit.addAction(self.actions['sortLines'])
        menuEdit.addAction(self.actions['insertImage'])
        # menuView
        menuView.addAction(self.actions['edit'])
        menuView.addAction(self.actions['split'])
        menuView.addAction(self.actions['flipEditAndView'])
        menuShowHide = menuView.addMenu(self.tr('Show/Hide'))
        menuShowHide.addAction(self.dockIndex.toggleViewAction())
        menuShowHide.addAction(self.dockSearch.toggleViewAction())
        menuShowHide.addAction(self.dockToc.toggleViewAction())
        menuShowHide.addAction(self.dockAttachment.toggleViewAction())
        #menuMode = menuView.addMenu(self.tr('Mode'))
        #menuMode.addAction(self.actionLeftAndRight)
        #menuMode.addAction(self.actionUpAndDown)
        # menuHelp
        menuHelp.addAction(self.actions['readme'])
        menuHelp.addAction(self.actions['changelog'])
        menuHelp.addAction(self.actions['aboutQt'])

#.........这里部分代码省略.........
开发者ID:kissthink,项目名称:mikidown,代码行数:103,代码来源:mikiwindow.py

示例9: DBManager

# 需要导入模块: from PyQt4.QtGui import QMenuBar [as 别名]
# 或者: from PyQt4.QtGui.QMenuBar import addMenu [as 别名]

#.........这里部分代码省略.........

        if callback is not None:
            invoke_callback = lambda x: self.invokeCallback(callback)

        if menuName is None or menuName == "":
            self.addAction(action)

            if menuName not in self._registeredDbActions:
                self._registeredDbActions[menuName] = list()
            self._registeredDbActions[menuName].append(action)

            if callback is not None:
                QObject.connect(action, SIGNAL("triggered(bool)"), invoke_callback)
            return True

        # search for the menu
        actionMenu = None
        helpMenuAction = None
        for a in self.menuBar.actions():
            if not a.menu() or a.menu().title() != menuName:
                continue
            if a.menu() != self.menuHelp:
                helpMenuAction = a

            actionMenu = a
            break

        # not found, add a new menu before the help menu
        if actionMenu is None:
            menu = QMenu(menuName, self)
            if helpMenuAction is not None:
                actionMenu = self.menuBar.insertMenu(helpMenuAction, menu)
            else:
                actionMenu = self.menuBar.addMenu(menu)

        menu = actionMenu.menu()
        menuActions = menu.actions()

        # get the placeholder's position to insert before it
        pos = 0
        for pos in range(len(menuActions)):
            if menuActions[pos].isSeparator() and menuActions[pos].objectName().endswith("_placeholder"):
                menuActions[pos].setVisible(True)
                break

        if pos < len(menuActions):
            before = menuActions[pos]
            menu.insertAction(before, action)
        else:
            menu.addAction(action)

        actionMenu.setVisible(True)  # show the menu

        if menuName not in self._registeredDbActions:
            self._registeredDbActions[menuName] = list()
        self._registeredDbActions[menuName].append(action)

        if callback is not None:
            QObject.connect(action, SIGNAL("triggered(bool)"), invoke_callback)

        return True

    def invokeCallback(self, callback, *params):
        """ Call a method passing the selected item in the database tree,
                the sender (usually a QAction), the plugin mainWindow and
                optionally additional parameters.
开发者ID:jarped,项目名称:QGIS,代码行数:70,代码来源:db_manager.py

示例10: MainWindow

# 需要导入模块: from PyQt4.QtGui import QMenuBar [as 别名]
# 或者: from PyQt4.QtGui.QMenuBar import addMenu [as 别名]
class MainWindow(QMainWindow):
    """
    class MainWindow for the gui
    """

    def __init__(self, config, parent=None):
        """
        Constructor for class MainWindow
        :rtype : object
        :param parent: 
        @param config: iHike configuration
        """
        QMainWindow.__init__(self)
        self.config = config
        self.setGeometry(
            self.config.settings['app_x'],
            self.config.settings['app_y'],
            self.config.settings['app_w'],
            self.config.settings['app_h']
        )
        self.setWindowTitle(
            self.config.settings['appname'] +
            ' - Version: ' +
            self.config.settings['appversion']
        )
        globalFont = QFont(
            self.config.settings['fontfamily'],
            self.config.settings['pointsize']
        )
        self.statusbar = self.statusBar()
        self.center()

        self.exit = QAction('Quit iHike', self)
        self.menuLoadFile = QAction('Load File...', self)

        self.menubar = QMenuBar(None)
        self.file = self.menubar.addMenu('&File')
        self.file.addAction(self.exit)
        self.file.addAction(self.menuLoadFile)
        self.setMenuBar(self.menubar)

        self.save = QAction(QIcon('rsc/icons/fileSave.png'),
            'Save current page', self)
        self.save.setShortcut('Ctrl+S')
        self.save.setDisabled(True)
        self.search = QAction(QIcon('rsc/icons/magfit.png'), 'Search for',
            self)

        self.toolbar = self.addToolBar('Toolbar')
        self.toolbar.addAction(self.save)
        self.toolbar.addSeparator()
        self.toolbar.addAction(self.search)
        self.toolbar.setMaximumHeight(24)

        self.trackListView = TrackListView()
        self.trackListView.setAllowedAreas(Qt.TopDockWidgetArea |
                                           Qt.BottomDockWidgetArea)
        self.addDockWidget(Qt.TopDockWidgetArea, self.trackListView)
        detailView = DetailView()
        detailView.setAllowedAreas(
            Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
        self.addDockWidget(Qt.RightDockWidgetArea, detailView)

        self.mainWidget = QWidget(self)
        # self.mainWidget.setLayout(self.gridLayout)
        self.setCentralWidget(self.mainWidget)

    def center(self):
        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width() - size.width()) / 2,
            (screen.height() - size.height()) / 2)
开发者ID:johannes82,项目名称:iHike,代码行数:74,代码来源:MainWindow.py

示例11: MainWindow

# 需要导入模块: from PyQt4.QtGui import QMenuBar [as 别名]
# 或者: from PyQt4.QtGui.QMenuBar import addMenu [as 别名]
class MainWindow(QMainWindow):
    subWindows = []
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)

        self.setWindowTitle("Seabiscuit2")

        self.menuBar = QMenuBar()
        self.setMenuBar(self.menuBar)

        self.fileMenu = QMenu("&File")
        self.menuBar.addMenu(self.fileMenu)

        self.newWindowAction = QAction("&New Window", self)
        self.newWindowAction.setShortcut("Ctrl+N")
        self.newWindowAction.triggered.connect(self.newWindow)
        self.fileMenu.addAction(self.newWindowAction)

        self.editMenu = QMenu("&Edit")
        self.menuBar.addMenu(self.editMenu)

        self.toolsMenu = QMenu("&Tools")
        self.menuBar.addMenu(self.toolsMenu)

        self.historyAction = QAction("View &History", self)
        self.historyAction.setShortcut("Ctrl+H")
        self.historyAction.triggered.connect(self.loadHistory)
        self.toolsMenu.addAction(self.historyAction)

        self.clearHistoryAction = QAction("&Clear History", self)
        self.clearHistoryAction.setShortcut("Ctrl+Shift+Del")
        self.clearHistoryAction.triggered.connect(self.clearHistory)
        self.toolsMenu.addAction(self.clearHistoryAction)

        self.helpMenu = QMenu("&Help")
        self.menuBar.addMenu(self.helpMenu)

        self.readmeAction = QAction("View &README", self)
        self.readmeAction.setShortcut("F1")
        self.readmeAction.triggered.connect(self.loadReadme)
        self.helpMenu.addAction(self.readmeAction)

        self.aboutAction = QAction("&About Seabiscuit2", self)
        self.aboutAction.setShortcut("F2")
        self.aboutAction.triggered.connect(lambda: self.render("Seabiscuit version " + version + " (running on " + platform + ")"))
        self.helpMenu.addAction(self.aboutAction)

        self.toolBar = QToolBar()
        self.toolBar.setMovable(False)
        self.toolBar.setContextMenuPolicy(Qt.CustomContextMenu)
        self.addToolBar(self.toolBar)

        self.wv = QWebView()

        self.backAction = self.wv.pageAction(QWebPage.Back)
        self.backAction.setEnabled(True)
        self.backAction.setShortcut("Alt+Left")
        self.backAction.triggered.connect(lambda: self.mdiArea.currentSubWindow().widget().back())
        self.toolBar.addAction(self.backAction)

        self.forwardAction = self.wv.pageAction(QWebPage.Forward)
        self.forwardAction.setEnabled(True)
        self.forwardAction.setShortcut("Alt+Right")
        self.forwardAction.triggered.connect(lambda: self.mdiArea.currentSubWindow().widget().forward())
        self.toolBar.addAction(self.forwardAction)

        self.reloadAction = self.wv.pageAction(QWebPage.Reload)
        self.reloadAction.setShortcuts(["F5", "Ctrl+R"])
        self.reloadAction.triggered.connect(lambda: self.mdiArea.currentSubWindow().widget().reload())
        self.toolBar.addAction(self.reloadAction)

        self.locationBar = QLineEdit()
        self.locationBar.returnPressed.connect(self.loadCommand)
        self.toolBar.addWidget(self.locationBar)

        self.focusLocationBarAction = QAction(self)
        self.focusLocationBarAction.setShortcuts(["Ctrl+L", "Alt+D"])
        self.focusLocationBarAction.triggered.connect(self.locationBar.setFocus)
        self.focusLocationBarAction.triggered.connect(self.locationBar.selectAll)
        self.addAction(self.focusLocationBarAction)

        self.mdiArea = QMdiArea()
        self.setCentralWidget(self.mdiArea)

    def newWindow(self):
        s = SWebView(self)
        self.subWindows.append(s)
        self.mdiArea.addSubWindow(s)
        s.activateWindow()
        s.show()
        return s

    def loadHistory(self):
        self.newWindow()
        self.updateWeb(os.path.join(seabiscuit_home, "history.html"))

    def loadReadme(self):
        self.newWindow()
        self.updateWeb("file://" + os.path.join(sys.path[0], "README.html"))

#.........这里部分代码省略.........
开发者ID:foxhead128,项目名称:fh-miscellany,代码行数:103,代码来源:command-handler.py

示例12: init_widgets

# 需要导入模块: from PyQt4.QtGui import QMenuBar [as 别名]
# 或者: from PyQt4.QtGui.QMenuBar import addMenu [as 别名]
    def init_widgets(self):

        tabs = QTabWidget(self)
        tab1 = QWidget(self)
        tab2 = QWidget(self)

        menu_bar = QMenuBar(self)
        file_menu = menu_bar.addMenu('&File')

        open = QAction("Exit", self) 
        save = QAction("Save", self) 
        exit = QAction("Quit", self) 

        file_menu.addAction(open)
        file_menu.addAction(save)
        file_menu.addAction(exit)

        stream_labels = ['client ip', 'client port', 
                         'server ip', 'server port',
                         'protocol', 'created']

        # set up the stream tab
        self.streammodel = QStandardItemModel()
        self.streammodel.setHorizontalHeaderLabels(stream_labels)
        
        self.streamtable = StreamTableView(self)
        self.streamtable.setModel(self.streammodel)
        self.streamtable.setSelectionBehavior(QAbstractItemView.SelectRows)
        
        # create textedit area where traffic goes
        self.stream_dump = QTextEdit(self)

        # create buttons
        self.proxy_btn = QPushButton('Proxy Stopped')
        self.proxy_btn.setCheckable(True)
        self.proxy_btn.clicked[bool].connect(self.toggle_proxy)
        
        # add widgets to stream tab
        stream_tab = QVBoxLayout(tab1)
        stream_tab.addWidget(self.proxy_btn)
        stream_tab.addWidget(self.streamtable)
        stream_tab.addWidget(self.stream_dump)

        # create buttons and add them to hbox widget
        intercept_btn = QPushButton('Intercept', self)
        intercept_btn.setCheckable(True)
        intercept_btn.clicked[bool].connect(self.toggle_intercept)

        forward_btn = QPushButton('Forward', self)
        forward_btn.clicked[bool].connect(self.forward_traffic)

        drop_btn = QPushButton('Drop', self)
        drop_btn.clicked[bool].connect(self.drop_traffic)

        intercept_buttons = QHBoxLayout()
        intercept_buttons.addWidget(intercept_btn)
        intercept_buttons.addWidget(forward_btn)
        intercept_buttons.addWidget(drop_btn)

        # create textedit area where traffic goes
        self.intercept_dump = QTextEdit(self)

        # add widgets to stream tab
        intercept_tab = QVBoxLayout(tab2)
        intercept_tab.addLayout(intercept_buttons)
        intercept_tab.addWidget(self.intercept_dump)

        # add tabs to the tabs widget
        tabs.addTab(tab1, "Streams")
        tabs.addTab(tab2, "Intercept")

        main_layout = QVBoxLayout(self)
        main_layout.addWidget(menu_bar)
        main_layout.addWidget(tabs)

        self.setLayout(main_layout)
开发者ID:Zaidos,项目名称:Pyxie,代码行数:78,代码来源:gui.py

示例13: PeakMapExplorer

# 需要导入模块: from PyQt4.QtGui import QMenuBar [as 别名]
# 或者: from PyQt4.QtGui.QMenuBar import addMenu [as 别名]
class PeakMapExplorer(EmzedDialog):

    def __init__(self, ok_rows_container=[], parent=None):
        super(PeakMapExplorer, self).__init__(parent)
        self.setWindowFlags(Qt.Window)
        # Destroying the C++ object right after closing the dialog box,
        # otherwise it may be garbage-collected in another QThread
        # (e.g. the editor's analysis thread in Spyder), thus leading to
        # a segmentation fault on UNIX or an application crash on Windows
        self.ok_rows = ok_rows_container

        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowFlags(Qt.Window)

        self.gamma = 3.0

        self.last_used_directory_for_load = None
        self.last_used_directory_for_save = None

        self.history = History()

    def keyPressEvent(self, e):
        # avoid closing of dialog when Esc key pressed:
        if e.key() != Qt.Key_Escape:
            return super(PeakMapExplorer, self).keyPressEvent(e)

    def setWindowTitle(self):
        if self.peakmap2 is None:
            title = os.path.basename(self.peakmap.meta.get("source", ""))
        else:
            p1 = os.path.basename(self.peakmap.meta.get("source", ""))
            p2 = os.path.basename(self.peakmap2.meta.get("source", ""))
            title = "yellow=%s, blue=%s" % (p1, p2)
        super(PeakMapExplorer, self).setWindowTitle(title)

    def setup(self, peakmap, peakmap2=None, table=None):
        self.table = table

        def collect_precursor_mz(pm):
            for s in pm:
                if s.precursors:
                    if s.msLevel > 1:
                        yield s.precursors[0][0]

        self.ms_levels = set(peakmap.getMsLevels())
        self.precursor_mz = set(collect_precursor_mz(peakmap))
        if peakmap2 is not None:
            self.ms_levels &= set(peakmap2.getMsLevels())
            self.precursor_mz &= set(collect_precursor_mz(peakmap2))

        self.ms_levels = sorted(self.ms_levels)
        self.precursor_mz = sorted(self.precursor_mz)

        self.setup_table_widgets()
        self.setup_input_widgets()
        self.history_list = QComboBox(self)

        self.setup_ms2_widgets()
        self.full_pm = peakmap
        self.full_pm2 = peakmap2
        self.dual_mode = self.full_pm2 is not None

        self.current_ms_level = self.ms_levels[0]
        self.process_peakmap(self.current_ms_level)
        self.rtmin, self.rtmax, self.mzmin, self.mzmax = get_range(self.peakmap, self.peakmap2)

        self.setup_plot_widgets()
        self.setup_menu_bar()
        self.setup_layout()
        self.connect_signals_and_slots()
        self.setup_initial_values()
        self.plot_peakmap()

    def setup_ms2_widgets(self):
        self.spectra_selector_widget.set_data(self.ms_levels, self.precursor_mz)

    def setup_table_widgets(self):
        if self.table is not None:
            self.table_widget = create_table_widget(self.table, self)
            self.select_all_peaks = QPushButton("Select all peaks", self)
            self.unselect_all_peaks = QPushButton("Unselect all peaks", self)
            self.done_button = QPushButton("Done", self)

    def setup_menu_bar(self):
        self.menu_bar = QMenuBar(self)
        menu = QMenu("Peakmap Explorer", self.menu_bar)
        self.menu_bar.addMenu(menu)
        if not self.dual_mode:
            self.load_action = QAction("Load Peakmap", self)
            self.load_action.setShortcut(QKeySequence("Ctrl+L"))
            self.load_action2 = None
            menu.addAction(self.load_action)
        else:
            self.load_action = QAction("Load Yellow Peakmap", self)
            self.load_action2 = QAction("Load Blue Peakmap", self)
            menu.addAction(self.load_action)
            menu.addAction(self.load_action2)

        self.save_action = QAction("Save selected range as image", self)
        self.save_action.setShortcut(QKeySequence("Ctrl+S"))
#.........这里部分代码省略.........
开发者ID:gmat,项目名称:emzed2,代码行数:103,代码来源:peakmap_explorer.py

示例14: LoginView

# 需要导入模块: from PyQt4.QtGui import QMenuBar [as 别名]
# 或者: from PyQt4.QtGui.QMenuBar import addMenu [as 别名]

#.........这里部分代码省略.........
		#Stack em up vertically
		self._mainLayout_ = QVBoxLayout()
		self._mainLayout_.addStretch()
		self._mainLayout_.addWidget(self._logoLabel_,0,Qt.AlignCenter)
		self._mainLayout_.addWidget(self._usernameWidget_)
		self._mainLayout_.addWidget(self._passWidget_)
		self._mainLayout_.addWidget(self._rememberWidget_)
		self._mainLayout_.addLayout(self._buttonsWidget_)
		self._mainLayout_.addLayout(myBloopSiteLinkLayout)
		self._mainLayout_.addStretch()
		
		#Add another layout to show while we wait
		#put all this on a QStackedLayout
		self._passwordLineEdit_.setStyleSheet("border-style: outset; border-width: 1px; border-radius: 3px; border-color: gray; padding: 3px;")
		self._usernameLineEdit_.setStyleSheet("border-style: outset; border-width: 1px; border-radius: 3px; border-color: gray; padding: 3px;")
		self._waitLayout_ = QVBoxLayout()
		self._waitLayout_.setAlignment(Qt.AlignHCenter)

		self._waitLabel_ = QLabel()
		pixmap = QPixmap(os.path.join('i18n','images','us_en','loading.png'))
		self._waitLabel_.setPixmap(pixmap)
		self._waitLayout_.addWidget(self._waitLabel_)
		self._waitLayout_.addStretch()

		self._stackedLayout_ = QStackedLayout()

		waitWidget = QWidget()
		waitWidget.setLayout(self._waitLayout_)

		mainWidget = QWidget()
		mainWidget.setLayout(self._mainLayout_)

		self._stackedLayout_.addWidget(mainWidget)
		self._stackedLayout_.addWidget(waitWidget)

		self._stackedLayout_.setCurrentIndex(0) #main layout

		self.fillBackground()
		loginLayout = QVBoxLayout()
		loginLayout.addLayout(self._stackedLayout_)
		self.setLayout(loginLayout)

	def getLineEditUsername(self):
		return self._usernameLineEdit_
	
	def getLineEditPassword(self):
		return self._passwordLineEdit_

	def getUsernameLabel(self):
		return self._usernameLabel_

	def getPasswordLabel(self):
		return self._passwordLabel_
	
	def getButtonLogin(self):
		return self._loginButton_
	
	def getButtonRegister(self):
		return self._registerButton_
	
	def getLabelMyBloopSiteLink(self):
		'''Returns a QLabel object. 
		This QLabel contains one or more links to MyBloop.com pages.
		It's the responsability of the controller to catch the linkActivated(QString)
		signal to open a browser for the user. The String passed contains the URL'''
		return self._myBloopSiteLink_
	
	def getRememberCheckbox(self):
		return self._rememberCheckbox_
	
	def wantsToBeRemembered(self):
		return self._rememberCheckbox_.checkState() == Qt.Checked
	
	def fillBackground(self):
		"""Fills the background with a solid white"""
		self.palette().setColor(QPalette.Background, QColor(255,255,255))
		self.setAutoFillBackground(True)
		
	def showForm(self):
		self._stackedLayout_.setCurrentIndex(0)
		
	def showWaiting(self):
		self._stackedLayout_.setCurrentIndex(1)

	def createMenubar(self):
		self._menuBar_ = QMenuBar(None)
		
		#Create File Menu
		self._fileMenu_ = QMenu(self)
		am = ActionManager.getInstance()
        #todo add actions from ActionManager
		for action in am.getBloopFileMenuActions():
		    print "MainView.createMenuBar() adding action to file menu", action
		    print self._fileMenu_.addAction(action)
        
		#Create Help Menu
		self._menuBar_.addMenu(self._fileMenu_)
		
		#self.setMenuWidget(self._menuBar_)
		#self._menuBar_.setVisible(True)
开发者ID:gubatron,项目名称:blooploader,代码行数:104,代码来源:LoginView.py

示例15: QDialog

# 需要导入模块: from PyQt4.QtGui import QMenuBar [as 别名]
# 或者: from PyQt4.QtGui.QMenuBar import addMenu [as 别名]
# coding: utf-8
from PyQt4.QtGui import QDialog, QMenu, QMenuBar, QVBoxLayout
from qgis.core import QgsColorSchemeRegistry, QgsCustomColorScheme
from qgis.gui import QgsColorSwatchGridAction

new_dialog = QDialog()
main_layout = QVBoxLayout()
menu_bar = QMenuBar()
menu = QMenu(u"Test")

color_scheme_registry = QgsColorSchemeRegistry.instance()
schemes = color_scheme_registry.schemes()
project_scheme = [s for s in schemes if isinstance(s, QgsCustomColorScheme)][0]

color_swatch_grid_action = QgsColorSwatchGridAction(project_scheme, menu)

menu.addAction(color_swatch_grid_action)

menu_bar.addMenu(menu)
main_layout.setMenuBar(menu_bar)
new_dialog.setLayout(main_layout)

new_dialog.show()
开发者ID:GEO-IASS,项目名称:pyqgis-samples,代码行数:25,代码来源:qgis-sample-QgsColorSwatchGridAction.py


注:本文中的PyQt4.QtGui.QMenuBar.addMenu方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。