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


Python QQuickView.engine方法代码示例

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


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

示例1: add_qml_import_path

# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import engine [as 别名]
    def add_qml_import_path(self, view: QQuickView) -> None:
        """
        Manually set the path to the QML folder to fix errors with unicode paths.
        This is needed only on Windows when packaged with Nuitka.
        """
        if Options.freezer != "nuitka":
            return

        qml_dir = Options.res_dir.parent / "PyQt5" / "Qt" / "qml"
        log.debug(f"Setting QML import path for {view} to {qml_dir!r}")
        view.engine().addImportPath(str(qml_dir))
开发者ID:nuxeo,项目名称:nuxeo-drive,代码行数:13,代码来源:application.py

示例2: TabletShortcuts

# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import engine [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

示例3: main

# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import engine [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

示例4: main

# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import engine [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

示例5: DAMAGES

# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import engine [as 别名]
## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
## 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_())
开发者ID:louisraccoon,项目名称:PyStudy,代码行数:33,代码来源:animation.py

示例6: QQmlEngine

# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import engine [as 别名]
    # Show the Label
    appLabel.show()
    
    # Create a QML engine.
    engine = QQmlEngine()
    
    # Initialize PhotoBoothEngine.
    pbengine = PhotoBoothEngine()
    pbengine.on_status.connect(appLabel.rootObject().status)
    pbengine.on_update_filter_preview.connect(appLabel.rootObject().updateImageFilterPreview)
    
    appLabel.rootContext().setContextProperty('pbengine', pbengine)

    # Create a component factory and load the QML script.
    print("Hello")
    component = QQmlComponent(appLabel.engine())
    component.loadUrl(QUrl('TextStatusFly.qml'))
    
    print("Hello2")
    asdf = component.create(appLabel.rootContext())
    
    print("Hello3")
    asdf.setParentItem(appLabel.rootObject())
    asdf.setParent(appLabel.rootObject())
    
    print("Hello4")
    #asdf.setProperty("targetX", 100)
    asdf.setProperty("objectName", "textStatusBar")
    
    print("Hello5")
    appLabel.rootContext().setContextProperty('textStatusBar', asdf)
开发者ID:UMDIEEE,项目名称:MDayPhotobooth,代码行数:33,代码来源:main.py

示例7: USBPrinterManager

# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import engine [as 别名]
class USBPrinterManager(QObject, SignalEmitter, Extension):
    def __init__(self, parent = None):
        super().__init__(parent)
        self._serial_port_list = []
        self._printer_connections = []
        self._check_ports_thread = threading.Thread(target = self._updateConnectionList)
        self._check_ports_thread.daemon = True
        self._check_ports_thread.start()
        
        self._progress = 0

        self._control_view = None
        self._firmware_view = None
        self._extruder_temp = 0
        self._bed_temp = 0
        self._error_message = "" 
        
        ## Add menu item to top menu of the application.
        self.setMenuName("Firmware")
        self.addMenuItem(i18n_catalog.i18n("Update Firmware"), self.updateAllFirmware)
    
    pyqtError = pyqtSignal(str, arguments = ["amount"])
    processingProgress = pyqtSignal(float, arguments = ["amount"])
    pyqtExtruderTemperature = pyqtSignal(float, arguments = ["amount"])
    pyqtBedTemperature = pyqtSignal(float, arguments = ["amount"])
    
    ##  Show firmware interface.
    #   This will create the view if its not already created.
    def spawnFirmwareInterface(self, serial_port):
        if self._firmware_view is None:
            self._firmware_view = QQuickView()
            self._firmware_view.engine().rootContext().setContextProperty("manager",self)
            self._firmware_view.setSource(QUrl("plugins/USBPrinting/FirmwareUpdateWindow.qml"))
        self._firmware_view.show()
    
    ##  Show control interface.
    #   This will create the view if its not already created.
    def spawnControlInterface(self,serial_port):
        if self._control_view is None:
            self._control_view = QQuickView()
            self._control_view.engine().rootContext().setContextProperty("manager",self)
            self._control_view.setSource(QUrl("plugins/USBPrinting/ControlWindow.qml"))
        self._control_view.show()

    @pyqtProperty(float,notify = processingProgress)
    def progress(self):
        return self._progress

    @pyqtProperty(float,notify = pyqtExtruderTemperature)
    def extruderTemperature(self):
        return self._extruder_temp

    @pyqtProperty(float,notify = pyqtBedTemperature)
    def bedTemperature(self):
        return self._bed_temp

    @pyqtProperty(str,notify = pyqtError)
    def error(self):
        return self._error_message
    
    ##  Check all serial ports and create a PrinterConnection object for them.
    #   Note that this does not validate if the serial ports are actually usable!
    #   This (the validation) is only done when the connect function is called.
    def _updateConnectionList(self):  
        while True: 
            temp_serial_port_list = self.getSerialPortList(only_list_usb = True)
            if temp_serial_port_list != self._serial_port_list: # Something changed about the list since we last changed something.
                disconnected_ports = [port for port in self._serial_port_list if port not in temp_serial_port_list ]
                self._serial_port_list = temp_serial_port_list
                for serial_port in self._serial_port_list:
                    if self.getConnectionByPort(serial_port) is None: # If it doesn't already exist, add it
                        if not os.path.islink(serial_port): # Only add the connection if it's a non symbolic link
                            connection = PrinterConnection.PrinterConnection(serial_port)
                            connection.connect()
                            connection.connectionStateChanged.connect(self.serialConectionStateCallback)
                            connection.progressChanged.connect(self.onProgress)
                            connection.onExtruderTemperatureChange.connect(self.onExtruderTemperature)
                            connection.onBedTemperatureChange.connect(self.onBedTemperature)
                            connection.onError.connect(self.onError)
                            self._printer_connections.append(connection)
                
                for serial_port in disconnected_ports: # Close connections and remove them from list.
                    connection = self.getConnectionByPort(serial_port)
                    if connection != None:
                        self._printer_connections.remove(connection)
                        connection.close()
            time.sleep(5) # Throttle, as we don"t need this information to be updated every single second.
    
    def updateAllFirmware(self):
        self.spawnFirmwareInterface("")
        for printer_connection in self._printer_connections:
            printer_connection.updateFirmware(Resources.getPath(Resources.FirmwareLocation, self._getDefaultFirmwareName()))
            
    def updateFirmwareBySerial(self, serial_port):
        printer_connection = self.getConnectionByPort(serial_port)
        if printer_connection is not None:
            self.spawnFirmwareInterface(printer_connection.getSerialPort())
            printer_connection.updateFirmware(Resources.getPath(Resources.FirmwareLocation, self._getDefaultFirmwareName()))
        
    def _getDefaultFirmwareName(self):
