Beispiel #1
0
class View(object):
    def __init__(self, iface, chart):

        dir_path = os.path.dirname(os.path.realpath(__file__))
        qml = os.path.join(dir_path, "qml", "scatterplot.qml")
        self.view = QQuickView()
        self.view.setResizeMode(QQuickView.SizeRootObjectToView)
        self.view.rootContext().setContextProperty("pychart", chart)
        self.view.setColor(QColor("#000000"))
        self.view.setSource(QUrl.fromLocalFile(qml))

        self.container = QWidget.createWindowContainer(self.view)
        self.widget = QDockWidget()
        self.widget.setWidget(self.container)
        iface.addDockWidget(Qt.BottomDockWidgetArea, self.widget)

        self.read_settings()

    def read_settings(self, settings=None):
        if not settings:
            settings = Settings.Snapshot()

        self.view.setColor(QColor(settings.background_color))

    def show(self):
        self.widget.show()

    def hide(self):
        self.widget.hide()
Beispiel #2
0
def main():
    global app

    # sys.argv.extend(['-platform', 'eglfs'])

    # Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used.
    app = QApplication(sys.argv)

    viewer = QQuickView()

    # The following are needed to make examples run without having to install the module
    # in desktop environments.
    extraImportPath = QGuiApplication.applicationDirPath()
    if sys.platform == 'win32':
        extraImportPath += "/../../../../qml"
    else:
        extraImportPath += "/../../../qml"

    viewer.engine().addImportPath(extraImportPath)
    viewer.engine().quit.connect(app.quit)

    viewer.setTitle("QML Oscilloscope")

    dataSource = datasource.DataSource(viewer)
    viewer.rootContext().setContextProperty("dataSource", dataSource)

    main_qml = path.dirname(__file__) + "/qml/qmloscilloscope/main.qml"
    viewer.setSource(QUrl(main_qml))
    viewer.setResizeMode(QQuickView.SizeRootObjectToView)
    viewer.setColor(QColor("#404040"))
    viewer.show()

    return app.exec_()
Beispiel #3
0
def createWindow():
    view = QQuickView()
    view.setSurfaceType(QSurface.OpenGLSurface)

    fmt = QSurfaceFormat()
    fmt.setAlphaBufferSize(8)
    fmt.setRenderableType(QSurfaceFormat.OpenGL)
    view.setFormat(fmt)

    color = QColor()
    color.setRedF(0.0)
    color.setGreenF(0.0)
    color.setBlueF(0.0)
    color.setAlphaF(0.0)
    view.setColor(color)

    view.setClearBeforeRendering(True)
    view.setFlags(Qt.FramelessWindowHint | Qt.ToolTip
                  | Qt.WindowStaysOnTopHint)

    context = view.rootContext()

    return (view, context)
Beispiel #4
0
# 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()

def on_toggle_fullscreen():
    global is_full_screen
    if is_full_screen: