def registerTypes(self, uri):
        sys.stderr.write(
            'exampleqmlitemplugin.py debug: ExampleQmlItemPlugin.registerTypes(): uri - {!r}\n'
            .format(uri))
        sys.stderr.flush()
        try:
            QtQml.qmlRegisterType(
                pyqt5_plugins.examples.exampleqmlitem.ExampleQmlItem,
                'examples',
                1,
                0,
                'ExampleQmlItem',
            )
        except Exception as e:
            sys.stderr.write(
                'exampleqmlitemplugin.py debug: ExampleQmlItemPlugin.registerTypes(): exception - {!r}\n'
                .format(e))
            sys.stderr.flush()
            traceback.print_exc(file=sys.stderr)
            sys.stderr.flush()
            raise

        sys.stderr.write(
            'exampleqmlitemplugin.py debug: ExampleQmlItemPlugin.registerTypes(): about to return None\n'
        )
        sys.stderr.flush()
        return None
Esempio n. 2
0
 def registerTypes(self, uri):
     QtQml.qmlRegisterType(
         pyqt5_tools.examples.exampleqmlitem.ExampleQmlItem,
         'examples',
         1,
         0,
         'ExampleQmlItem',
     )
Esempio n. 3
0
    def __init__(self, argv):
        super(Application, self).__init__(argv)

        self._console_ctrl = console.Controller()
        self._tray = None
        self._popen = None
        self._window = None

        # Virtual host properties
        self._vhost_ctrl = virtual_host.Controller()

        with open(self.THEMEPATH) as f:
            self._theme = json.load(f)

        self.engine = QtQml.QQmlApplicationEngine()
        self.engine.addImportPath(self.QMLPATH)
        self.engine.objectCreated.connect(self.on_object_created)

        self.focusWindowChanged.connect(self.on_focus_changed)
        self._console_ctrl.autohideChanged.connect(self.on_autohide_changed)

        context = self.engine.rootContext()
        context.setContextProperty("applicationTheme", self._theme)
        context.setContextProperty("consoleCtrl", self._console_ctrl)
        context.setContextProperty("hostCtrl", self._vhost_ctrl)

        # Toggles
        self.toggles = {"autoHide": True}

        # Timers
        keep_visible = QtCore.QTimer(self)
        keep_visible.setInterval(1000)
        keep_visible.setSingleShot(True)

        self.timers = {"keepVisible": keep_visible}
Esempio n. 4
0
 def __init__(self,
              qmlSrc: Union[str, Path],
              qmlFile: Optional[Union[str, Path, QtCore.QUrl]] = None,
              parent: QtCore.QObject = None):
     """Parameters
     ----------
     qmlSrc
         Either QML source code or :py:class:`Path` pointing to source
         file.
     qmlFile
         If `qmlSrc` is source code, behave as if it had been loaded from a
         file named `qmlFile`.
     parent
         Parent QObject
     """
     super().__init__(parent)
     self._status = self.Status.Error
     if qmlFile is None:
         qmlFile = QtCore.QUrl()
     elif isinstance(qmlFile, (str, Path)):
         qmlFile = QtCore.QUrl.fromLocalFile(str(qmlFile))
     self._engine = QtQml.QQmlApplicationEngine()
     self._engine.addImportPath(qmlPath)
     useBundledIconTheme()
     self._engine.objectCreated.connect(self._instanceCreated)
     # TODO: A user can only connect to status_Changed after __init__
     # finishes and will therefore miss this signal and also the one
     # emitted by _instanceCreated. Maybe add callback parameter to
     # __init__?
     self._status = self.Status.Loading
     self.status_Changed.emit(self._status)
     if isinstance(qmlSrc, Path):
         self._engine.load(str(qmlSrc))
     else:
         self._engine.loadData(qmlSrc.encode(), qmlFile)
    def __init__(self, source, root=None):
        super(Launcher, self).__init__()

        engine = QtQml.QQmlApplicationEngine()
        engine.objectCreated.connect(self.on_object_created)
        # engine.warnings.connect(self.on_warnings)
        engine.addImportPath(QML_IMPORT_DIR)

        try:
            io.install()
        except IOError:
            raise  # Server refused to connect

        # Install actions
        from . import install
        install()

        terminal.init()
        app_root = os.path.dirname(__file__).replace('\\', '/')
        res_path = "file:///{}/res/".format(app_root)

        controller = control.Controller(root, self)
        engine.rootContext().setContextProperty("controller", controller)
        engine.rootContext().setContextProperty("terminal", terminal.model)
        engine.rootContext().setContextProperty("res_path", res_path)

        self._icon = QtGui.QIcon(ICON_PATH)
        self._tray = None
        self.window = None
        self.engine = engine
        self.controller = controller
        # self.window = object
        self.controller.init()
        engine.load(QtCore.QUrl.fromLocalFile(source))
