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


Python QtWidgets.QApplication类代码示例

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


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

示例1: run_main

def run_main():
    import sys
    from PySide2.QtWidgets import QApplication
    app = QApplication(sys.argv)
    mw = AddressWidget()
    mw.show()
    sys.exit(app.exec_())
开发者ID:amirkogit,项目名称:QtTestGround,代码行数:7,代码来源:table_model_test.py

示例2: main

def main():
    app = QApplication(sys.argv)

    window = MainWindow()
    window.show()

    app.exec_()
开发者ID:gpeterson2,项目名称:JSON-Beautifier,代码行数:7,代码来源:main.py

示例3: main

def main():
    global dbus
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="increase output verbosity",
                        action="store_true")
    args = parser.parse_args()
    QtQml.qmlRegisterType(QmlPage, "djpdf", 1, 0, "DjpdfPage")
    app = QApplication([])
    engine = QQmlApplicationEngine()
    thumbnail_image_provider = ThumbnailImageProvider()
    engine.addImageProvider("thumbnails", thumbnail_image_provider)
    ctx = engine.rootContext()
    pages_model = QmlPagesModel(verbose=args.verbose)
    if os.environ.get("DJPDF_PLATFORM_INTEGRATION", "") == "flatpak":
        import dbus
        import dbus.mainloop.glib
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        bus = dbus.SessionBus()
        platform_integration = QmlFlatpakPlatformIntegration(bus)
    else:
        platform_integration = QmlPlatformIntegration()
    ctx.setContextProperty("pagesModel", pages_model)
    ctx.setContextProperty("platformIntegration", platform_integration)
    engine.load(QUrl.fromLocalFile(
        os.path.join(QML_DIR, "main.qml")))
    if os.environ.get("DJPDF_PLATFORM_INTEGRATION", "") == "flatpak":
        platform_integration.win_id = engine.rootObjects()[0].winId()
    exit(app.exec_())
开发者ID:Unrud,项目名称:djpdf,代码行数:28,代码来源:scans2pdfgui.py

示例4: testInstanceObject

 def testInstanceObject(self):
     TestObject.createApp()
     app1 = QApplication.instance()
     app2 = QApplication.instance()
     app1.setObjectName("MyApp")
     self.assertEqual(app1, app2)
     self.assertEqual(app2.objectName(), app1.objectName())
     app1.destroyed.connect(self.appDestroyed)
开发者ID:BadSingleton,项目名称:pyside2,代码行数:8,代码来源:application_test.py

示例5: main

def main():
    app = QApplication([])
    QtWebEngine.initialize()
    engine = QQmlApplicationEngine()
    qml_file_path = os.path.join(os.path.dirname(__file__), 'browser.qml')
    qml_url = QUrl.fromLocalFile(os.path.abspath(qml_file_path))
    engine.load(qml_url)
    app.exec_()
开发者ID:amirkogit,项目名称:QtTestGround,代码行数:8,代码来源:quicknanobrowser.py

示例6: testIt

    def testIt(self):
        app = QApplication([])
        self.box = MySpinBox()
        self.box.show()

        QTimer.singleShot(0, self.sendKbdEvent)
        QTimer.singleShot(100, app.quit)
        app.exec_()

        self.assertEqual(self.box.text(), '0')
开发者ID:BadSingleton,项目名称:pyside2,代码行数:10,代码来源:bug_879.py

示例7: round

 def round(self, disc: FourPlay.Disc):
     QApplication.setOverrideCursor(Qt.WaitCursor)
     self.player.disc = disc
     score = self.fourPlay.round(True)
     QApplication.restoreOverrideCursor()
     if score is not None:
         if score == +1:
             QMessageBox.information(self, self.tr("Victory!"), self.tr("You won :)"), QMessageBox.Ok)
         if score == 0:
             QMessageBox.warning(self, self.tr("Tie!"), self.tr("You tied :|"), QMessageBox.Ok)
         if score == -1:
             QMessageBox.critical(self, self.tr("Defeat!"), self.tr("You lost :("), QMessageBox.Ok)
         self.fourPlay.reset(True)
开发者ID:vojtamolda,项目名称:games,代码行数:13,代码来源:ui.py

示例8: saveFile

    def saveFile(self, fileName):
        file = QFile(fileName)

        if not file.open(QFile.WriteOnly | QFile.Text):
            QMessageBox.warning(self, "MDI",
                    "Cannot write file %s:\n%s." % (fileName, file.errorString()))
            return False

        outstr = QTextStream(file)
        QApplication.setOverrideCursor(Qt.WaitCursor)
        outstr << self.toPlainText()
        QApplication.restoreOverrideCursor()

        self.setCurrentFile(fileName)
        return True
开发者ID:amirkogit,项目名称:QtTestGround,代码行数:15,代码来源:mdi.py

示例9: about_text

    def about_text(self):
        self._window.label_3 = QLabel()
        self._window.label_3.setTextFormat(Qt.RichText)
        self._window.label_3.setOpenExternalLinks(True)
        self._window.label_3.setLocale(QLocale(QLocale.English,
                                               QLocale.UnitedStates))
        self._window.label_3.setScaledContents(True)
        self._window.label_3.setWordWrap(True)
        text = """
<html>
<head/>
<body>
  <p>poliBeePsync is a program written by Davide Olianas,
released under GNU GPLv3+.</p>
  <p>Feel free to contact me at <a
  href=\"mailto:[email protected]\">[email protected]</a> for
  suggestions and bug reports.</p>
  <p>More information is available on the
  <a href=\"http://www.davideolianas.com/polibeepsync\">
  <span style=\" text-decoration: underline; color:#0000ff;\">
  official website</span></a>.
  </p>
</body>
</html>
"""

        self._window.label_3.setText(QApplication.translate("Form", text,
                                                            None))
开发者ID:davethecipo,项目名称:polibeepsync,代码行数:28,代码来源:qtgui.py

示例10: loadFile

    def loadFile(self, fileName):
        file = QFile(fileName)
        if not file.open(QFile.ReadOnly | QFile.Text):
            QMessageBox.warning(self, "MDI",
                    "Cannot read file %s:\n%s." % (fileName, file.errorString()))
            return False

        instr = QTextStream(file)
        QApplication.setOverrideCursor(Qt.WaitCursor)
        self.setPlainText(instr.readAll())
        QApplication.restoreOverrideCursor()

        self.setCurrentFile(fileName)

        self.document().contentsChanged.connect(self.documentWasModified)

        return True
开发者ID:amirkogit,项目名称:QtTestGround,代码行数:17,代码来源:mdi.py

示例11: main

def main():
    # load options from cmdline
    parser = create_parser()
    args = parser.parse_args()

    # set debug levels
    LEVELS = {
        'notset': logging.NOTSET,
        'debug': logging.DEBUG,
        'info': logging.INFO,
        'warning': logging.WARNING,
        'error': logging.ERROR,
        'critical': logging.CRITICAL,
    }

    level_name = 'info'
    if args.debug:
        level_name = args.debug
    level = LEVELS.get(level_name, logging.INFO)

    # now get the logger used in the common module and set its level to what
    # we get from sys.argv
    commonlogger.setLevel(level)
    logger.setLevel(level)

    formatter = logging.Formatter('[%(levelname)s] %(name)s %(message)s')

    handler = logging.StreamHandler(stream=sys.stdout)
    handler.setFormatter(formatter)
    handler.setLevel(logging.DEBUG)

    logger.addHandler(handler)
    commonlogger.addHandler(handler)

    app = QApplication(sys.argv)

    frame = MainWindow()
    # args is defined at the top of this module
    if not args.hidden:
        # Need to fix showing wrong window
        frame.show()

    sys.exit(app.exec_())
开发者ID:davethecipo,项目名称:polibeepsync,代码行数:43,代码来源:qtgui.py

示例12: __init__

 def __init__(self):
     QCoreApplication.setOrganizationName('DynArt')
     QCoreApplication.setApplicationName('TilePad')
     QCoreApplication.setApplicationVersion('0.4.0')
     if getattr(sys, 'frozen', False):
         self.dir = os.path.dirname(sys.executable)
     else:
         self.dir = os.path.dirname(__file__)
     self.dir = self.dir.replace('\\', '/')
     self.qApp = QApplication(sys.argv)
     self.mainWindow = MainWindow(self)
开发者ID:goph-R,项目名称:TilePad,代码行数:11,代码来源:TilePad.py

示例13: getCheckBoxRect

 def getCheckBoxRect(self, option):
     check_box_style_option = QStyleOptionButton()
     check_box_rect = QApplication.style().subElementRect(
         QStyle.SE_CheckBoxIndicator, check_box_style_option, None)
     check_box_point = QPoint(option.rect.x() +
                              option.rect.width() / 2 -
                              check_box_rect.width() / 2,
                              option.rect.y() +
                              option.rect.height() / 2 -
                              check_box_rect.height() / 2)
     return QRect(check_box_point, check_box_rect.size())
开发者ID:davethecipo,项目名称:polibeepsync,代码行数:11,代码来源:ui_resizable.py

示例14: createNextWebView

def createNextWebView():
    global functionID

    nListCount = len(FUNCTIONS_LIST) - 1
    functionID = functionID + 1
    print functionID

    if functionID < nListCount:
        createWebView( functionID )
    else:
        QTimer.singleShot(300, QApplication.instance().quit)
开发者ID:BadSingleton,项目名称:pyside2,代码行数:11,代码来源:bug_959.py

示例15: testQClipboard

    def testQClipboard(self):
        # skip this test on MacOS because the clipboard is not available during the ssh session
        # this cause problems in the buildbot
        if sys.platform == "darwin":
            return
        clip = QApplication.clipboard()
        clip.setText("Testing this thing!")

        text, subtype = clip.text("")
        self.assertEqual(subtype, "plain")
        self.assertEqual(text, "Testing this thing!")
开发者ID:linzhun,项目名称:pyside2,代码行数:11,代码来源:api2_test.py


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