Пример #1
0
def main():
    os.environ["QT_IM_MODULE"] = "qtvirtualkeyboard"

    app = QtWidgets.QApplication(sys.argv)

    # class instance
    chartManager1 = ChartManager1()
    chartManager2 = ChartManager2()
    chartManager3 = ChartManager3()
    alarmManager = AlarmManager()
    # patient = Patient()
    userInput = UserInput()
    modeSelect = ms.ModeSelect()

    # connect signal
    app.aboutToQuit.connect(chartManager1.stop)
    app.aboutToQuit.connect(chartManager2.stop)
    app.aboutToQuit.connect(chartManager3.stop)
    app.aboutToQuit.connect(modeSelect.stop)
    app.aboutToQuit.connect(alarmManager.stop)

    dp = 0

    # start thread
    chartManager1.start()
    modeSelect.start()
    alarmManager.start()

    engine = QtQml.QQmlApplicationEngine()
    ctx = engine.rootContext()

    ctx.setContextProperty("ChartManager1", chartManager1)
    ctx.setContextProperty("ChartManager2", chartManager2)
    ctx.setContextProperty("ChartManager3", chartManager3)

    ctx.setContextProperty("ModeSelect", modeSelect)
    # ctx.setContextProperty("Patient", patient)
    ctx.setContextProperty("UserInput", userInput)
    ctx.setContextProperty("AlarmManager", alarmManager)

    ctx.setContextProperty("dp", dp)
    ctx.setContextProperty("fs", False)

    # if redis exists take the userinput
    if config.useredis:
        params = config.r.get("PARAMS")
        params = json.loads(params)
        ctx.setContextProperty("Params", params)

    if config.args.fullscreen:
        logging.debug("Runnin in full screen")
        ctx.setContextProperty("fs", True)

    # engine.load('main.qml')
    engine.load('./qml/MainQt.qml')
    if not engine.rootObjects():
        sys.exit(-1)

    sys.exit(app.exec_())
Пример #2
0
    def create(self) -> bool:
        # search the main QML file
        path = utils.get_resource('themes', self._theme_name, 'main.qml')
        if not path:
            ERR('Cannot find theme: "{}"'.format(self._theme_name))
            return False
        LOG('Loading theme: "{}"'.format(path))

        # create the QML engine
        self._qml_engine = QtQml.QQmlApplicationEngine()

        # inject MainMenu and Browser model
        ctxt = self._qml_engine.rootContext()
        self._mainmenu_qtmodel = MainMenuModel()
        ctxt.setContextProperty('MainMenuModel', self._mainmenu_qtmodel)

        self._browser_qtmodel = BrowserModel(self)
        ctxt.setContextProperty('BrowserModel', self._browser_qtmodel)

        # ctxt.setContextProperty('NavigatorModel', self._navigator_proxymodel)

        self._notify_model = NotifyModel()
        ctxt.setContextProperty('EmcNotifyModel', self._notify_model)

        # inject the Communicator class
        self._backend_instance = GuiCommunicator(self)
        ctxt.setContextProperty('EmcBackend', self._backend_instance)

        # inject the network cache manager
        self._nam_factory = QMLNetworkAccessManagerFactory()
        self._qml_engine.setNetworkAccessManagerFactory(self._nam_factory)

        # load and show the QML theme
        self._qml_engine.load(path)
        roots = self._qml_engine.rootObjects()
        if not roots:
            ERR('Cannot create the QML view')
            return False

        # keep a reference of the main QML object for fast access
        self._qml_root = roots[0]

        # keep a reference of the main QGuiApplication for faster access
        self._qapp = QtGui.QGuiApplication.instance()

        # all the keyboard input must be forwarded to EMC and ignored
        self._events_manager = EventManager(self)
        self._qapp.installEventFilter(self._events_manager)

        # startup with correct volume value
        self.volume_set(mediaplayer.volume_get())

        # startup with correct fullscreen state
        self.fullscreen_set(self._boot_in_fullscreen)

        return True
Пример #3
0
 def __init__(self, parent = None):
     QObject.__init__(self, parent)
     engine = QtQml.QQmlApplicationEngine()
     engine.rootContext().setContextProperty("ui_control", self)
     url = QtCore.QUrl.fromLocalFile('./qml/main.qml')
     engine.load(url)
     self._engine = engine
     fc = fixt.FixtureController()
     self._calib_workflow = cwc.CalibrationWorkflowController(fc, self)
     
     self._sensor_mappings = []