Esempio n. 6
0
    def __init__(self, root, source):
        super(Application, self).__init__(sys.argv)
        self.setWindowIcon(QtGui.QIcon(ICON_PATH))

        engine = QtQml.QQmlApplicationEngine()
        engine.objectCreated.connect(self.on_object_created)
        engine.warnings.connect(self.on_warnings)
        engine.addImportPath(QML_IMPORT_DIR)

        try:
            io.install()
        except IOError:
            raise  # Server refused to connect

        # Install actions
        from . import install
        install()

        terminal.init()

        controller = control.Controller(root, self)
        engine.rootContext().setContextProperty("controller", controller)
        engine.rootContext().setContextProperty("terminal", terminal.model)

        self._tray = None
        self.window = None
        self.engine = engine
        self.controller = controller

        engine.load(QtCore.QUrl.fromLocalFile(source))

        self.setQuitOnLastWindowClosed(False)
Esempio n. 7
0
    def __init__(self, gates=None, allow_mouse_wheel_updates: bool = True):
        """ Parameter viewer for gates

        Args:
            gates: Gate instrument to use. If None, use qcodes.Station.default.gates
            allow_mouse_wheel_updates: If True, then allow changing parameter values using mouse scrolling
        """
        super().__init__()
        self.app = QtCore.QCoreApplication.instance()
        self.instance_ready = True

        if self.app is None:
            self.instance_ready = False
            self.app = QtWidgets.QApplication([])

        self.engine = QtQml.QQmlApplicationEngine()

        if gates is None:
            if hasattr(qc.Station.default, 'gates'):
                gates = qc.Station.default.gates
            else:
                raise ValueError(
                    'No gates Instrument found in the station, pleasse add manually.'
                )

        self.real_gate_model = gate_model(
            gates,
            list(gates.hardware.dac_gate_map.keys()),
            allow_mouse_wheel_updates=allow_mouse_wheel_updates)
        self.engine.rootContext().setContextProperty("real_gate_model",
                                                     self.real_gate_model)

        v_gates = list()
        for i in gates.v_gates.values():
            v_gates += i

        self.virtual_gate_model = gate_model(
            gates,
            v_gates,
            allow_mouse_wheel_updates=allow_mouse_wheel_updates)
        self.engine.rootContext().setContextProperty("virtual_gate_model",
                                                     self.virtual_gate_model)

        self.engine.rootContext().setContextProperty("param_viewer", self)

        filename = os.path.join(qml_in.__file__[:-12], "param_viewer.qml")
        self.engine.load(QtCore.QUrl.fromLocalFile(filename))
        self.win = self.engine.rootObjects()[0]

        self.timer_real = QtCore.QTimer()
        self.timer_real.timeout.connect(self.real_gate_model.update_model)
        self.timer_real.start(500)
        self.timer_virt = QtCore.QTimer()
        self.timer_virt.timeout.connect(self.virtual_gate_model.update_model)
        self.timer_virt.start(500)

        if self.instance_ready == False:
            self.app.exec_()
            print('exec')
