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


Python QtWidgets.QMenuBar类代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QMenuBar的典型用法代码示例。如果您正苦于以下问题:Python QMenuBar类的具体用法?Python QMenuBar怎么用?Python QMenuBar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

 def __init__(self, parent=None):
     """
     Initialize the menubar.
     :param parent: the parent widget
     """
     QMenuBar.__init__(self, parent)
     self.initUI()
开发者ID:HaoDrang,项目名称:big-brother-bot,代码行数:7,代码来源:system.py

示例2: setup_menubar

    def setup_menubar(self):
        menu_bar = QMenuBar()

        file_menu = menu_bar.addMenu("&File")
        file_menu.addAction(self.new_project_action)
        file_menu.addAction(self.show_settings_action)
        file_menu.addSeparator()
        file_menu.addAction(self.quit_action)

        view_menu = menu_bar.addMenu("&View")

        dockWidgets = self.findChildren(QDockWidget)
        for widget in dockWidgets:
            view_menu.addAction(widget.toggleViewAction())

        debug_menu = menu_bar.addMenu("&Debug")
        debug_menu.addAction(self.start_listening_action)
        debug_menu.addAction(self.stop_listening_action)
        debug_menu.addSeparator()
        debug_menu.addAction(self.stop_debug_action)
        debug_menu.addAction(self.detach_debug_action)
        debug_menu.addSeparator()
        debug_menu.addAction(self.run_debug_action)
        debug_menu.addAction(self.step_over_action)
        debug_menu.addAction(self.step_into_action)
        debug_menu.addAction(self.step_out_action)

        self.setMenuBar(menu_bar)
开发者ID:mbarbon,项目名称:pugdebug,代码行数:28,代码来源:main_window.py

示例3: initUI

    def initUI(self):
        QToolTip.setFont(QFont('SansSerif', 10))
        self.setToolTip('This is a <b>QWidget</b> widget.')
        #quitBtn = QPushButton('Quit', self)
        #quitBtn.clicked.connect(self.quitBtnEvent())
        #quitBtn.clicked.connect(QCoreApplication.instance().quit)
        #quitBtn.setToolTip('This is a <b>QPushButton</b> widget.')
        #quitBtn.resize(quitBtn.sizeHint())

        exitAction = QAction(QIcon('application-exit-4.png'), '&Exit', self)
        exitAction.setShortcut('Alt+F4')
        exitAction.setStatusTip('Exit Application')
        exitAction.triggered.connect(qApp.quit)

        menuBar = QMenuBar()
        fileMenu = menuBar.addMenu('&File')
        fileMenu.addAction(exitAction)
        fileMenu.resize(fileMenu.sizeHint())

        toolBar = QToolBar(self)
        toolBar.addAction(exitAction)
        #toolBar.resize(toolBar.sizeHint())
        toolBar.setFixedHeight(60)

        hozLine = QFrame()
        hozLine.setFrameStyle(QFrame.HLine)
        #hozLine.setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Expanding)

        statusBar = QStatusBar(self)
        statusBar.showMessage('Ready')

        grid = QGridLayout()
        lbl_1 = QLabel('1,1')
        lbl_2 = QLabel('1,2')
        lbl_3 = QLabel('2,1')
        lbl_4 = QLabel('2,2')
        grid.addWidget(lbl_1, 1, 1)
        grid.addWidget(lbl_2, 1, 2)
        grid.addWidget(lbl_3, 2, 1)
        grid.addWidget(lbl_4, 2, 2)

        vbox = QVBoxLayout()
        vbox.addWidget(menuBar)
        vbox.addWidget(hozLine)
        vbox.addWidget(toolBar)
        # vbox.addWidget(hozLine)
        vbox.addLayout(grid)
        vbox.addStretch(1)
        vbox.addWidget(statusBar)

        self.setLayout(vbox)

        self.setGeometry(300, 300, 500, 500)
        self.setWindowTitle('Photos')
        self.setWindowIcon(QIcon('camera-photo-5.png'))
        self.center()
        self.show()
