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
Пример #2
0
 def registerTypes(self, uri):
     QtQml.qmlRegisterType(
         pyqt5_tools.examples.exampleqmlitem.ExampleQmlItem,
         'examples',
         1,
         0,
         'ExampleQmlItem',
     )
Пример #3
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)
Пример #4
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_())
Пример #5
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_())
Пример #6
0
        super(Filesystem, self).__init__(parent)

    @QtCore.pyqtSlot(str, result="QStringList")
    def listdir(self, path):
        """Exposed function to QML

        Note input parameter specified in decorator, along with output format

        """

        return os.listdir(path)


app = QtWidgets.QApplication(sys.argv)

QtQml.qmlRegisterType(Filesystem, 'Os', 1, 0, 'Filesystem')

engine = QtQml.QQmlApplicationEngine()


def finish_load(obj, url):
    if obj is not None:
        obj.show()
        app.exec_()
    else:
        sys.exit()


engine.objectCreated.connect(finish_load)
engine.load(QtCore.QUrl.fromLocalFile("app.qml"))
Пример #7
0
            self.player.start()
        else:
            if self.player.isRunning():
                self.player.terminate()

    @QtCore.pyqtSlot(float)
    def scrub(self, where):
        if self.isPlaying:
            self.isPlaying = False
            self.progress = where
            self.isPlaying = True
        else:
            self.progress = where

    filename_changed, filename = autoProperty(str, 'filename')
    isPlaying_changed, isPlaying = autoProperty(bool, 'isPlaying')
    progress_changed, progress = autoProperty(float, 'progress')
    waveform_changed, waveform = autoProperty(QtCore.QVariant, 'waveform', readonly=True)
    length_changed, length = autoProperty(float, 'length', readonly=True)


if __name__ == "__main__":
    if not QtGui.QGuiApplication.instance():
        app = QtGui.QGuiApplication(sys.argv)
    QtQml.qmlRegisterType(Player, 'Player', 1, 0, 'Player')
    engine = QtQml.QQmlApplicationEngine('main.qml')
    if len(engine.rootObjects()) > 0:
        mainWindow = engine.rootObjects()[0]
        mainWindow.setVisible(True)
    app.exec()