Esempio n. 8
0
    def __init__(self, parent=None):
        QtWidgets.QWidget.__init__(self, parent)
        # QtQml.qmlRegisterType(ViewConfig, 'ViewConfig', 1, 0, 'ViewConfig')
        self.view = QtQuickWidgets.QQuickWidget(self)
        rootCtx = self.view.rootContext()
        self.cfg = ViewConfig(self)
        self.msgStack = MessageStack(self)
        rootCtx.setContextProperty('viewConfig', self.cfg)
        QtQml.qmlRegisterType(MessageItem, 'Message', 1, 0, 'Message')
        QtQml.qmlRegisterType(MessageStack, 'Message', 1, 0, 'Store')
        rootCtx.setContextProperty('msgStack', self.msgStack)
        self.view.setSource(QtCore.QUrl("qrc:///qml/message-view.qml"))
        # self.view.show()

        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.repaint)
        self.timer.start(50)
Esempio n. 9
0
def main(qml_file="millerLauncher.qml", path=""):
    # _root = os.path.abspath(path)
    # List._root = os.path.abspath(path)

    # Show QML Window
    full_directory = os.path.dirname(os.path.abspath(__file__))

    app = pigui.pyqt5.widget.QApplication(sys.argv)
    # app = QtWidgets.QApplication(sys.argv)

    QtQml.qmlRegisterType(Controller, 'Controller', 1, 0, 'Controller')
    engine = QtQml.QQmlApplicationEngine()
    qml_file = os.path.join(full_directory, qml_file)
    engine.load(str(qml_file))
    window = engine.rootObjects()[0]
    window.show()
    sys.exit(app.exec_())
Esempio n. 10
0
 def _load_qml(self, engine, qml_file):
     self._component = QtQml.QQmlComponent(engine)
     url = QtCore.QUrl(
         os.path.dirname(os.path.realpath(__file__)) + "/" + qml_file)
     # Apparently QQmlEngine caches loaded components so there shouldn't
     # be a big performance penalty creating many instances of the same
     # component using this code.
     self._component.loadUrl(url, QtQml.QQmlComponent.PreferSynchronous)
     if self._component.isError():
         for error in self._component.errors():
             print(error.toString())
Esempio n. 11
0
 def initWebengine(self):
     component = QtQml.QQmlComponent(self.engine())
     component.setData('''
         import QtQuick 2.4
         import WebEngineWrapper 1.0
         WebEngineWrapper {
             Component.onCompleted: {
                 initialize()
             }
         }
     ''', QtCore.QUrl(''))
     item = component.create()
     item.setParentItem(self.rootObject())
Esempio n. 12
0
    def __init__(self):
        super().__init__()
        self.app = QtCore.QCoreApplication.instance()
        self.instance_ready = True
        if self.app is None:
            self.instance_ready = False
            self.app = QtWidgets.QApplication([])

        self.engine = QtQml.QQmlApplicationEngine()

        self.date_model = date_model([])
        self.data_overview_model = data_overview_model([])

        self.project_model = combobox_model(['any', sample_info.project])
        self.set_up_model = combobox_model(['any', sample_info.set_up])
        self.sample_model = combobox_model(['any', sample_info.sample])

        self.signal_handler = signale_handler(self.project_model,
                                              self.set_up_model,
                                              self.sample_model,
                                              self.date_model,
                                              self.data_overview_model)

        self.engine.rootContext().setContextProperty("combobox_project_model",
                                                     self.project_model)
        self.engine.rootContext().setContextProperty("combobox_set_up_model",
                                                     self.set_up_model)
        self.engine.rootContext().setContextProperty("combobox_sample_model",
                                                     self.sample_model)

        self.engine.rootContext().setContextProperty("date_list_model",
                                                     self.date_model)
        self.engine.rootContext().setContextProperty("data_content_view_model",
                                                     self.data_overview_model)

        self.engine.rootContext().setContextProperty("local_conn_status", True)
        self.engine.rootContext().setContextProperty("remote_conn_status",
                                                     True)

        self.engine.rootContext().setContextProperty("signal_handler",
                                                     self.signal_handler)

        # grab directory from the import!
        filename = os.path.join(qml_in.__file__[:-11], "data_browser.qml")
        self.engine.load(QtCore.QUrl.fromLocalFile(filename))
        self.win = self.engine.rootObjects()[0]
        self.signal_handler.init_gui_variables(self.win)

        if self.instance_ready == False:
            self.app.exec_()
            print('exec')