#.........这里部分代码省略.........
开发者ID:BjoernT,项目名称:Cura,代码行数:103,代码来源:USBPrinterManager.py

示例8: P2CQMLApplication

# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import engine [as 别名]
class P2CQMLApplication(QGuiApplication):
    def __init__(self, list_of_str):
        super().__init__(list_of_str)
        self._current_category = None
        self._current_torrent = None
        self._current_torrent_info = None
        self._status_timer = QTimer(self)
        self._movies_thread = None
        self._search_thread = None

    def run_view(self):
        self._view = QQuickView()
        self._view.engine().addImportPath("qml")
        self._rctx = self._view.rootContext()
        self._view.setResizeMode(QQuickView.SizeRootObjectToView)

        # set context variables
        self.categories = []
        self._rctx.setContextProperty("categoriesModel", self.categories)
        self.tiles = []
        self.torrents = []
        self._rctx.setContextProperty("moviesModel", self.tiles)
        self._set_loading(False)
        self._view.setSource(QUrl('qrc:/qml.qml'))
        self._view.showFullScreen()
#        self._view.show()

    def connect_daemon(self, daemon: P2CDaemon):
        self._daemon = daemon
        self._set_categories()
        self._connect_signals()

    def play(self, movie: Movie):
        self._set_movie_status("Ready to play!")
        self._set_media(movie)
        self._daemon.play(movie)
        self._set_additional_media_info()

    def buffer(self, movie: Movie):
        seconds = self._current_torrent.get_seconds_to_buffer()
        info = "just started"
        if seconds:
            if seconds < 15:
                info = "just a moment"
            else:
                # rount to minutes
                minutes = int(seconds / 60) + 1
                if minutes == 1:
                    info = "1 minute"
                else:
                    info = "{} minutes".format(minutes)
        self._set_movie_status("Buffering... ({})".format(info))
        self._daemon.buffer(movie)
        self._set_additional_media_info()

    def wait_for_metadata(self):
        self._set_movie_status("Getting metadata...")
        if self._current_torrent:
            self._set_additional_media_info(self._current_torrent.name)

    def select_movie(self, torrent: Torrent) -> Movie:
        movies = torrent.get_movies()
        if len(movies) == 0:
            return
        # TODO: show dialog with movie selecting instead of doing it automatically
        return max(movies, key=lambda x: x.size)

    def update_status(self):
        torrent = self._current_torrent
        if torrent:
            if(torrent.has_torrent_info()):
                movie = self.select_movie(torrent)
                if not movie:
                    self._set_movie_status("No movie in this torrent. Please, select another.")
                    return

                torrent.download_file(movie.path)
                self._set_duration(movie)
                if not self._daemon.is_playing(movie):
                    if(movie.can_play()):
#                        print(movie.get_subtitles())
                        self.play(movie)
                    else:
                        self.buffer(movie)

                ### DEBUG INFO
                text = "s: %s, num p: %s, rate: %s kbs, p_rate: %s kbs" % (
                    torrent.get_status()['state'],
                    torrent.get_status()['num_peers'],
                    int(torrent.get_status()['download_rate'] / 1024),
                    int(torrent.get_status()['download_payload_rate'] / 1024),
                    )
                self._view.rootObject().setProperty("debugText", text)
                ### END DEBUG INFO

            else:
                self.wait_for_metadata()
        else:
            self.wait_for_metadata()

#.........这里部分代码省略.........
开发者ID:rafallo,项目名称:p2c,代码行数:103,代码来源:app.py

示例9: newUUID

# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import engine [as 别名]
	def newUUID(self):
		return QUuid.createUuid().toString()
		

if __name__ == '__main__':
	import os
	import sys

	app = QGuiApplication(sys.argv)
	app.setLayoutDirection(Qt.RightToLeft);


	view = QQuickView()
	context = view.rootContext()
	
	view.engine().setOfflineStoragePath(".")
	
	exutil = LauncherEXUtils()
	qmlRegisterType(LauncherEXUtils, 'ExUtils', 1, 0, 'ExUtils')
	qmlRegisterType(Bozorgrah,'Bozorgrah',1,0,'Bozorgrah')
	context.setContextProperty('exutils',exutil)
	
	view.setResizeMode(QQuickView.SizeRootObjectToView)
	try:
		approot = os.path.dirname(os.path.abspath(__file__))
	except NameError:  # We are the main py2exe script, not a module
		approot = os.path.dirname(os.path.abspath(sys.argv[0]))
	print(approot)
	view.setSource(
			QUrl.fromLocalFile(
					os.path.join(approot,'qml\\app.qml')))
开发者ID:meahmadi,项目名称:launcher,代码行数:33,代码来源:launcher.py


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