Пример #8
0
        Whenever the property named `prop` is changed, each dataset's `prop`
        property is set accordingly. Additionally, when adding a dataset, its
        `prop` property is initialized with the current value.

        Parameters
        ----------
        prop
            Name of the property whose value should be passed on to datasets
        """
        self._propagated.append(prop)
        sig = getNotifySignal(self, prop)
        sig.connect(lambda: self._propagatedPropertyChanged(prop))

    def _propagatedPropertyChanged(self, prop: str):
        """Slot called when a property marked for propagation changes

        This does the actual setting of the datasets' properties.

        Parameters
        ----------
        prop
            Property name
        """
        newVal = getattr(self, prop)
        for i in range(self.rowCount()):
            setattr(self.get(i, "dataset"), prop, newVal)


QtQml.qmlRegisterType(Dataset, "SdtGui", 0, 1, "Dataset")
QtQml.qmlRegisterType(DatasetCollection, "SdtGui", 0, 1, "DatasetCollection")
Пример #9
0
import os
import sys

from PyQt5 import QtCore, QtQml, QtWidgets
from mymodel import MyModel, MyItem

osname = os.name.lower()
sysplatform = sys.platform.lower()
windows = os.name.lower() == "nt" and sysplatform.startswith("win")

# PyQt class name, QML URI, major version, minor version, QML type name
QtQml.qmlRegisterType(MyModel, 'MyModel', 1, 0, 'MyModel')
QtQml.qmlRegisterType(MyItem, 'MyItem', 1, 0, 'MyItem')

app = QtWidgets.QApplication(sys.argv)

# Create the QML engine
engine = QtQml.QQmlEngine(app)
engine.quit.connect(app.quit)

# Load the main.qml file and create the toplevel component
component = QtQml.QQmlComponent(engine)
currentFilePath = os.path.dirname(os.path.abspath(__file__))
mainFilepath = os.path.join(currentFilePath, "main.qml")
if windows:
    mainFilepath = mainFilepath.replace('\\', '/')
qmlFile = QtCore.QUrl("file:///" + mainFilepath)
component.loadUrl(qmlFile)
if component.status() != QtQml.QQmlComponent.Ready:
    for error in component.errors():
        print(error.toString())
Пример #10
0
def main():
    app = QtGui.QGuiApplication(sys.argv)
    QtQml.qmlRegisterType(LoginManager, 'LoginManager', 1, 0, 'LoginManager')
    engine = QtQml.QQmlApplicationEngine(os.path.join(THIS_DIR, "Main.qml"))
    app.exec_()
Пример #11
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys, signal
from PyQt5 import QtCore, QtGui, QtQml
from zmq_client import ZmqClient
from camera_item import CameraItem

if __name__ == "__main__":
    app = QtGui.QGuiApplication(sys.argv)
    app.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
    app.setOverrideCursor(QtCore.Qt.BlankCursor)

    QtQml.qmlRegisterType(CameraItem, "goldo", 1, 0, "CameraItem")

    engine = QtQml.QQmlApplicationEngine()
    zmq_client = ZmqClient()
    engine.rootContext().setContextProperty("zmqClient", zmq_client)
    engine.load('qml/main.qml')
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    sys.exit(app.exec_())
Пример #12
0
def main():
    app = QtGui.QGuiApplication(sys.argv)
    QtQml.qmlRegisterType(JSManager, 'JSManager', 1, 0, 'JSManager')
    engine = QtQml.QQmlApplicationEngine(os.path.join(THIS_DIR, "main.qml"))
    app.exec_()
Пример #13
0
    @image.setter
    def image(self, image: Union[np.ndarray, None]):
        if self._image is image:
            return
        self._image = image
        self._imageMinVal = image.min() if image is not None else 0.0
        self._imageMaxVal = image.max() if image is not None else 0.0
        self._imageMinChanged.emit(self._imageMin)
        self._imageMaxChanged.emit(self._imageMax)
        self.imageChanged.emit(image)

    _imageMinChanged = QtCore.pyqtSignal(float)

    @QtCore.pyqtProperty(float, notify=_imageMinChanged)
    def _imageMin(self) -> float:
        """Minimum value in input image. Used for QML property binding."""
        return self._imageMinVal

    _imageMaxChanged = QtCore.pyqtSignal(float)

    @QtCore.pyqtProperty(float, notify=_imageMaxChanged)
    def _imageMax(self):
        """Maximum value in input image. Used for QML property binding."""
        return self._imageMaxVal

    error = SimpleQtProperty(str)
    """Error message to be displayed"""


QtQml.qmlRegisterType(ImageDisplay, "SdtGui.Templates", 0, 1, "ImageDisplay")
Пример #14
0
#! /usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (C) 2011 ~ 2014 Deepin, Inc.
#               2011 ~ 2014 Hou ShaoHui
#
# Author:     Hou ShaoHui <*****@*****.**>
# Maintainer: Hou ShaoHui <*****@*****.**>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from PyQt5 import QtQml
from dtalk.gui.plugins.message import DMessage
from dtalk.gui.plugins.popup import PopupItem

QtQml.qmlRegisterType(DMessage, "DTalk", 1, 0, "DMessage")
QtQml.qmlRegisterType(PopupItem, "DTalk", 1, 0, "PopupItem")
Пример #15
0
        """
        if self._locData is None or not self._locData.size:
            self._circles = []
        else:
            vals = np.empty((len(self._locData), 4))
            for i, axis in enumerate(["x", "y"]):
                sz_col = f"size_{axis}"
                sizes = self._locData[sz_col if sz_col in
                                      self._locData.columns else "size"]
                sizes = sizes.to_numpy() * self.scaleFactor
                coords = self._locData[axis] * self.scaleFactor - sizes
                vals[:, i] = coords
                vals[:, i + 2] = 2 * sizes
            self._circles = [QtCore.QRectF(*v) for v in vals]
        self.update()

    def paint(self, painter: QtGui.QPainter):
        # Implement QQuickItem.paint
        pen = painter.pen()
        pen.setColor(self.color)
        pen.setWidthF(2.5)
        pen.setCosmetic(True)
        painter.setPen(pen)
        painter.setRenderHint(QtGui.QPainter.Antialiasing, True)

        for c in self._circles:
            painter.drawEllipse(c)


