本文整理汇总了Python中PyQt5.QtQuick.QQuickView.setSource方法的典型用法代码示例。如果您正苦于以下问题:Python QQuickView.setSource方法的具体用法?Python QQuickView.setSource怎么用?Python QQuickView.setSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtQuick.QQuickView
的用法示例。
在下文中一共展示了QQuickView.setSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LoginWin
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setSource [as 别名]
class LoginWin(QtCore.QObject):
def __init__(self, state, app):
QtCore.QObject.__init__(self)
self.state = state
self.app = app
# Create the QML user interface.
self.login_win = QQuickView()
self.login_win.setTitle(self.tr("Xiami Login"))
self.login_win.setSource(QUrl('login.qml'))
self.login_win.setResizeMode(QQuickView.SizeRootObjectToView)
self.login_win.show()
# Connect signals
self.root_obj = self.login_win.rootObject()
self.root_obj.loginClicked.connect(self.login_clicked)
self.root_obj.exitClicked.connect(self.exit_clicked)
def set_state(self, msg):
self.root_obj.setStatus(msg)
def exit_clicked(self):
sys.exit(0)
def login_clicked(self, username, password):
code = self.root_obj.getVerificationCode()
if code != "":
try:
login.login_with_code(self.state, self.key, code)
except Exception as e:
self.set_state(e.message)
self.root_obj.hideCode()
return
self.ok()
else:
try:
ret = login.login(self.state, username, password)
except Exception as e:
self.set_state(e.message)
return
if not ret[0]:
with open(login.img_path, 'wb') as imgf:
imgf.write(ret[2])
self.set_state(self.tr("Please enter verification code"))
self.root_obj.setVerificationImage("file://%s"
% login.img_path)
self.key = ret[1]
else:
self.ok()
def ok(self):
self.login_win.close()
self.app.auth_ok()
示例2: __init__
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setSource [as 别名]
def __init__(self):
super(QmlStartPage, self).__init__()
box = QVBoxLayout(self)
box.setContentsMargins(0, 0, 0, 0)
# View
view = QQuickView()
view.setSource(QUrl.fromLocalFile(PATH_QML))
view.setResizeMode(QQuickView.SizeRootObjectToView)
# Root object
self._root = view.rootObject()
widget_container = QWidget.createWindowContainer(view)
box.addWidget(widget_container)
self._root.animationFinished.connect(self._on_animation_finished)
示例3: TabletShortcuts
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setSource [as 别名]
class TabletShortcuts(QGuiApplication):
def __init__(self, argv):
QGuiApplication.__init__(self, argv)
self.view = QQuickView()
self.bus = QDBusConnection.sessionBus()
self.server = MyDBUSServer(self)
self.bus.registerObject("/app", self.server)
self.bus.registerService("sevanteri.TabletShortcuts")
self.view.setTitle("TabletShortcuts")
self.view.setResizeMode(QQuickView.SizeRootObjectToView)
self.view.setSource(QUrl('main.qml'))
self.root = self.view.rootObject()
self.showView()
self.root.runCommand.connect(self.run)
self.root.hideView.connect(self.view.hide)
self.view.engine().quit.connect(self.quit)
def run(self, cmd):
return Popen(shlex.split(cmd))
def quit(self):
self.exit()
def showView(self):
if self.view.isVisible():
self.view.hide()
else:
# width, height = TabletShortcuts.getScreenGeometry()
# self.view.setGeometry(1, 1, width, height)
self.view.show()
def getScreenGeometry():
output = Popen("xrandr | grep 'current'", shell=True, stdout=PIPE)\
.communicate()[0].decode('UTF-8')
m = re.search('current.([0-9]+).x.([0-9]+)', output)
width = int(m.group(1))
height = int(m.group(2))
return (width, height)
示例4: __init__
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setSource [as 别名]
def __init__(self):
super(StartPage, self).__init__()
vbox = QVBoxLayout(self)
vbox.setContentsMargins(0, 0, 0, 0)
view = QQuickView()
qml = os.path.join(settings.QML_PATH, "StartPage.qml")
view.setSource(QUrl.fromLocalFile(qml))
view.setResizeMode(QQuickView.SizeRootObjectToView)
widget = QWidget.createWindowContainer(view)
vbox.addWidget(widget)
self.__root = view.rootObject()
# Connections
self.__root.openDatabase.connect(self.__open_database)
self.__root.newDatabase.connect(self.__new_database)
self.__root.removeCurrent.connect(self.__remove_current)
示例5: __init__
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setSource [as 别名]
def __init__(self, parent=None):
super(MessageError, self).__init__(parent,
Qt.Dialog | Qt.FramelessWindowHint)
self._parent = parent
self.setModal(True)
self.setFixedHeight(150)
self.setFixedWidth(350)
box = QVBoxLayout(self)
box.setContentsMargins(0, 0, 0, 0)
view = QQuickView()
qml = os.path.join(settings.QML_PATH, "MessageError.qml")
view.setSource(QUrl.fromLocalFile(qml))
view.setResizeMode(QQuickView.SizeRootObjectToView)
self.widget = QWidget.createWindowContainer(view)
box.addWidget(self.widget)
self._root = view.rootObject()
self._root.close.connect(self.close)
示例6: main
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setSource [as 别名]
def main():
app = QApplication(sys.argv)
# Register the Python type.
# qmlRegisterType(Hal.Component, 'Hal', 1, 0, 'Component')
# qmlRegisterType(Hal.Pin, 'Hal', 1, 0, 'Pin')
qmlRegisterType(Stat.Stat, 'LinuxCNC', 1, 0, 'Stat')
qmlRegisterType(Axis.Axis, 'LinuxCNC', 1, 0, 'Axis')
qmlRegisterType(Command.Command, 'LinuxCNC', 1, 0, 'Command')
qmlRegisterType(ErrorChannel.ErrorChannel, 'LinuxCNC', 1, 0, 'ErrorChannel')
quickview = QQuickView()
quickview.setSource(QUrl('gui/qml/main.qml'))
quickview.showFullScreen()
quickview.engine().quit.connect(app.quit)
app.exec_()
示例7: run_app
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setSource [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: quickViewForQML
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setSource [as 别名]
def quickViewForQML(self, qmlFilename, transientParent=None):
'''
Create a QQuickView for qmlFilename.
More robust: connects to error
'''
quickView = QQuickView()
quickView.statusChanged.connect(self.onStatusChanged)
qurl = resourceMgr.urlToQMLResource(resourceSubpath=qmlFilename)
quickView.setSource(qurl)
'''
Show() the enclosing QWindow?
But this means the window for e.g. the toolbar is visible separately?
'''
#quickView.show()
print("Created QQuickView for:", qurl.path())
if transientParent is not None:
quickView.setTransientParent(transientParent)
return quickView
示例9: MainWindow
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setSource [as 别名]
class MainWindow(QtCore.QObject):
def __init__(self):
QtCore.QObject.__init__(self)
self._controller = Controller()
self.view = QQuickView()
full_path = os.path.realpath(__file__)
folder = os.path.dirname(full_path)
qml_file = os.path.join(folder, 'qml', 'App.qml')
qml_qurl = QtCore.QUrl.fromLocalFile(qml_file)
self.view.setSource(qml_qurl)
# Add context properties to use this objects from qml
rc = self.view.rootContext()
rc.setContextProperty('controller', self._controller)
def show(self):
self.view.show()
示例10: main
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setSource [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_()
示例11: run
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setSource [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)
示例12: QApplication
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setSource [as 别名]
# -*- coding: utf-8 -*-
#from PyQt5.QtGui import QApplication
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QVariant, QUrl, QDir
from PyQt5.QtQml import QQmlApplicationEngine, QQmlEngine
from PyQt5.QtQuick import QQuickView, QQuickItem, QQuickWindow
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
viewer = QQuickView()
viewer.setSource(QUrl("main.qml"))
viewer.setTitle("Material Demo QML")
viewer.engine().quit.connect(app.quit)
viewer.resize(500, 500)
viewer.setResizeMode(QQuickView.SizeRootObjectToView)
viewer.show()
sys.exit(app.exec_())
示例13: initData
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setSource [as 别名]
def initData(self):
objs = []
for i in range(10):
objdict = {
'name': 'qwe%s' % i,
'count': i,
'cover': '/home/djf/jjk/',
'songs': {'song': '1111'}
}
obj = self.dataTye(**objdict)
objs.append(obj)
self.data = objs
if __name__ == '__main__':
import sys
app = QGuiApplication(sys.argv)
view = QQuickView()
view.setResizeMode(QQuickView.SizeRootObjectToView)
ctxt = view.rootContext()
myListModel = ListModel(QmlArtistObject)
ctxt.setContextProperty('myListModel', myListModel)
view.setSource(QUrl('ListShow.qml'))
view.show()
sys.exit(app.exec_())
示例14: QQmlComponent
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setSource [as 别名]
component = QQmlComponent(engine)
component.loadUrl(QUrl('WeatherDash.qml'))
# Create the QML user interface. Auto creates its own engine
view = QQuickView()
engine2 = view.engine
# Does not run
#engine2.quit.connect(app.quit)
#view.setSource(QUrl('PyTest.qml'))
# To Satisfy cool-retro-term needs
view.rootContext().setContextProperty('devicePixelRatio', app.devicePixelRatio())
view.setSource(QUrl('WeatherDash.qml'))
#view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
view.setGeometry(100, 100, 750, 480)
# ala https://pythonspot.com/pyqt5-colors/
view.setColor(QColor(0, 30, 0))
view.show()
is_full_screen = False
# technique lifted from https://stackoverflow.com/questions/19131084/pyqt5-qml-signal-to-python-slot
# and augmented from https://stackoverflow.com/questions/30586983/how-to-close-pyqt5-program-from-qml
# could refine with https://stackoverflow.com/questions/24111717/how-to-bind-buttons-in-qt-quick-to-python-pyqt-5
# not 100% ideal, but adequate and interesting
def on_quit():
app.quit()
示例15: QApplication
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setSource [as 别名]
from PyQt5.QtQuick import QQuickView
from PyQt5.QtWidgets import QApplication
from qtypes.argv import ArgParser
from qtypes.vend import Vend
if __name__ == '__main__':
# Reminder to self, see link for why we avoid a 'main' function here
# http://pyqt.sourceforge.net/Docs/PyQt5/pyqt4_differences.html#object-destruction-on-exit
app = QApplication(sys.argv)
print(sys.version)
print("InvoiceIt")
root = os.path.dirname(__file__)
app.setApplicationName("InvoiceIt")
app.setApplicationDisplayName("InvoiceIt")
app.setApplicationVersion("0.1")
view = QQuickView()
qmlRegisterType(ArgParser, "ArgV", 1, 0, "ArgParser")
qmlRegisterType(Vend, "Vend", 1, 0, "Vendor")
f = QUrl.fromLocalFile(join(root, 'qml', 'main.qml'))
view.setResizeMode(QQuickView.SizeRootObjectToView)
view.setSource(f)
view.show()
sys.exit(app.exec_())