Esempio n. 13
0
    def __init__(self, args, qml: str):
        """
        Args:
            args: system level arguments
            qml : main qml file
        """
        self._app = create_application(args)
        self._engine = QtQml.QQmlApplicationEngine()
        self._settings = ApplicationSettings()
        self._engine.rootContext().setContextProperty("qtVersion", QtCore.QT_VERSION_STR)

        self.register_qml_types()

        self._engine.load(QtCore.QUrl(qml))
        assert(len(self._engine.rootObjects()) > 0)
    def launch(self):
        global VhclSpeed
        myApp = QtGui.QGuiApplication(sys.argv)
        myEngine = QtQml.QQmlApplicationEngine()
        self.manager = SpeedMeterManager()
        myEngine.rootContext().setContextProperty("smManager", self.manager)
        directory = os.path.dirname(os.path.abspath(__file__))
        myEngine.load(QtCore.QUrl.fromLocalFile(os.path.join(directory, 'speedMeter.qml')))
    
        if not myEngine.rootObjects():
            return -1
        self.dashB = myEngine.rootObjects()[0]
        timer = QtCore.QTimer(interval=500)
#         timer.timeout.connect(partial(self.updateSpeed, VhclSpeed))
        timer.timeout.connect(self.fetchBrake)
        timer.timeout.connect(self.fetchAccl)
        timer.start()
        return myApp.exec_()
Esempio n. 15
0
    def __init__(self, root, source):
        super(Application, self).__init__(sys.argv)
        self.setWindowIcon(QtGui.QIcon(ICON_PATH))

        pixmap = QtGui.QPixmap(SPLASH_PATH)
        splash = QtWidgets.QSplashScreen(pixmap)
        splash.show()
        self._splash = splash

        engine = QtQml.QQmlApplicationEngine()
        engine.objectCreated.connect(self.on_object_created)
        engine.warnings.connect(self.on_warnings)
        engine.addImportPath(QML_IMPORT_DIR)

        self._splash.showMessage("Connecting database...",
                                 QtCore.Qt.AlignBottom, QtCore.Qt.black)

        try:
            io.install()
        except IOError:
            raise  # Server refused to connect

        # Install actions
        from . import install

        install()

        self._splash.showMessage("Starting Studio Launcher...",
                                 QtCore.Qt.AlignBottom, QtCore.Qt.black)

        terminal.init()

        controller = control.Controller(root, self)
        engine.rootContext().setContextProperty("controller", controller)
        engine.rootContext().setContextProperty("terminal", terminal.model)

        self._tray = None
        self.window = None
        self.engine = engine
        self.controller = controller

        engine.load(QtCore.QUrl.fromLocalFile(source))

        self.setQuitOnLastWindowClosed(False)
Esempio n. 16
0
    def __init__(self):
        super().__init__()
        # self.app =  QtGui.QGuiApplication(sys.argv)
        self.app = QtCore.QCoreApplication.instance()
        self.instance_ready = True
        if self.app is None:
            self.instance_ready = False
            self.app = QtWidgets.QApplication([])

        hw = hardware()
        self.engine = QtQml.QQmlApplicationEngine()

        self.attenuation_model = attenuation_model(hw.awg2dac_ratios)
        self.engine.rootContext().setContextProperty("attenuation_model",
                                                     self.attenuation_model)

        if len(hw.virtual_gates) > 0:
            self.row_header_model = table_header_model(
                hw.virtual_gates[0].gates)
            self.column_header_model = table_header_model(
                hw.virtual_gates[0].v_gates)
            self.vg_matrix_model = vg_matrix_model(hw.virtual_gates[0])

            self.engine.rootContext().setContextProperty(
                'row_header_model', self.row_header_model)
            self.engine.rootContext().setContextProperty(
                'column_header_model', self.column_header_model)
            self.engine.rootContext().setContextProperty(
                'vg_matrix_model', self.vg_matrix_model)
        # grab directory from the import!

        filename = os.path.join(qml_in.__file__[:-12],
                                "virt_gate_matrix_gui.qml")
        self.engine.load(QtCore.QUrl.fromLocalFile(filename))
        self.win = self.engine.rootObjects()[0]

        timer = QtCore.QTimer()
        timer.timeout.connect(lambda: None)
        timer.start(100)

        if self.instance_ready == False:
            self.app.exec_()
            print('exec')