开发者ID:jean-petitclerc,项目名称:PhotosGUI,代码行数:57,代码来源:PhotosGUI.py

示例4: __init__

    def __init__(self, parent, actionManager):
        QMenuBar.__init__(self, parent)
        self._manager = actionManager

        for action in self._manager.allActions():
            self._onActionInserted(action)

        self._manager.actionInserted.connect(self._onActionInserted)
        self._manager.actionRemoved.connect(self._onActionRemoved)
开发者ID:rapgro,项目名称:enki,代码行数:9,代码来源:actionmanager.py

示例5: __init__

    def __init__(self, app):
        QMainWindow.__init__(self, None)
        self.l.debug('Initializing MainWindow ...')

        self.setWindowTitle('MynPad')
        app.setWindowIcon(QIcon(':/icons/mynpad.png'))

        if os.name == 'nt':
            # On Windows, make sure to use a unique Application User Model Id, otherwise
            # Windows shows the default python icon in the taskbar
            # see http://stackoverflow.com/questions/1551605/how-to-set-applications-taskbar-icon-in-windows-7
            myappid = 'afester.mynpad'
            import ctypes; ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

        self.theApplication = app
        app.aboutToQuit.connect(self.saveState)

        # read the local configuration file
        iniPath = 'mynpad.ini'
        if not os.path.exists(iniPath):
            iniPath = os.path.join(expanduser("~"), iniPath)
        self.settings = Settings(iniPath)
        self.settings.load()

        # Set up the menu bar
        menuBar = QMenuBar(self)

        exitAction = QAction("Exit", self, triggered=self.theApplication.exit)
        fileMenu = menuBar.addMenu("&File")
        fileMenu.addAction(exitAction)

        aboutAction = QAction("About ...", self, triggered = self.handleAbout)
        helpMenu = menuBar.addMenu("&Help")
        helpMenu.addAction(aboutAction)

        self.setMenuBar(menuBar)

        # Setup the status bar
        self.statusBar = QStatusBar()
        self.statusBar.showMessage("Ready.")
        self.setStatusBar(self.statusBar)
        self.mainWidget = CentralWidget(self, self.settings)
        self.mainWidget.updateWindowTitle.connect(self.updateWindowTitle)
        self.setCentralWidget(self.mainWidget)

        # Reset main window size and position
        pos = self.settings.getMainWindowPos()
        self.move(pos.x(), pos.y())
        size = self.settings.getMainWindowSize()
        self.resize(size)

        # initialize the browser tree (add the top nodes and expand the saved path)
        self.mainWidget.browserWidget.initialize()
开发者ID:afester,项目名称:CodeSamples,代码行数:53,代码来源:MainWindow.py

示例6: menubar

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:19joho66,项目名称:frescobaldi,代码行数:9,代码来源:globalmenu.py

示例7: createMenus

    def createMenus(self):

        self.menubar = QMenuBar(self)
        self.menubar.setGeometry(QRect(0, 0, 1029, 22))
        self.menubar.setDefaultUp(False)
        self.menubar.setNativeMenuBar(False)
        self.menubar.setObjectName("menubar")
        self.menuFile = QMenu(self.menubar)


        self.setMenuBar(self.menubar)



        self.fileMenu = self.menuBar().addMenu("&File")
        self.fileMenu.addAction(self.newAct)
        self.fileMenu.addAction(self.openAct)
        self.fileMenu.addAction(self.closeAct)
        self.fileMenu.addAction(self.saveAct)
        self.fileMenu.addAction(self.saveAsAct)
        self.fileMenu.addAction(self.printAct)
        self.fileMenu.addSeparator();
        self.fileMenu.addAction(self.exitAct)

        self.editMenu = self.menuBar().addMenu("&Edit")
        self.editMenu.addAction(self.cutAct)
        self.editMenu.addAction(self.copyAct)
        self.editMenu.addAction(self.pasteAct)

        self.menuBar().addSeparator()

        self.helpMenu = self.menuBar().addMenu("&Help")
        self.helpMenu.addAction(self.aboutAct)
