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


Python QQuickView.setSource方法代码示例

本文整理汇总了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()
开发者ID:HenryHu,项目名称:xmradio,代码行数:55,代码来源:gui.py

示例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)
开发者ID:jefperito,项目名称:amaru,代码行数:17,代码来源:start_page.py

示例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)
开发者ID:sevanteri,项目名称:tabletShortcuts,代码行数:49,代码来源:tabletShortcuts.py

示例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)
开发者ID:centaurialpha,项目名称:pireal,代码行数:19,代码来源:start_page.py

示例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)
开发者ID:centaurialpha,项目名称:pireal,代码行数:20,代码来源:message_error.py

示例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_()
开发者ID:gorilux,项目名称:LinuxCNC-QML,代码行数:21,代码来源:qmlgui.py

示例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_())
开发者ID:fadawar,项目名称:worship-prototype,代码行数:22,代码来源:__init__.py

示例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
开发者ID:GrandHsu,项目名称:demoQMLPyQt,代码行数:22,代码来源:qmlMaster.py

示例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()
开发者ID:ivanalejandro0,项目名称:bitmask_gui2,代码行数:23,代码来源:app.py

示例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_()
开发者ID:hluk,项目名称:infinitecopy,代码行数:42,代码来源:infinitecopy.py

示例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)
开发者ID:bgr,项目名称:qml_hot_reload,代码行数:24,代码来源:main.py

示例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_())
开发者ID:harry159821,项目名称:PyQt_3D,代码行数:25,代码来源:main.py

示例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_())
开发者ID:binwen925,项目名称:QMusic,代码行数:32,代码来源:main.py

示例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()
开发者ID:malachib,项目名称:dashboard.qt,代码行数:32,代码来源:main.py

示例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_())
开发者ID:nzmm,项目名称:invoiceitx,代码行数:32,代码来源:main.py


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