Esempio n. 17
0
def main():
    app = QtWidgets.QApplication(sys.argv)
    app.setFont(QtGui.QFont("Ubuntu Mono"))
    engine = QtQml.QQmlApplicationEngine()
    interfaces = Interfaces()
    engine.rootContext().setContextProperty('interfaces', interfaces)
    sniffer = Sniffer()
    engine.rootContext().setContextProperty('sniffer', sniffer)

    packetItemModel = sniffer.packetItemModel
    engine.rootContext().setContextProperty('packetItemModel', packetItemModel)
    engine.load(QUrl('main.qml'))

    topLevel = QtCore.QObject()
    topLevel = engine.rootObjects()[0]

    window = QtQuick.QQuickWindow()
    window = topLevel

    window.show()
    sys.exit(app.exec_())
Esempio n. 18
0
    def _getProp(self, obj: QtCore.QObject) -> QtQml.QQmlProperty:
        """Get the QML property instance

        Parameters
        ----------
        obj:
            QObject to get property from

        Returns
        -------
        Property object

        Raises
        ------
        AttributeError
            The QObject does not have such a propery
        """
        p = QtQml.QQmlProperty(obj, self._name)
        if not p.isValid():
            raise AttributeError(f"no QML-defined property named {self._name}")
        return p
Esempio n. 19
0
def main():
    app = QtWidgets.QApplication(sys.argv)
    view = QtQuick.QQuickView()
    view.setResizeMode(QtQuick.QQuickView.SizeRootObjectToView)

    # Create a declarative view
    component = QtQml.QQmlComponent(view)
    topLevelItem = component.create()
    qmlFile = QtCore.QUrl("source.qml")
    view.setSource(qmlFile)

    # Declare we are using instant coding tool on this view
    qic = QmlInstantCoding(view,
                           ReloadComponent(qmlFile, component, topLevelItem),
                           verbose=True)

    # Add any source file (.qml and .js by default) in current working directory
    qic.addFilesFromDirectory(os.getcwd())

    view.show()
    app.exec_()
Esempio n. 20
0
    def setup(self):
        if not os.path.exists(self.THUMB_DIR):
            os.makedirs(self.THUMB_DIR)
        user_database.setup()

        self.qml_engine = QtQml.QQmlApplicationEngine()
        self.qml_engine.addImportPath(self.QML_PATH)
        # self.qml_engine.addPluginPath(self.QML_PATH)
        self.setAttribute(QtCore.Qt.AA_UseOpenGLES, True)
        self.qml_engine.load(os.path.join(self.QML_PATH, "main.qml"))
        self.app_window = self.qml_engine.rootObjects()[0]
        self.app_window.updateGalleryRating.connect(self.update_gallery_rating)
        self.app_window.askForTags.connect(self.get_tags_from_search)
        self.app_window.saveSettings.connect(self.update_config)
        self.app_window.setSortMethod.connect(self.set_sorting)
        self.app_window.setSearchText.connect(self.update_search)
        self.app_window.pageChange.connect(self.switch_page)
        self.app_window.scanGalleries.connect(self.find_galleries)
        self.app_window.openGallery.connect(self.open_gallery)
        self.app_window.openGalleryFolder.connect(self.open_gallery_folder)
        self.app_window.metadataSearch.connect(self.get_metadata)
        self.app_window.removeGallery.connect(self.remove_gallery_by_uuid)
        self.app_window.openOnEx.connect(self.open_on_ex)
        self.app_window.saveGallery.connect(self.save_gallery_customization)
        self.app_window.searchForDuplicates.connect(self.remove_duplicates)
        self.app_window.closedUI.connect(self.close)
        self.app_window.getDetailedGallery.connect(self.get_detailed_gallery)
        self.app_window.getGalleryImageFolder.connect(
            self.get_gallery_image_folder)
        self.app_window.setGalleryImage.connect(self.set_gallery_image)
        self.app_window.setUISort.emit(Config.sort_type,
                                       1 if Config.sort_mode_reversed else 0)
        self.completer_line = QtWidgets.QLineEdit()
        self.completer_line.hide()
        self.setup_completer()
        self.setWindowIcon(
            QtGui.QIcon(Utils.convert_from_relative_path("icon.ico")))
        self.set_ui_config()
        self.app_window.show()