开发者ID:PWilsonUofC,项目名称:VGenes,代码行数:33,代码来源:VgenesTextEdit.py

示例8: createMenuBar

    def createMenuBar(self):
        self.menuBar = QMenuBar()

        self.fileMenu = QMenu("&File", self)
        self.exitAction = self.fileMenu.addAction("E&xit")
        self.menuBar.addMenu(self.fileMenu)

        self.exitAction.triggered.connect(self.accept)
开发者ID:Ink-Pixi,项目名称:AvailableSizes,代码行数:8,代码来源:availableSizes.py

示例9: __init__

    def __init__(self):
        super(Main_Window, self).__init__()

        self.menubar = QMenuBar(self)
        self.statusbar = QStatusBar(self)
        self.centralwidget = QWidget(self)
        self.image_view = Image_View(self.centralwidget)
        self.horizontal_slider = QSlider(self.centralwidget)

        self.setup_ui()
开发者ID:CaptainWilliam,项目名称:StrawHat,代码行数:10,代码来源:ui_1_random_lines.py

示例10: __init__

    def __init__(self, parent=None, title="Source"):
        super(ViewSourceDialog, self).__init__()
        self.setParent(parent)
        self.menuBar = QMenuBar(self)
        self.menuBar.setStyleSheet("""QMenuBar { background: transparent; border: 0; }
                                      QMenuBar::item { background: transparent;
                                                       color: palette(window-text); }
                                      QMenuBar::item:pressed { background: palette(highlight);
                                                               color: palette(highlighted-text); }""")
        self.setMenuBar(self.menuBar)

        self.text = ""
        self.findFlag = None

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

        self.saveAsAction = QAction(tr("&Save As..."), self)
        self.saveAsAction.setShortcut("Ctrl+S")
        self.saveAsAction.triggered.connect(self.saveAs)
        self.addAction(self.saveAsAction)
        self.fileMenu.addAction(self.saveAsAction)

        self.viewMenu = QMenu(tr("&View"), self.menuBar)
        self.menuBar.addMenu(self.viewMenu)

        self.findAction = QAction(tr("&Find..."), self)
        self.findAction.setShortcut("Ctrl+F")
        self.findAction.triggered.connect(self.find)
        self.addAction(self.findAction)
        self.viewMenu.addAction(self.findAction)

        self.findNextAction = QAction(tr("Find Ne&xt"), self)
        self.findNextAction.setShortcut("Ctrl+G")
        self.findNextAction.triggered.connect(self.findNext)
        self.addAction(self.findNextAction)
        self.viewMenu.addAction(self.findNextAction)

        self.findPreviousAction = QAction(tr("Find Pre&vious"), self)
        self.findPreviousAction.setShortcut("Ctrl+Shift+G")
        self.findPreviousAction.triggered.connect(self.findPrevious)
        self.addAction(self.findPreviousAction)
        self.viewMenu.addAction(self.findPreviousAction)

        self.sourceView = SourceView(self)
        self.sourceView.setReadOnly(True)
        self.sourceView.setFontFamily("monospace")
        self.setCentralWidget(self.sourceView)
        closeWindowAction = QAction(self)
        closeWindowAction.setShortcut("Ctrl+W")
        closeWindowAction.triggered.connect(self.close)
        self.addAction(closeWindowAction)
        self.setWindowTitle(title)

        self.resize(640, 480)
开发者ID:ismlsmile,项目名称:nimbus,代码行数:55,代码来源:view_source_dialog.py

