本文整理汇总了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())
示例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()