Esempio n. 21
0
    def _getProp(self, name: str) -> QtQml.QQmlProperty:
        """Get the QML property instance

        Parameters
        ----------
        name
            Property name

        Returns
        -------
        Property object

        Raises
        ------
        AttributeError
            The :py:attr:`instance_` does not have such a propery
        """
        p = QtQml.QQmlProperty(self.instance_, name, self._engine)
        if not p.isValid():
            raise AttributeError(f"'{type(self.instance_)}' has no property "
                                 f"'{name}'")
        return p
Esempio n. 22
0
    def __init__(self, data):
        super().__init__()
        # self.app =  QtGui.QGuiApplication(sys.argv)
        self.app = QtCore.QCoreApplication.instance()
        self.instance_ready = True
        if self.app is None:
            self.instance_ready = False
            self.app = QtWidgets.QApplication([])

        self.engine = QtQml.QQmlApplicationEngine()
        self.categories_model = categories_model(list(data.keys()))
        self.data = data
        if len(data) == 0:
            self.data_model = name_value_model({})
        else:
            self.data_model = name_value_model(data[list(data.keys())[0]])
        self.singal_hander = singal_hander_4_variable_exporer(
            self.categories_model, self.data_model, data)

        self.engine.rootContext().setContextProperty("cat_model",
                                                     self.categories_model)
        self.engine.rootContext().setContextProperty(
            "variable_name_value_pair_list", self.data_model)
        self.engine.rootContext().setContextProperty("test_function",
                                                     self.singal_hander)

        # grab directory from the import!
        filename = os.path.join(qml_in.__file__[:-11],
                                "variable_mgr_window.qml")
        self.engine.load(QtCore.QUrl.fromLocalFile(filename))
        self.win = self.engine.rootObjects()[0]

        timer = QtCore.QTimer()
        timer.timeout.connect(lambda: None)
        timer.start(100)

        if self.instance_ready == False:
            self.app.exec_()
            print('exec')
Esempio n. 23
0
    def _workerFinished(self, retval: Any):
        """Worker has finished

        Store the result in the dataset

        Parameters
        ----------
        retval
            Return value of :py:attr:`func` call
        """
        if self._resultRole:
            if self._resultRole not in self._curDset.roles:
                self._curDset.roles = self._curDset.roles + [self._resultRole]
            self._curDset.set(self._curIndex, self._resultRole, retval)
        self._progress += 1
        self._curIndex += 1
        self.progressChanged.emit()
        if self.progress < self._count:
            self._nextCall()
        else:
            self.abort()

    def _workerError(self, exc):
        # TODO: error handling
        tb = traceback.TracebackException.from_exception(exc)
        print("".join(tb.format()))
        self.abort()


QtQml.qmlRegisterType(BatchWorker, "SdtGui.Templates", 0, 1, "BatchWorker")
Esempio n. 24
0
import sys

from PyQt5 import QtQml
from PyQt5.QtWidgets import QApplication

app = QApplication(sys.argv)
engine = QtQml.QQmlApplicationEngine("example.qml")
app.exec_()
Esempio n. 25
0
class DataCollector(QtQuick.QQuickItem):
    """QtQuick item which allows for defining a dataset and associated files

    This supports defining multiple files per dataset entry, which can
    appear, for instance, when using multiple cameras simultaneously; see
    the :py:attr:`sourceNames` property.
    """

    sourceNames = QmlDefinedProperty()
    """Number of source files per dataset entry or list of source names"""
    dataset = QmlDefinedProperty()
    """:py:class:`Dataset` that is used by this item"""


class MultiDataCollector(QtQuick.QQuickItem):
    """QtQuick item which allows for defining datasets and associated files

    This supports defining multiple datasets using :py:class:`DataCollector`.
    """

    sourceNames = QmlDefinedProperty()
    """Number of source files per dataset entry or list of source names"""
    datasets = QmlDefinedProperty()
    """:py:class:`DatasetCollection` that is used by this item"""


QtQml.qmlRegisterType(DataCollector, "SdtGui.Templates", 0, 1, "DataCollector")
QtQml.qmlRegisterType(MultiDataCollector, "SdtGui.Templates", 0, 1,
                      "MultiDataCollector")
Esempio n. 26
0
 def filters(self):
     return QtQml.QQmlListProperty(CVAbstractFilter, self, self.m_filters)
Esempio n. 27
0
# -*- coding: utf-8 -*-

import sys
from PyQt5 import QtCore, QtWidgets, QtQuick, QtQml
import text_balloon

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)

    view = QtQuick.QQuickView()

    QtQml.qmlRegisterType(text_balloon.TextBalloon, "Custom", 1, 0,
                          "TextBalloon")

    view.setSource(QtCore.QUrl("main.qml"))
    view.show()

    sys.exit(app.exec_())
Esempio n. 28
0
import os
import sys

from PyQt5 import QtQml, QtWidgets

if __name__ == '__main__':
    if 'CONFIG' in os.environ:
        print(os.environ['CONFIG'])
    app = QtWidgets.QApplication(sys.argv + ["-nograb"])
    engine = QtQml.QQmlApplicationEngine("Debug.qml")
    sys.exit(app.exec_())
Esempio n. 29
0
# -*- coding: utf-8 -*-

import sys
from PyQt5 import QtCore, QtGui, QtQuick, QtQml
import squircle

if __name__ == '__main__':
    app = QtGui.QGuiApplication(sys.argv)

    QtQml.qmlRegisterType(squircle.Squircle, "OpenGLUnderQML", 1, 0,
                          "Squircle")

    view = QtQuick.QQuickView()

    # Rendering in a thread introduces a slightly more complicated cleanup
    # so we ensure that no cleanup of graphics resources happen until the
    # application is shutting down.
    view.setPersistentOpenGLContext(True)
    view.setPersistentSceneGraph(True)

    view.setResizeMode(QtQuick.QQuickView.SizeRootObjectToView)
    view.setSource(QtCore.QUrl("main.qml"))
    view.show()

    execReturn = app.exec()

    # As the render threads make use of our QGuiApplication object
    # to clean up gracefully, wait for them to finish before
    # QGuiApp is taken off the heap.
    for t in squircle.Squircle.threads:
        t.wait()
Esempio n. 30
0
        return True

    def lprint(self, message):
        # 日志打印
        global GTime
        k = GTime[0:2]
        if not self.log.get(str(k)):
            self.log[str(k)] = []
        self.log[str(k)].append(message)
        json.dump(self.log, open("log.json", "w"), ensure_ascii=False)


if __name__ == '__main__':
    # 界面初始化
    app = QtWidgets.QApplication(sys.argv)
    engine = QtQml.QQmlApplicationEngine()
    context = engine.rootContext()

    # 配置qml属性
    system = System()
    context.setContextProperty("system", system)

    timer = Timer()
    context.setContextProperty("timer", timer)

    # 加载qml属性
    engine.addImportPath(absPath + "qtquickcontrols2.conf")
    engine.load(QUrl(absPath + 'main.qml'))
    engine.load(QUrl(absPath + 'loginPage.qml'))

    # 信号与槽连接