當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。