Пример #4
0
def main():
    app = QtGui.QGuiApplication(sys.argv)

    QtQml.qmlRegisterType(CalendarProvider, "MyCalendar", 1, 0,
                          "CalendarProvider")

    engine = QtQml.QQmlApplicationEngine()
    filename = os.path.join(CURRENT_DIR, "main.qml")
    engine.load(QtCore.QUrl.fromLocalFile(filename))

    if not engine.rootObjects():
        sys.exit(-1)

    sys.exit(app.exec_())
Пример #5
0
def main():
    app = qtg.QGuiApplication(sys.argv)

    engine = qml.QQmlApplicationEngine()

    # Bind the backend object in qml
    backend = Backend()
    engine.rootContext().setContextProperty('backend', backend)

    engine.load(qtc.QUrl.fromLocalFile(os.path.join(CURRENT_DIR, 'main.qml')))

    if not engine.rootObjects():
        return -1

    return app.exec_()
Пример #6
0
def main():

    # sys.argv += ['--style', 'material']
    app = qtg.QGuiApplication(sys.argv)

    engine = qml.QQmlApplicationEngine()
    backend = Backend()
    engine.rootContext().setContextProperty('backend', backend)

    engine.load(qtc.QUrl(os.path.join(CURRENT_DIR, 'main.qml')))

    if not engine.rootObjects:
        sys.exit(-1)

    sys.exit(app.exec_())
Пример #7
0
def main():
    import os
    import sys

    CURRENT_DIR = os.path.dirname(os.path.realpath(__file__))

    app = QtGui.QGuiApplication(sys.argv)

    engine = QtQml.QQmlApplicationEngine()

    filename = os.path.join(CURRENT_DIR, "Clockwindow.qml")
    engine.load(QUrl.fromLocalFile(filename))

    if not engine.rootObjects():
        sys.exit(-1)

    sys.exit(app.exec_())
Пример #8
0
def run(argv=None):
    if argv is None:
        argv = sys.argv[1:]

    p = argparse.ArgumentParser()
    p.add_argument('-l', '--local-qml', dest='local_qml', action='store_true',
        help='Use local qml files (development mode)',
    )
    p.add_argument('--palette', dest='palette', choices=['system', 'dark'], default='dark')
    args, remaining = p.parse_known_args(argv)

    if not resource_manager.ready:
        resource_manager.build_missing()
        assert resource_manager.ready is True

    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    app = QApplication(remaining)
    QtGui.QIcon.setThemeName('fa-icons')
    loop = QEventLoop(app)
    asyncio.set_event_loop(loop)
    app.setOrganizationName('jvconnected')
    app.setApplicationName('jvconnected')
    engine = QtQml.QQmlApplicationEngine()
    if args.local_qml:
        logger.debug('Using local qml files')
        qml_import = str(QML_PATH)
        qml_main = str(QML_PATH / 'main.qml')
    else:
        check_qrc_hash()
        qml_import = 'qrc:/qml'
        qml_main = 'qrc:/qml/main.qml'
    register_qml_types()
    engine.addImportPath(qml_import)
    palette_manager = palette.PaletteManager(
        qmlEngine=engine,
        defaultPaletteName=args.palette,
    )
    context = engine.rootContext()
    context.setContextProperty('paletteManager', palette_manager)

    engine.load(qml_main)
    win = engine.rootObjects()[0]
    win.show()
    with loop:
        sys.exit(loop.run_forever())
Пример #9
0
def run(argv=None):
    if argv is None:
        argv = sys.argv
    logger.info('starting application')
    app = QApplication(argv)
    app.setOrganizationName('rtlsdr-wwb-scanner')
    app.setApplicationName('wwb_scanner')
    app.aboutToQuit.connect(on_app_quit)
    QtCore.qInstallMessageHandler(qt_message_handler)
    engine = QtQml.QQmlApplicationEngine()
    engine.setBaseUrl(str(QML_PATH))
    engine.addImportPath(str(QML_PATH))
    register_qml_types()
    qml_main = QML_PATH / 'main.qml'
    engine.load(str(qml_main))
    win = engine.rootObjects()[0]
    win.show()
    sys.exit(app.exec_())
Пример #10
0
def main():
    import os
    import sys

    CURRENT_DIR = os.path.dirname(os.path.realpath(__file__))

    app = QtGui.QGuiApplication(sys.argv)

    time = WeatherDate()

    engine = QtQml.QQmlApplicationEngine()
    engine.rootContext().setContextProperty("time", time)

    filename = os.path.join(CURRENT_DIR, "Weather.qml")
    engine.load(QUrl.fromLocalFile(filename))

    if not engine.rootObjects():
        sys.exit(-1)

    sys.exit(app.exec_())
Пример #11
0
def main():
    global _bi
    _bi = Bi()
    op_init()

    app = QtGui.QGuiApplication(sys.argv)
    screens = QtGui.QGuiApplication.screens()
    for screen in screens:
        screen.setOrientationUpdateMask(Qt.LandscapeOrientation
                                        | Qt.PortraitOrientation
                                        | Qt.InvertedLandscapeOrientation
                                        | Qt.InvertedPortraitOrientation)
    QQuickWindow.setDefaultAlphaBuffer(True)
    engine = QtQml.QQmlApplicationEngine()
    engine.rootContext().setContextProperty('bi', _bi)
    engine.load(QtCore.QUrl.fromLocalFile(f'{CURRENT_DIR}/window.qml'))
    if not engine.rootObjects():
        return -1

    # https://wiki.qt.io/Qt_for_Python_Signals_and_Slots
    app.aboutToQuit.connect(op_exit)

    return app.exec_()
Пример #12
0
def main():
    sys.argv += ['--style', 'material']

    CURRENT_DIR = os.path.dirname(sys.argv[0])

    QtGui.QGuiApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
    QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)

    QtQml.qmlRegisterType(Backend, 'MyLibrary', 1, 0, 'Backend')

    app = QtGui.QGuiApplication(sys.argv)
    app.setWindowIcon(QtGui.QIcon(resource_path('icon.ico')))

    engine = QtQml.QQmlApplicationEngine()

    utils = Utils()
    engine.rootContext().setContextProperty('Utils', utils)

    engine.load(os.path.join(CURRENT_DIR, resource_path('qml/main.qml')))

    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec_())
Пример #13
0
def main():

    QtCore.QCoreApplication

    #subprocess.run(['xset', '-dpms'])
    subprocess.run(['xset', 's', 'off', '-dpms'])
    app = QtWidgets.QApplication(sys.argv)
    QtWebEngine.QtWebEngine.initialize()
    engine = QtQml.QQmlApplicationEngine()

    settings = settingsController()
    try:
        settings.check()
        settings.load()
    except:
        subprocess.run([
            'x-terminal-emulator', '-T', settings.system_id, '-geometry',
            '146x80', '-e', 'sudo nmtui'
        ])
        exit(403)

    t = threading.Thread(target=settings.while_touch)
    t.daemon = True
    t.start()

    printer = printController(settings.settings, settings)

    ctx = engine.rootContext()
    ctx.setContextProperty('KioskPrinter', printer)
    ctx.setContextProperty('KioskSettings', settings)

    engine.load(QtCore.QUrl("qrc:/Kiosk.qml"))

    c = app.exec_()
    content.resource.qCleanupResources()

    return c
Пример #14
0
# coding: utf-8
from PySide2 import QtWidgets, QtCore, QtGui, QtQuick, QtQml
import sys
import os
from resources import qml

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

    engine = QtQml.QQmlApplicationEngine()
    engine.addImportPath(os.path.join(os.path.dirname(__file__), 'imports'))
    # import path 是qml中用来improt 的路径,类似python sys.path
    # plugin path 是能读到qmdir的路径

    engine.load("qrc:/main.qml")

    sys.exit(app.exec_())
Пример #15
0
            return
        self.y = newY
        self.handYChanged.emit()

    @qtc.Property(float, notify=handZChanged)
    def handZ(self):
        return self.z

    @handZ.setter
    def setZ(self, newZ):
        # Do not emit a changed signal if the icon is the same
        if self.z == newZ:
            return
        self.z = newZ
        self.handZChanged.emit()


if __name__ == '__main__':

    # Initializes the app, engine, and classes
    app = qtg.QGuiApplication(sys.argv)
    engine = qtm.QQmlApplicationEngine()
    root_context = engine.rootContext()

    handgest = HandGest()

    root_context.setContextProperty('handgest', handgest)

    engine.load(qtc.QUrl.fromLocalFile('../test.qml'))
    sys.exit(app.exec_())
import sys
from PySide2 import QtCore as qtc, QtWidgets as qtw, QtGui as qtgui, QtQml as qtqml
from main import Main



