예제 #1
0
def run():
    directory = os.path.dirname(os.path.abspath(__file__))

    appIcon = QIcon()
    appIcon.addFile(os.path.join(directory, "python.png"), QSize(64, 64))
    app.setWindowIcon(appIcon)

    from . import registerQmlTypes

    registerQmlTypes()

    engine = QQmlApplicationEngine()
    context = QQmlContext(engine)

    mainQml = QUrl.fromLocalFile(os.path.join(directory, "Main.qml"))

    component = QQmlComponent(engine)
    component.loadUrl(mainQml)

    if component.isError():
        for error in component.errors():
            print("Error: ", error.toString())

    dialog = component.create(context)

    return app.exec_()
예제 #2
0
    def spawnPrintView(self):
        if self._print_view is None:
            path = QUrl.fromLocalFile(os.path.join(self._plugin_path, "PrintWindow.qml"))
            component = QQmlComponent(Application.getInstance()._engine, path)

            self._print_context = QQmlContext(Application.getInstance()._engine.rootContext())
            self._print_context.setContextProperty("OutputDevice", self)
            self._print_view = component.create(self._print_context)

            if component.isError():
                Logger.log("e", " Errors creating component: \n%s", "\n".join(
                    [e.toString() for e in component.errors()]))

        if self._print_view is not None:
            self._print_view.show()
예제 #3
0
def main():
	# Set up correct Ctrl-C behavior.
	signal.signal(signal.SIGINT, signal.SIG_DFL)
	
	app = QGuiApplication( sys.argv )
	engine = QQmlEngine()
	engine.addImportPath( path.join( path.dirname( __file__ ), 'ui', 'qml' ) )
	core.register_types()

	component = QQmlComponent( engine )
	component.loadUrl( QUrl( '/home/feoh3/.config/nube/hud.qml' ) )

	if component.isError():
		print( "\n".join( error.toString() for error in component.errors() ) )
	else:
		window = component.create()

		app.exec_()