QtQml.qmlRegisterType(LocDisplay, "SdtGui", 0, 1, "LocDisplay")
Пример #16
0
            if self.player.isRunning():
                self.player.terminate()

    @QtCore.pyqtSlot(float)
    def scrub(self, where):
        if self.isPlaying:
            self.isPlaying = False
            self.progress = where
            self.isPlaying = True
        else:
            self.progress = where

    filename_changed, filename = autoProperty(str, 'filename')
    isPlaying_changed, isPlaying = autoProperty(bool, 'isPlaying')
    progress_changed, progress = autoProperty(float, 'progress')
    waveform_changed, waveform = autoProperty(QtCore.QVariant,
                                              'waveform',
                                              readonly=True)
    length_changed, length = autoProperty(float, 'length', readonly=True)


if __name__ == "__main__":
    if not QtGui.QGuiApplication.instance():
        app = QtGui.QGuiApplication(sys.argv)
    QtQml.qmlRegisterType(Player, 'Player', 1, 0, 'Player')
    engine = QtQml.QQmlApplicationEngine('main.qml')
    if len(engine.rootObjects()) > 0:
        mainWindow = engine.rootObjects()[0]
        mainWindow.setVisible(True)
    app.exec()
Пример #17
0
        frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGBA)
        frame = QtGui.QImage(frame, frame.shape[1], frame.shape[0], 17)
        self.cam_frame = frame.copy()
        self.update()


def get_frames(app):
    cap = cv2.VideoCapture(0)
    num = 0
    imgw = ImageWriter()
    while True:
        while num != 30:
            _, bgframe = cap.read()
            num += 1
        ret, frame = cap.read()
        if ret:
            imgw.update_frame(frame)
            #print("get frames")
            app.processEvents()


if __name__ == '__main__':
    app = QtGui.QGuiApplication(sys.argv)
    QtQml.qmlRegisterType(ImageWriter, "imageWriter", 1, 0, "ImageWriter")
    view = QtQuick.QQuickView()
    view.setSource(QtCore.QUrl('test.qml'))
    rootObject = view.rootObject()
    view.show()
    get_frames(app)
    sys.exit(app.exec_())
Пример #18
0
    @staticmethod
    def workerFunc(image: np.ndarray, algorithm: str,
                   options: Mapping[str, Any]) -> pd.DataFrame:
        """Run localization algorithm

        This is executed in the worker process.

        Paramters
        ---------
        image
            Image to find localizations in.
        algorithm
            Name of the algorithm, i.e., name of the submodule in
            :py:mod:`sdt.loc`.
        options
            Arguments passed to the ``locate`` function of the submodule
            specified by `algorithm`

        Returns
        -------
        Localization data
        """
        if image is None:
            return None
        algo_mod = getattr(loc, algorithm)
        result = algo_mod.locate(image, **options)
        return result


