本文整理汇总了Python中PyQt5.QtGui.QGuiApplication.exec_方法的典型用法代码示例。如果您正苦于以下问题:Python QGuiApplication.exec_方法的具体用法?Python QGuiApplication.exec_怎么用?Python QGuiApplication.exec_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QGuiApplication
的用法示例。
在下文中一共展示了QGuiApplication.exec_方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import exec_ [as 别名]
def __init__(self, qml):
app = QGuiApplication(sys.argv)
model = QmlModel()
model.register()
qmlUrl = QUrl(qml)
assert qmlUrl.isValid()
print(qmlUrl.path())
# assert qmlUrl.isLocalFile()
"""
Create an engine a reference to the window?
window = QuickWindowFactory().create(qmlUrl=qmlUrl)
window.show() # visible
"""
engine = QQmlApplicationEngine()
"""
Need this if no stdio, i.e. Android, OSX, iOS.
OW, qWarnings to stdio.
engine.warnings.connect(self.errors)
"""
engine.load(qmlUrl)
engine.quit.connect(app.quit)
app.exec_() # !!! C exec => Python exec_
print("Application returned")
示例2: start
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import exec_ [as 别名]
def start():
app = QGuiApplication(sys.argv)
ui = DefaultUI()
ui.gamesList.gameChanged.connect(test2)
ui.platformSelector.platformChanged.connect(test)
ui.show()
sys.exit(app.exec_())
示例3: main
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import exec_ [as 别名]
def main():
print("start")
app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
engine.load(QUrl("main.qml"))
engine.rootObjects()[0].show()
sys.exit(app.exec_())
示例4: main
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import exec_ [as 别名]
def main():
# Set up correct Ctrl-C behavior.
signal.signal(signal.SIGINT, signal.SIG_DFL)
app = QGuiApplication( sys.argv )
engine = QQmlEngine()
engine.addImportPath( path.join( path.dirname( __file__ ), 'ui', 'qml' ) )
core.register_types()
component = QQmlComponent( engine )
component.loadUrl( QUrl( '/home/feoh3/.config/nube/hud.qml' ) )
if component.isError():
print( "\n".join( error.toString() for error in component.errors() ) )
else:
window = component.create()
app.exec_()
示例5: main
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import exec_ [as 别名]
def main():
app = QGuiApplication(sys.argv)
qmlRegisterType(MainController, 'MainController', 1, 0, 'MainController')
qmlRegisterType(ProfileViewModel, 'ProfileViewModel', 1, 0, 'ProfileViewModel')
engine = QQmlApplicationEngine()
main_controller = MainController()
main_controller.profile_selection_changed(0)
engine.rootContext().setContextProperty('mainController', main_controller)
engine.load(QUrl.fromLocalFile(pkg_resources.resource_filename('yarg.resource', 'main.qml')))
sys.exit(app.exec_())
示例6: execute_app
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import exec_ [as 别名]
def execute_app(config_dict):
# On systems running X11, possibly due to a bug, Qt fires the qWarning
# "QXcbClipboard::setMimeData: Cannot set X11 selection owner" while
# setting clipboard data when copy/selection events are encountered in
# rapid succession, resulting in clipboard data not being set. This env
# variable acts as a fail-safe which aborts the application if this
# happens more than once. Similar situation arises when another clipboard
# management app (like GPaste) is running alongside chaos.
os.environ["QT_FATAL_WARNINGS"] = "1"
signal.signal(signal.SIGTERM, qt_quit)
signal.signal(signal.SIGINT, qt_quit)
signal.signal(signal.SIGTSTP, qt_quit)
signal.signal(signal.SIGHUP, qt_quit)
app = QGuiApplication(sys.argv)
timer(100, lambda: None)
cb = Clipboard(config_dict)
sys.exit(app.exec_())
示例7: run_app
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import exec_ [as 别名]
def run_app():
app = QGuiApplication(sys.argv)
app.setApplicationName("Worship Prototype")
view = QQuickView()
view.setResizeMode(QQuickView.SizeRootObjectToView)
view.setSource(QUrl.fromLocalFile(os.path.join(os.path.dirname(__file__), 'main.qml')))
view.show()
root = view.rootObject()
preview = DefaultScreen()
preview.wire_to_gui(root, 'previewScreen')
preview.show_background(VideoBackground(os.path.join(os.path.dirname(__file__), '../echo.mp4')))
# preview_live = DefaultScreen()
# live = DefaultScreen()
modules = [
LyricsModule(SongsList(), root, preview),
]
sys.exit(app.exec_())
示例8: main
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import exec_ [as 别名]
def main():
app = QGuiApplication(sys.argv)
app.setApplicationName('InfiniteCopy')
openDataBase()
view = QQuickView()
clipboardItemModel = ClipboardItemModel()
clipboardItemModel.create()
filterProxyModel = QSortFilterProxyModel()
filterProxyModel.setSourceModel(clipboardItemModel)
clipboard = Clipboard()
clipboard.setFormats([
mimeText,
mimeHtml,
mimePng,
mimeSvg
])
clipboard.changed.connect(clipboardItemModel.addItem)
engine = view.engine()
imageProvider = ClipboardItemModelImageProvider(clipboardItemModel)
engine.addImageProvider("items", imageProvider)
context = view.rootContext()
context.setContextProperty('clipboardItemModel', clipboardItemModel)
context.setContextProperty('clipboardItemModelFilterProxy', filterProxyModel)
context.setContextProperty('clipboard', clipboard)
view.setSource(QUrl.fromLocalFile('qml/MainWindow.qml'))
view.setGeometry(100, 100, 400, 240)
view.show()
engine.quit.connect(QGuiApplication.quit)
return app.exec_()
示例9: run
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import exec_ [as 别名]
def run():
signal.signal(signal.SIGINT, signal.SIG_DFL)
app = QGuiApplication(sys.argv)
view = QQuickView()
view.setTitle('Hot reloading demo')
qml_engine = view.rootContext().engine()
qml_engine.addImportPath(lib_dir_path)
notifier = HotReloadNotifier(demo_dir_path, qml_engine, parent=app)
view.rootContext().setContextProperty('hotReloadNotifier', notifier)
qml_url = QUrl.fromLocalFile(os.path.join(demo_dir_path, 'Demo.qml'))
view.setSource(qml_url)
view.show()
exit_code = app.exec_()
# notifier.stop() # seems like this is not needed
sys.exit(exit_code)
示例10: DAMAGES
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import exec_ [as 别名]
## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
## $QT_END_LICENSE$
##
#############################################################################
import sys
import os.path
from PyQt5.QtCore import QUrl
from PyQt5.QtGui import QGuiApplication
from PyQt5.QtQuick import QQuickView
#animation 폴더의 animation_rc 와 shared 폴더의 shared_rc를 import해온다.
from shared_rc import *
from animation_rc import *
if len(sys.argv) is 2:# 실행 옵션으로 파이썬도움말 절대경로 제공시
os.chdir(sys.argv[1])
app = QGuiApplication(sys.argv)
view = QQuickView()
view.engine().quit.connect(app.quit)
view.setSource(QUrl('animation.qml'))
view.show()
sys.exit(app.exec_())
示例11: print
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import exec_ [as 别名]
if DEBUG:
print('frozen', IS_FROZEN)
print('bundle dir is', BUNDLE_DIR)
print('sys.argv[0] is', sys.argv[0])
print('sys.executable is', sys.executable)
print('os.getcwd is', os.getcwd())
app = QGuiApplication(sys.argv)
MAINWINDOW_INSTANCE = PDFxGui()
# PdfDetailWindow("/tmp/some-test-funky.pdf", fake=True)
try:
status_code = app.exec_()
except:
# if this is packaged by PyInstaller, report crashes to sentry
if IS_FROZEN:
SENTRY.captureException()
raise
finally:
sys.exit(status_code)
# print(self.app)
# print(dir(self.app))
# self.app.setWindowIcon(QIcon("icon.ico"))
# self.app.setWindowTitle("Foo")
# self.app.setOrganizationName("Jeena")
# self.app.setOrganizationDomain("jeena.net")
# self.app.setApplicationName("FeedTheMonkey")
示例12: run
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import exec_ [as 别名]
def run(self):
engine = NetEaseEngine()
if self.qtype == "artist":
url = engine.searchCoverByArtistName(self.name)
elif self.qtype == "album":
url = engine.searchCoverByAlbumName(self.name)
coverWorker.receiveCover.emit(self.qtype, self.name, url)
if __name__ == "__main__":
app = QGuiApplication(sys.argv)
artists = []
for artist in db.get_cursor().execute("Select name from artist").fetchall():
artists.append(artist)
albums = []
for album in db.get_cursor().execute("Select name from album").fetchall():
albums.append(album)
for artist in artists:
d = DRunnable(artist, qtype="artist")
QThreadPool.globalInstance().start(d)
for album in albums:
d = DRunnable(album, qtype="album")
QThreadPool.globalInstance().start(d)
exitCode = app.exec_()
sys.exit(exitCode)
示例13: MyClass
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import exec_ [as 别名]
#!/usr/bin/python
# -*- coding: utf-8 -*-
from PyQt5.QtCore import QUrl, QObject, pyqtSlot
from PyQt5.QtGui import QGuiApplication
from PyQt5.QtQuick import QQuickView
class MyClass(QObject):
@pyqtSlot(int, result=str) # 声明为槽,输入参数为int类型,返回值为str类型
def returnValue(self, value):
"""
功能: 创建一个槽
参数: 整数value
返回值: 字符串
"""
return str(value+10)
if __name__ == '__main__':
path = 'demo.qml' # 加载的QML文件
app = QGuiApplication([])
view = QQuickView()
con = MyClass()
context = view.rootContext()
context.setContextProperty("con", con)
view.engine().quit.connect(app.quit)
view.setSource(QUrl(path))
view.show()
app.exec_()
示例14: QGuiApplication
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import exec_ [as 别名]
if __name__ == '__main__':
import sys
from Curves import BezierCurve
from Generators import JsonGenerator
app = QGuiApplication(sys.argv)
qmlRegisterType(ConsoleOutput, 'PyConsole', 1, 0, 'PyConsole')
qmlRegisterType(BezierCurve, 'Curves', 1, 0, 'BezierCurve')
qmlRegisterType(JsonGenerator, 'Generators', 1, 0, 'JsonGenerator')
view = QQuickView()
context = view.rootContext()
view.engine().quit.connect(app.quit)
view.setResizeMode(QQuickView.SizeRootObjectToView)
view.setSource(
QUrl.fromLocalFile('../view/visionai.qml')
)
view.show()
for error in view.errors():
print(error.toString())
status = app.exec_()
for error in view.errors():
print(error.toString())
sys.exit(status)
示例15: View
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import exec_ [as 别名]
class View(object):
shapes = ["rectangle", "ellipse", "image"]
edgetypes = ["line", "curve"]
def __init__(self):
self._controller = Controller(self)
self._gui = QGuiApplication(sys.argv)
self._qml_dir = os.path.dirname(os.path.realpath(__file__))
self._main = QQuickView()
self._main.setResizeMode(QQuickView.SizeRootObjectToView)
self._main.setSource(QUrl(self._qml_dir + '/main.qml'))
self._main.rootObject().create_node.connect(
self._controller.create_node)
self._main.rootObject().mouse_position.connect(
self._controller.mouse_position)
self._main.rootObject().save.connect(
self._controller.save)
self._main.rootObject().load.connect(
self._controller.load)
self._main.rootObject().lose_focus.connect(
self._controller.lose_focus)
self._main.rootObject().node_color_sel.connect(
self._controller.node_color_sel)
self._main.rootObject().edge_color_sel.connect(
self._controller.edge_color_sel)
self._main.rootObject().workspace_height_changed.connect(
self._controller.workspace_height_changed)
self._main.rootObject().workspace_width_changed.connect(
self._controller.workspace_width_changed)
self._main.rootObject().edge_type_sel.connect(
self._controller.edge_type_sel)
self._main.rootObject().node_shape_sel.connect(
self._controller.node_shape_sel)
self._main.rootObject().clear_workspace.connect(
self._controller.clear_workspace)
self._main.rootObject().node_width_changed.connect(
self._controller.node_width_changed)
self._main.rootObject().node_height_changed.connect(
self._controller.node_height_changed)
self._main.rootObject().node_text_color_sel.connect(
self._controller.node_text_color_sel)
self._main.rootObject().node_text_size_changed.connect(
self._controller.node_text_size_changed)
self._main.rootObject().edge_thickness_changed.connect(
self._controller.edge_thickness_changed)
self._main.rootObject().show_edge_controls.connect(
self._controller.show_edge_controls)
self._main.rootObject().hide_edge_controls.connect(
self._controller.hide_edge_controls)
self._main.rootObject().exporting.connect(
self._controller.exporting)
self._main.setProperty(
"width", self._controller.project.workspace_width)
self._main.setProperty(
"height", self._controller.project.workspace_height)
self._main.show()
def run(self):
return self._gui.exec_()
def create_node(self, node):
# Creates new node from source QML and puts it inside of main window
qml_node = QQuickView(QUrl(self._qml_dir + '/shapes/' +
self.shapes[node.shape] + '.qml'),
self._main)
workspace = self._main.rootObject().findChild(QQuickItem, "workspace")
# Sets all properties
qml_node.rootObject().setProperty("parent", workspace)
qml_node.rootObject().setProperty("objectId", str(node.id))
qml_node.rootObject().setProperty("background",
str(node.background))
qml_node.rootObject().setProperty("width", str(node.width))
qml_node.rootObject().setProperty("height", str(node.height))
qml_node.rootObject().setProperty("text", str(node.text.text))
qml_node.rootObject().setProperty("textFont", str(node.text.font))
qml_node.rootObject().setProperty("textSize", str(node.text.size))
qml_node.rootObject().setProperty("textColor", str(node.text.color))
# Sets drag boundaries
qml_node.rootObject().setProperty("workspaceWidth",
str(workspace.property("width")))
qml_node.rootObject().setProperty("workspaceHeight",
str(workspace.property("height")))
# Signal connection
qml_node.rootObject().node_delete.connect(
self._controller.node_delete)
qml_node.rootObject().node_text_changed.connect(
self._controller.node_text_changed)
qml_node.rootObject().node_position_changed.connect(
self._controller.node_position_changed)
qml_node.rootObject().node_connect.connect(
self._controller.node_connect)
qml_node.rootObject().node_focus.connect(
self._controller.node_focus)
#.........这里部分代码省略.........