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


Python QMenuBar.setNativeMenuBar方法代码示例

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


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

示例1: ui

# 需要导入模块: from PyQt5.QtWidgets import QMenuBar [as 别名]
# 或者: from PyQt5.QtWidgets.QMenuBar import setNativeMenuBar [as 别名]
    def ui(self):
        menubar = QMenuBar()
        menubar.setNativeMenuBar(True)  # make the menu bar OS specific

        bar_file = menubar.addMenu(self.tr("&File"))

        file_load = QAction(self.tr("&Load image"), self,
                            shortcut=QKeySequence.New,
                            statusTip=self.tr("Load a new image"),
                            triggered=self.open_file)

        file_save = QAction(self.tr("&Save plate"), self,
                            shortcut=QKeySequence.Save,
                            statusTip=self.tr("Save the pattern"),
                            triggered=self.save_file)

        file_print = QAction(self.tr("&Print"), self,
                             shortcut=QKeySequence.Print,
                             statusTip=self.tr("Print pixel pattern"),
                             triggered=self.print_file)

        file_settings = QAction(self.tr("S&ettings"), self,
                                statusTip=self.tr('Change settings'),
                                triggered=self.change_settings)

        file_quit = QAction(self.tr("&Quit"), self, shortcut=QKeySequence.Quit,
                            statusTip=self.tr('Quit the program'),
                            triggered=self.close)

        bar_file.addAction(file_load)
        bar_file.addAction(file_save)
        bar_file.addAction(file_print)
        bar_file.addAction(file_settings)
        bar_file.addAction(file_quit)

        bar_about = menubar.addMenu(self.tr("&About"))
        about_about = QAction(self.tr("&About"), self,
                              statusTip=self.tr("Show about PyBigPix"),
                              triggered=self.show_about)

        about_licence = QAction(self.tr("&License"), self,
                                statusTip=self.tr('Show license'),
                                triggered=self.show_license)

        about_QT = QAction(self.tr("About &QT"), self,
                           statusTip=self.tr("Show about QT"),
                           triggered=qApp.aboutQt)

        bar_about.addAction(about_about)
        bar_about.addAction(about_licence)
        bar_about.addAction(about_QT)

        self.setMenuWidget(menubar)
        self.setMenuBar(menubar)

        self.setWindowTitle(self.window_title)

        self.label_image = QLabel(self.tr("Start Image"))
        self.label_image.setSizePolicy(QSizePolicy.Expanding,
                                       QSizePolicy.Expanding)
        self.label_image.setMinimumSize(400, 400)
        self.label_image.textFormat()
        self.label_image.setFrameShape(QFrame.Panel)
        self.label_image.setAlignment(Qt.AlignCenter)

        self.lable_pixels = QLabel(self.tr("Pixel Image"))
        self.lable_pixels.setMinimumSize(400, 400)
        self.lable_pixels.setSizePolicy(QSizePolicy.Expanding,
                                       QSizePolicy.Expanding)
        self.lable_pixels.setAlignment(Qt.AlignCenter)
        self.lable_pixels.setFrameShape(QFrame.Panel)

        self.centeralwidget = QWidget()
        layout = QHBoxLayout(self.centeralwidget)
        layout.addWidget(self.label_image)
        layout.addWidget(self.lable_pixels)
        self.setCentralWidget(self.centeralwidget)
开发者ID:SWE-JSAM,项目名称:PyBigPixel-creator,代码行数:79,代码来源:pybigpixel.py

示例2: VGenesTextMain

# 需要导入模块: from PyQt5.QtWidgets import QMenuBar [as 别名]
# 或者: from PyQt5.QtWidgets.QMenuBar import setNativeMenuBar [as 别名]

#.........这里部分代码省略.........
        self.printAct = QAction(QIcon(':/PNG-Icons/print.png'), "&Print...", self,
                shortcut=QKeySequence.Print,
                statusTip="Print the current form letter",
                triggered=self.print_)

        self.copyAct = QAction(QIcon(':/PNG-Icons/pages.png'), "&Copy", self,
                shortcut=QKeySequence.Copy,
                statusTip="Copy the current selection's contents to the clipboard",
                triggered=self.textEdit.copy)

        self.pasteAct = QAction(QIcon(':/PNG-Icons/Paste.png'), "&Paste", self,
                shortcut=QKeySequence.Paste,
                statusTip="Paste the clipboard's contents into the current selection",
                triggered=self.textEdit.paste)

        self.aboutAct = QAction("&About", self,
                statusTip="Show the application's About box",
                triggered=self.about)

        # self.aboutQtAct = QAction("About &Qt", self,
        #         statusTip="Show the Qt library's About box",
        #         triggered=QApplication.instance().aboutQt)

        self.cutAct.setEnabled(False)
        self.copyAct.setEnabled(False)
        self.textEdit.copyAvailable.connect(self.cutAct.setEnabled)
        self.textEdit.copyAvailable.connect(self.copyAct.setEnabled)

    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)
        # self.helpMenu.addAction(self.aboutQtAct)

    def createToolBars(self):
        self.fileToolBar = self.addToolBar("File")
        self.fileToolBar.addAction(self.newAct)
开发者ID:PWilsonUofC,项目名称:VGenes,代码行数:70,代码来源:VgenesTextEdit.py


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