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


Python QGuiApplication.exec方法代码示例

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


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

示例1: main

# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import exec [as 别名]
def main(argv):
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    qapp = QGuiApplication([])

    engine = QQmlApplicationEngine()

    data_list = []
    for entry in os.scandir(argv[1]):
        url = "file://" + urllib.parse.quote(os.path.abspath(entry.path))
        digest = hashlib.md5(os.fsencode(url)).hexdigest()
        result = os.path.join(xdg.BaseDirectory.xdg_cache_home, "thumbnails", "normal", digest + ".png")
        data_list.append(Foo(entry.name, result, "2018-01-11T19:20"))

    engine.load(QUrl('main.qml'))

    ctxt = engine.rootContext()
    ctxt.setContextProperty("menu2", QVariant(data_list))

    win = engine.rootObjects()[0]
    win.show()

    sys.exit(qapp.exec())
开发者ID:Grumbel,项目名称:dirtool,代码行数:25,代码来源:qmltest.py

示例2: Calculator

# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import exec [as 别名]
# encoding: utf-8

from PyQt5.QtCore import  QUrl, QObject, pyqtSlot
from PyQt5.QtGui import QGuiApplication
from PyQt5.QtQuick import QQuickView
from calculate import *

class Calculator(QObject):

    @pyqtSlot(str,result = str)
    def output(self,exp):
        '''return the result of  exp'''
        return str(calculate(exp))

    @pyqtSlot(str,result = str)
    def del_input(self,input):
        '''the function for the "del" Button '''
        return input[:-1]

if __name__ == '__main__':
    path = 'calculate.qml'
    app = QGuiApplication([])
    view = QQuickView()
    con = Calculator()
    context = view.rootContext()
    context.setContextProperty("con",con)
    view.engine().quit.connect(app.quit)
    view.setSource(QUrl(path))
    view.show()
    app.exec()
开发者ID:Zonzely,项目名称:calculate,代码行数:32,代码来源:main.py


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