示例11: createMenu

 def createMenu(self):
     self.menuBar = QMenuBar()
     self.fileMenu = self.menuBar.addMenu("&File")
     self.helpMenu = self.menuBar.addMenu("&Help")
     self.aNewProject = self.fileMenu.addAction("Start new project")
     self.aOpen = self.fileMenu.addAction("Open")
     self.aSave = self.fileMenu.addAction("Save as...")
     self.aExport = self.fileMenu.addAction("Export as...")
     self.fileMenu.addSeparator()
     self.aExitApp = self.fileMenu.addAction("Exit")
     self.setMenuBar(self.menuBar)
开发者ID:Penguinum,项目名称:py-nodebox-editor,代码行数:11,代码来源:main.py

示例12: createMenu

    def createMenu(self):
        self.menuBar = QMenuBar()

        self.fileMenu = QMenu("&Fichier", self)
        self.exitAction = self.fileMenu.addAction("E&xit")
        apropos = QMenu("&Infos", self)
        apro = QAction("À &propos", self)
        apro.triggered.connect(self._createApropos)
        apropos.addAction(apro)

        self.menuBar.addMenu(self.fileMenu)
        self.menuBar.addMenu(apropos)
开发者ID:TeddyBoomer,项目名称:TableauSigne,代码行数:12,代码来源:TabSigneGUI.py

示例13: createMenu

	def createMenu(self):
		self.menuBar = QMenuBar()

		self.fileMenu = QMenu("&File", self)
		self.exitAction = self.fileMenu.addAction("E&xit")

		self.exitAction.setShortcut('Ctrl+Q')
		self.exitAction.setStatusTip('Exit application')
		#self.exitAction.triggered.connect(qApp.quit)

		self.menuBar.addMenu(self.fileMenu)

		self.exitAction.triggered.connect(self.accept)
开发者ID:Shadey,项目名称:Bamboodl,代码行数:13,代码来源:bamboogui.py

示例14: Main_Window

class Main_Window(QMainWindow):
    def __init__(self):
        super(Main_Window, self).__init__()

        self.menubar = QMenuBar(self)
        self.statusbar = QStatusBar(self)
        self.centralwidget = QWidget(self)
        self.image_view = Image_View(self.centralwidget)
        self.horizontal_slider = QSlider(self.centralwidget)

        self.setup_ui()

    def setup_ui(self):
        # 1. self info
        self.setObjectName("Demo_1")
        self.resize(800, 600)

        # 2.1 sub widgets
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 22))
        self.menubar.setObjectName("menubar")
        self.setMenuBar(self.menubar)

        # 2.2
        self.statusbar.setObjectName("statusbar")
        self.setStatusBar(self.statusbar)

        # 2.3
        self.centralwidget.setObjectName("centralwidget")
        self.setCentralWidget(self.centralwidget)

        self.image_view.setGeometry(QtCore.QRect(144, 10, 512, 512))
        self.image_view.setObjectName("image_view")

        self.horizontal_slider.setGeometry(QtCore.QRect(144, 530, 512, 22))
        self.horizontal_slider.setOrientation(QtCore.Qt.Horizontal)
        self.horizontal_slider.setObjectName("horizontal_slider")

        # 3 signals and slots
        self.horizontal_slider.valueChanged['int'].connect(self.image_view.repaint)
开发者ID:CaptainWilliam,项目名称:StrawHat,代码行数:39,代码来源:ui_1_random_lines.py

示例15: __init__

    def __init__(self):
        super().__init__()
        # GroupBox Initialization
        self.mainlayout = QGridLayout()   # basicinfo layout

        self.names = []
        self.menuBar = QMenuBar()
        # PushButton Initialization
        self.BeginTestButton = QPushButton('开始测试')
        self.CancelTestButton = QPushButton('取消测试')
        self.PauseTestButton = QPushButton('暂停测试')
        self.SaveBasicinfoButton = QPushButton('保存基本信息')

        self.initUI()
开发者ID:JokerLJZ,项目名称:FieldSensorTest,代码行数:14,代码来源:FrontPanel.py


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