當前位置: 首頁>>代碼示例>>Python>>正文


Python QtGui.QGuiApplication方法代碼示例

本文整理匯總了Python中PyQt5.QtGui.QGuiApplication方法的典型用法代碼示例。如果您正苦於以下問題:Python QtGui.QGuiApplication方法的具體用法?Python QtGui.QGuiApplication怎麽用?Python QtGui.QGuiApplication使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtGui的用法示例。


在下文中一共展示了QtGui.QGuiApplication方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QGuiApplication [as 別名]
def main():
    app = QGuiApplication(sys.argv)
    
    qmlRegisterType(FigureCanvasQTAggToolbar, "Backend", 1, 0, "FigureToolbar")
    
    imgProvider = MatplotlibIconProvider()
    
    engine = QQmlApplicationEngine(parent=app)
    engine.addImageProvider("mplIcons", imgProvider)
    
    context = engine.rootContext()
    data_model = DataSeriesModel()
    context.setContextProperty("dataModel", data_model)
    mainApp = Form(data=data_model)
    context.setContextProperty("draw_mpl", mainApp)
    
    engine.load(QUrl('main.qml'))
    
    win = engine.rootObjects()[0]
    mainApp.figure = win.findChild(QObject, "figure").getFigure()
    
    rc = app.exec_()
    sys.exit(rc) 
開發者ID:fcollonval,項目名稱:matplotlib_qtquick_playground,代碼行數:25,代碼來源:mpl_qtquick1.py

示例2: setUp

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QGuiApplication [as 別名]
def setUp(self):
        PillowQtTestCase.setUp(self)
        try:
            if ImageQt.qt_version == '5':
                from PyQt5.QtGui import QGuiApplication
            elif ImageQt.qt_version == '4':
                from PyQt4.QtGui import QGuiApplication
            elif ImageQt.qt_version == 'side':
                from PySide.QtGui import QGuiApplication
            elif ImageQt.qt_version == 'side2':
                from PySide2.QtGui import QGuiApplication
        except ImportError:
            self.skipTest('QGuiApplication not installed')

        self.app = QGuiApplication([]) 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:17,代碼來源:test_imageqt.py

示例3: main

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QGuiApplication [as 別名]
def main():
    argv = sys.argv
    
    # Trick to set the style / not found how to do it in pythonic way
    argv.extend(["-style", "universal"])
    app = QGuiApplication(argv)

    qmlRegisterType(FigureCanvasQTAggToolbar, "Backend", 1, 0, "FigureToolbar")    
    imgProvider = MatplotlibIconProvider()
    
    # !! You must specified the QApplication as parent of QQmlApplicationEngine
    # otherwise a segmentation fault is raised when exiting the app
    engine = QQmlApplicationEngine(parent=app)
    engine.addImageProvider("mplIcons", imgProvider)
    
    context = engine.rootContext()
    data_model = DataSeriesModel()
    context.setContextProperty("dataModel", data_model)
    mainApp = Form(data=data_model)
    context.setContextProperty("draw_mpl", mainApp)
    
    engine.load(QUrl('main.qml'))
    
    win = engine.rootObjects()[0]
    mainApp.figure = win.findChild(QObject, "figure").getFigure()
    
    rc = app.exec_()
    # There is some trouble arising when deleting all the objects here
    # but I have not figure out how to solve the error message.
    # It looks like 'app' is destroyed before some QObject
    sys.exit(rc) 
開發者ID:fcollonval,項目名稱:matplotlib_qtquick_playground,代碼行數:33,代碼來源:mpl_qtquick2.py

示例4: main

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QGuiApplication [as 別名]
def main():
    argv = sys.argv
    
    app = QGuiApplication(argv)
    
    qmlRegisterType(FigureCanvasQTAggToolbar, "Backend", 1, 0, "FigureToolbar")
    
    imgProvider = MatplotlibIconProvider()
    view = QQuickView()
    view.engine().addImageProvider("mplIcons", imgProvider)
    view.setResizeMode(QQuickView.SizeRootObjectToView)
    view.setSource(QUrl('backend_qtquick5/FigureToolbar.qml'))
    
    win = view.rootObject()
    fig = win.findChild(QObject, "figure").getFigure()
    ax = fig.add_subplot(111)
    x = np.linspace(-5, 5)
    ax.plot(x, np.sin(x))
    
    view.show()
    
    rc = app.exec_()
    # There is some trouble arising when deleting all the objects here
    # but I have not figure out how to solve the error message.
    # It looks like 'app' is destroyed before some QObject
    sys.exit(rc) 
開發者ID:fcollonval,項目名稱:matplotlib_qtquick_playground,代碼行數:28,代碼來源:mpl_qquick_toolbar.py

示例5: main

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QGuiApplication [as 別名]
def main():
    argv = sys.argv
    
    # Trick to set the style / not found how to do it in pythonic way
    argv.extend(["-style", "universal"])
    app = QGuiApplication(argv)
    
    qmlRegisterType(FigureCanvasQTAgg, "Backend", 1, 0, "FigureCanvas")
    
    view = QQuickView()
    view.setResizeMode(QQuickView.SizeRootObjectToView)
    view.setSource(QUrl('backend_qtquick5/Figure.qml'))
    view.show()
    
    win = view.rootObject()
    fig = win.findChild(QObject, "figure").getFigure()
    print(fig)
    ax = fig.add_subplot(111)
    x = np.linspace(-5, 5)
    ax.plot(x, np.sin(x))
    
    rc = app.exec_()
    # There is some trouble arising when deleting all the objects here
    # but I have not figure out how to solve the error message.
    # It looks like 'app' is destroyed before some QObject
    sys.exit(rc) 
開發者ID:fcollonval,項目名稱:matplotlib_qtquick_playground,代碼行數:28,代碼來源:mpl_qquick.py

示例6: main

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QGuiApplication [as 別名]
def main():
    client_dbus = ClientDBus()
    # FIXME: log service failed to dump log
    client_log.debug('Init client dbus: %s' % client_dbus)

    app = QtGui.QGuiApplication(sys.argv)
    app.exec() 
開發者ID:linuxdeepin,項目名稱:deepin-remote-assistance,代碼行數:9,代碼來源:client_dbus_test.py


注:本文中的PyQt5.QtGui.QGuiApplication方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。