QtQml.qmlRegisterType(LocOptions, "SdtGui.Templates", 0, 1, "LocOptions")
Пример #19
0
        Parameters
        ----------
        index
            Index of currently selected frame
        """
        if self._curImage is None:
            self._image = None
        else:
            try:
                self._image = self._curImage[index]
            except Exception as ex:
                self._image = None
                err = str(ex)
                if self._error != err:
                    self._error = err
                    self.errorChanged.emit()
                self._image = None
            else:
                if self._error:
                    self._error = ""
                    self.errorChanged.emit()
        self.imageChanged.emit()

    currentIndex = QmlDefinedProperty()
    """Index w.r.t :py:attr:`dataset` of currently selected image sequence"""
    currentFrame = QmlDefinedProperty()
    """Currently selected frame number"""


QtQml.qmlRegisterType(ImageSelector, "SdtGui.Templates", 0, 1, "ImageSelector")
Пример #20
0
        super(Species, self).__init__(parent=parent, identifier=identifier)
        self.name = None
        self.cost = None
        self.baseLE = None
        self.baseSK = None
        self.baseZ = None
        self.baseGS = None
        self.talentBoniList = None
        self.cultureList = None
        self.perkList = None
        self.quirkList = None
        self.unusualPerkList = None
        self.unusualQuirkList = None
        self.hairColorList = None
        self.eyeColorList = None
        self.heightLimits = None
        self.weightLimits = None

    def select(self, c):
        c.species = self

    def deselect(self, c):
        pass


QtQml.qmlRegisterType(Species, 'dsa5', 1, 0, 'species')
QtQml.qmlRegisterType(Trait, 'dsa5', 1, 0, 'trait')
QtQml.qmlRegisterType(Perk, 'dsa5', 1, 0, 'perk')
QtQml.qmlRegisterType(Quirk, 'dsa5', 1, 0, 'quirk')
# QtQml.qmlRegisterType(Id, 'dsa5', 1, 0, 'id')
Пример #21
0
import os
import sys

from PyQt5 import QtCore, QtQml, QtWidgets

from regatta import QRegatta, QEvent, QSailingClub, QPerson

# Fixme: I have no idea why I can't put it in a method
# def main():

osname = os.name.lower()
sysplatform = sys.platform.lower()
windows = os.name.lower() == "nt" and sysplatform.startswith("win")

# PyQt class name, QML URI, major version, minor version, QML type name
QtQml.qmlRegisterType(QRegatta, 'QRegatta', 1, 0, 'QRegatta')
QtQml.qmlRegisterType(QEvent, 'QEvent', 1, 0, 'QEvent')
QtQml.qmlRegisterType(QSailingClub, 'QSailingClub', 1, 0, 'QSailingClub')
QtQml.qmlRegisterType(QPerson, 'QPerson', 1, 0, 'QPerson')

app = QtWidgets.QApplication(sys.argv)

# Create the QML engine
engine = QtQml.QQmlEngine(app)
engine.quit.connect(app.quit)

# Load the main.qml file and create the toplevel component
component = QtQml.QQmlComponent(engine)
currentFilePath = os.path.dirname(os.path.abspath(__file__))
mainFilepath = os.path.join(currentFilePath, "regatta/main.qml")
if windows:
Пример #22
0

class MaxRGBFilter(PyCVQML.CVAbstractFilter):
    def process_image(self, src):
        return max_rgb_filter(src)


class GrayFilter(PyCVQML.CVAbstractFilter):
    def process_image(self, src):
        return rgb_to_gray(src)


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

    app = QtGui.QGuiApplication(sys.argv)

    PyCVQML.registerTypes()
    QtQml.qmlRegisterType(MaxRGBFilter, "Filters", 1, 0, "MaxRGBFilter")
    QtQml.qmlRegisterType(GrayFilter, "Filters", 1, 0, "GrayFilter")

    view = QtQuick.QQuickView()
    view.setTitle("PyCVQML Example")
    dir_path = os.path.dirname(os.path.realpath(__file__))
    view.setSource(
        QtCore.QUrl.fromLocalFile(
            QtCore.QDir(dir_path).absoluteFilePath("main.qml")))
    view.show()
    sys.exit(app.exec_())
Пример #23
0
#! /usr/bin/env python
# -*- coding: utf-8 -*-

from PyQt5 import QtQml
from gui.popup import PopupItem

QtQml.qmlRegisterType(PopupItem, "DGui", 1, 0, "PopupItem")
Пример #24
0
        """Resize all ROIs to `model`'s size

        This is a callback invoked when a ROI (whose name is given by the
        `model` argument) changes.

        Parameters
        ----------
        model
            Name of the channel to get the ROI size from
        image
            Image defining the ROI boundaries
        """
        allRois = self.channels
        modelRoi = allRois[model]["roi"]
        sz = modelRoi.size
        for n, v in allRois.items():
            r = v.get("roi", None)
            if n == model or r is None:
                continue
            if image is not None:
                # Resize to right/bottom only as long as image boundaries are
                # not exceeded
                tl = (min(r.top_left[0], image.shape[1] - sz[0]),
                      min(r.top_left[1], image.shape[0] - sz[1]))
            else:
                tl = r.top_left
            self._setROI(v.get("source_id", 0), n, sdt_roi.ROI(tl, size=sz))


QtQml.qmlRegisterType(ChannelConfig, "SdtGui.Templates", 0, 1, "ChannelConfig")
Пример #25
0
def registerTypes(uri="PyCVQML"):
    QtQml.qmlRegisterType(CVCapture, uri, 1, 0, "CVCapture")
    QtQml.qmlRegisterType(CVItem, uri, 1, 0, "CVItem")
Пример #26
0
        """Convert QUrl to local file name string

        Parameters
        ----------
        u
            URL to convert

        Returns
        -------
        File name
        """
        return u.toLocalFile()

    @QtCore.pyqtSlot(QtCore.QUrl, result=QtCore.QUrl)
    def parentUrl(self, u: QtCore.QUrl) -> QtCore.QUrl:
        """Get URL of directory containing `u`

        Parameters
        ----------
        u
            URL to get parent directory for

        Returns
        -------
        URL to `u`'s parent
        """
        return QtCore.QUrl.fromLocalFile(str(Path(u.toLocalFile()).parent))


QtQml.qmlRegisterType(Sdt, "SdtGui.Templates", 0, 1, "Sdt")
Пример #27
0
    @QtCore.pyqtSlot()
    def GetServerNames(self):
        def go():
            serverNames = ["one", "two", "three"]
            self.serverNames.emit(serverNames)

        threading.Thread(target=go).start()

    @QtCore.pyqtSlot()
    def GetLastLogin(self):
        def go():
            login = "******"
            self.lastLogin.emit(login)

        threading.Thread(target=go).start()

    @QtCore.pyqtSlot()
    def GetLastServerName(self):
        def go():
            serverName = "three"
            self.lastServer.emit(serverName)

        threading.Thread(target=go).start()


app = QtGui.QGuiApplication(sys.argv)
QtQml.qmlRegisterType(LoginManager, 'LoginManager', 1, 0, 'LoginManager')
engine = QtQml.QQmlApplicationEngine("Main.qml")
app.exec_()
Пример #28
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_())
Пример #29
0
        return reg

    @QtCore.pyqtSlot()
    def abortCalculation(self):
        """Abort processing"""
        if self._worker is None:
            return
        self._worker.enabled = False
        self._worker = None

    def _workerFinished(self, retval: multicolor.Registrator):
        """Worker has finished

        Store the result in :py:attr:`registrator`

        Parameters
        ----------
        retval
            Result of calculation
        """
        self.registrator = retval
        self.abortCalculation()

    def _workerError(self, exc: Exception):
        # TODO: error handling
        print("worker exc", exc)
        self.abortCalculation()


QtQml.qmlRegisterType(Registrator, "SdtGui.Templates", 0, 1, "Registrator")
Пример #30
0
                                    QtGui.QImage.Format_Grayscale8)
        self.update()

    def paint(self, painter: QtGui.QPainter):
        if self._qImage is None:
            return
        # Maybe use self._qImage.scaled(), which would allow to specifiy
        # whether to do interpolation or not?
        painter.drawImage(
            QtCore.QRect(0, 0, self.width(), self.height()), self._qImage,
            QtCore.QRect(0, 0, self.sourceWidth, self.sourceHeight))

    sourceWidthChanged = QtCore.pyqtSignal(int)
    """Width of the image changed."""

    @QtCore.pyqtProperty(int, notify=sourceWidthChanged)
    def sourceWidth(self) -> int:
        """Width of the image."""
        return self._source.shape[1] if self._source is not None else 0

    sourceHeightChanged = QtCore.pyqtSignal(int)
    """Height of the image changed."""

    @QtCore.pyqtProperty(int, notify=sourceHeightChanged)
    def sourceHeight(self) -> int:
        """Height of the image."""
        return self._source.shape[0] if self._source is not None else 0


QtQml.qmlRegisterType(PyImage, "SdtGui", 0, 1, "PyImage")
Пример #31
0
# -*- coding: utf-8 -*-

# Copyright (C) 2011 ~ 2014 Deepin, Inc.
#               2011 ~ 2014 Hou ShaoHui
# 
# Author:     Hou ShaoHui <*****@*****.**>
# Maintainer: Hou ShaoHui <*****@*****.**>
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from PyQt5 import QtQml
from dtalk.gui.plugins.message import DMessage
from dtalk.gui.plugins.popup import PopupItem

QtQml.qmlRegisterType(DMessage, "DTalk", 1, 0, "DMessage")
QtQml.qmlRegisterType(PopupItem, "DTalk", 1, 0, "PopupItem")



Пример #32
0
def qmlRegister():
    QtQml.qmlRegisterType(WheelArea, "QuickMamba", 1, 0, "WheelAreaImpl")
    QtQml.qmlRegisterType(ExternDropArea, "QuickMamba", 1, 0, "ExternDropAreaImpl")
    QtQml.qmlRegisterType(ColorExtended, "QuickMamba", 1, 0, "ColorExtended")
    QtQml.qmlRegisterType(ColorPicker, "QuickMamba", 1, 0, "ColorPicker")
Пример #33
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()
Пример #34
0
        Parameters
        ----------
        locData
            Localization data for tracking
        searchRange
            `search_range` parameter to :py:func:`trackpy.link`
        memory
            `memory` parameter to :py:func:`trackpy.link`

        Returns
        -------
        Tracked data
        """
        if locData is None:
            return None
        if not locData.size:
            ret = locData.copy()
            ret["particle"] = []
            return ret
        trackpy.quiet()
        return trackpy.link(locData, search_range=searchRange, memory=memory)

    @QtCore.pyqtSlot(result=QtCore.QVariant)
    def getTrackFunc(self) -> Callable[[pd.DataFrame], pd.DataFrame]:
        return functools.partial(self.workerFunc,
                                 searchRange=self.searchRange,
                                 memory=self.memory)


QtQml.qmlRegisterType(TrackOptions, "SdtGui.Templates", 0, 1, "TrackOptions")
Пример #35
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")
Пример #36
0
    def _makeLines(self):
        """Create lines marking the tracks

        This calls also :py:meth:`update` to trigger paint.
        """
        self._lines = []
        if self._curFrame < 0 or self._trc is None:
            self.locData = None
        else:
            self.locData = self._trc[self._trc["frame"] == self._curFrame]
            curTrc = self._trc.groupby("particle").filter(lambda x: (x[
                "frame"].min() <= self._curFrame <= x["frame"].max()))
            # TODO: sort by frame

            for p, t in curTrc.groupby("particle"):
                xs = (t["x"].to_numpy() + 0.5) * self.scaleFactor
                ys = (t["y"].to_numpy() + 0.5) * self.scaleFactor
                poly = QtGui.QPolygonF(
                    QtCore.QPointF(x, y) for x, y in zip(xs, ys))
                self._lines.append(poly)
        self.update()

    def paint(self, painter: QtGui.QPainter):
        # Implement QQuickItem.paint
        super().paint(painter)
        for li in self._lines:
            painter.drawPolyline(li)


QtQml.qmlRegisterType(TrackDisplay, "SdtGui", 0, 1, "TrackDisplay")
Пример #37
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")
Пример #38
0
import os
import sys