if __name__ == "__main__":

    #   Set attributes
    qtw.QApplication.setAttribute(qtc.Qt.AA_EnableHighDpiScaling)
    qtc.QCoreApplication.setAttribute(qtc.Qt.AA_UseHighDpiPixmaps)

    #   Define application
    app = qtw.QApplication(sys.argv)
    app.setOrganizationName("Yeahlowflicker Production")

    #   Define engine
    engine = qtqml.QQmlApplicationEngine()
    manager = Main(engine)
    engine.load(qtc.QUrl("/mnt/YFP/Projects/PRJ000-Simple-Text-Editor/proj/main.qml"))


    #   Exit handler
    sys.exit(app.exec_())
Пример #17
0
def run():
    # Sets path of QML files
    qml_path = ""
    if os.path.isdir(sys.path[0] + "/qml"):
        qml_path = sys.path[0] + "/qml"
    else:
        qml_path = sys.path[0] + "/../qml"
    # Create a Qt Application object from the system arguments
    app = QtWidgets.QApplication(sys.argv)

    # Set the application icon
    app.setWindowIcon(QtGui.QIcon("assets/img/icon.png"))

    # Enable material design in the app
    os.environ["QT_QUICK_CONTROLS_STYLE"] = "Material"

    # When the SIGINT signal is received, exit
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    # Creates an engine for the application to run under
    engine = QtQml.QQmlApplicationEngine()

    # A function to start the main part of the program.
    # It is conditionally executed based on if the program
    # has been started before.
    def start_main():
        # Access the global proc and app vars
        # Load in the config
        config.load()
        # Prep the engine (see views.main)
        views.main.prep_engine(engine, qml_path)
        # Get the list of root objects:
        n = engine.rootObjects()
        # If there are more than one objects in the list, use the second one.
        # This occurs when the wizard is shown first.
        if len(n) > 1:
            root = engine.rootObjects()[1]
        else:
            # Else, show the first one
            root = engine.rootObjects()[0]

        # Establish all the properties from the config
        nameProp = QtQml.QQmlProperty(root, "name")
        schoolProp = QtQml.QQmlProperty(root, "school")
        hostProp = QtQml.QQmlProperty(root, "hostname")
        nameProp.write(config.user["firstName"] + " " +
                       config.user["lastName"])
        schoolProp.write(config.user["school"])
        hostProp.write(config.hostname)

        # Show the root window
        root.show()
        # And execute the application
        proc = app.exec_()

    # Register this client to the main server
    network.register_client()

    # A function to start the wizard
    # Again, it is conditionally executed.
    def start_wizard():
        global proc

        # A function to start the main application from the wizard:
        def start_main_from_wizard(root):
            # Close the main window
            root.close()
            # and execute start_main
            start_main()

        # Load in the interface so it is accessible from QML
        context = engine.rootContext()
        engine.load(qml_path + "/wizard/wizard.qml")
        interface = WizardInterface(lambda: start_main_from_wizard(root))
        root = engine.rootObjects()[0]
        context.setContextProperty("wizardInterface", interface)
        # Bind user_created to onUserCreated
        interface.user_created.connect(root.onUserCreated)
        # And execute the application
        proc = app.exec_()

    # If the config file exists, show the main window, if not, show the wizard.
    if config.exists():
        start_main()
    else:
        start_wizard()

    # Exit python when the app starts
    sys.exit()
Пример #18
0
# App constants
MODULE_NAME = 'QtTodos'
MAJOR_VERSION = 0
MINOR_VERSION = 1

# Enable Ctrl-C to kill
signal.signal(signal.SIGINT, signal.SIG_DFL)

if __name__ == '__main__':
    # Create QML components from a Python classes
    # major_version and minor_version represent major and minor version numbers for when we import it in QML
    QtQml.qmlRegisterType(TodosViewModel, MODULE_NAME, MAJOR_VERSION,
                          MINOR_VERSION, 'TodosViewModel')
    QtQml.qmlRegisterType(SettingsViewModel, MODULE_NAME, MAJOR_VERSION,
                          MINOR_VERSION, 'SettingsViewModel')
    QtQml.qmlRegisterType(TodosListModel, MODULE_NAME, MAJOR_VERSION,
                          MINOR_VERSION, 'TodosListModel')

    # Use render loop that supports persistent 6major_versionfps
    os.environ['QSG_RENDER_LOOP'] = 'windows'

    # Create system app
    app = QtGui.QGuiApplication(sys.argv)

    # Initialize QML rendering engine
    engine = QtQml.QQmlApplicationEngine(parent=app)
    engine.load('main.qml')

    # Use the app's status as an exit code
    sys.exit(
        app.exec_())  # exec_ to avoid collision with built in exec function