from PyQt5 import QtCore, QtQml, QtWidgets
from sortfilterproxymodel import SortFilterProxyModel
from mymodel import MyModel, MyItem

osname = os.name.lower()
sysplatform = sys.platform.lower()
windows = os.name.lower() == "nt" and sysplatform.startswith("win")

# PyQt class name, QML URI, major version, minor version, QML type name
QtQml.qmlRegisterType(MyModel, 'MyModel', 1, 0, 'MyModel')
QtQml.qmlRegisterType(MyItem, 'MyItem', 1, 0, 'MyItem')
QtQml.qmlRegisterType(SortFilterProxyModel, 'SortFilterProxyModel', 1, 0, 'SortFilterProxyModel')

app = QtWidgets.QApplication(sys.argv)

# Create the QML engine
engine = QtQml.QQmlEngine(app)
engine.quit.connect(app.quit)

# Load the main.qml file and create the toplevel component
component = QtQml.QQmlComponent(engine)
currentFilePath = os.path.dirname(os.path.abspath(__file__))
mainFilepath = os.path.join(currentFilePath, "main.qml")
if windows:
    mainFilepath = mainFilepath.replace('\\', '/')
qmlFile = QtCore.QUrl("file:///" + mainFilepath)
component.loadUrl(qmlFile)
if component.status() != QtQml.QQmlComponent.Ready: