def startGui(): settings = Settings() try: settings.load() except JSONSettings.SettingsError as e: print(e) quit() app = QGuiApplication([]) app.setOrganizationName('Schweinesystem') app.setOrganizationDomain('schweinesystem.eu') app.setApplicationName('PasswdAdmin') signal.signal(signal.SIGINT, signit_handler) timer = QTimer() timer.start(500) # You may change this if you wish. timer.timeout.connect(lambda: None) # Let the interpreter run each 500 ms. engine = QQmlApplicationEngine() usermodel = UserModel(settings) context = engine.rootContext() context.setContextProperty('userModel', usermodel) thisFile = os.path.realpath(__file__) thisDir = os.path.dirname(thisFile) engine.load(thisDir + '/qml/MainWidget.qml') if not engine.rootObjects(): sys.exit(-1) sys.exit(app.exec_())
def athenumEngineStart(): app = QGuiApplication(sys.argv) athenumInfo = AthenumInfo() if len(sys.argv) > 1: if sys.argv[1] == '-platform' and sys.argv[2].find('webgl') != -1: print("Starting WebGl mode") athenumInfo.setWebGL() if sys.argv[1] == '-c': print("Console mode activated") consoleMode(sys.argv) sys.exit(0) app.setApplicationName("Full reptend prime & cyclic prime numbers") engine = QQmlApplicationEngine() platformName = platform.system() print('Platform name is', platformName) from Rational import Rational qmlRegisterType(Rational, 'Athenum', 1, 0, 'Rational') athenumModuleImport("SumModels") athenumModuleImport("DigitalCircle") athenumModuleImport("PrimeScales") athenumModuleImport("IntervalScales") athenumModuleImport("CyclicPrimes") athenumModuleImport("Primes") athenumModuleImport("GeometricProgression") athenumModuleImport("NumericSystem") copyClipboard = CopyClipboard() engine.rootContext().setContextProperty("athenumInfo", athenumInfo) engine.rootContext().setContextProperty("copyClipboard", copyClipboard) engine.load('qml/athenum.qml') print("Starting viewer") res = app.exec_() del engine sys.exit(res)
def run(): """Start Virtual Warehouse application.""" QGuiApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling) app = QGuiApplication(sys.argv) app.setOrganizationName("Bretislav Hajek") app.setOrganizationDomain("bretahajek.com") app.setApplicationName("Virtual Warehouse") app.setApplicationVersion(__version__) engine = QQmlApplicationEngine() controller = ViewController() engine.rootContext().setContextProperty("ViewController", controller) engine.rootContext().setContextProperty("versionNumber", __version__) app.setWindowIcon(QIcon(":/images/icon.png")) engine.load(QtCore.QUrl("qrc:/qml/main.qml")) if not engine.rootObjects(): sys.exit(-1) sys.exit(app.exec_())
def main(): # QApplication.setAttribute( Qt.AA_UseDesktopOpenGL ) # QSurfaceFormat.setDefaultFormat(utils.defaultFormat(False)) # from vtk 8.2.0 app = QGuiApplication(sys.argv) app.setApplicationName('QtVTK-Py') # qmlRegisterType(FboItem, "QmlVTK", 1, 0, "Interactor") qmlRegisterType(FboItem, "QtVTK", 1, 0, "VtkFboItem") view = QQuickView() # qml file must begin with Item, not ApplicationWindow view.setSource(QUrl.fromLocalFile(abs_path("main.qml"))) # view.setTitle ("QQuickView Load") # view.setResizeMode(QQuickView.SizeRootObjectToView) # view.setFlags(Qt.FramelessWindowHint) view.show() ''' In the unlikely event, you will encounter the following problems: the QML window is stuck. Please check if you: import pyside2, and use QmlApplicationEngine().load to load only one qml-vtk window(containing qmlRegisterType class) . If you have to do this, plus self.createRenderer () to __ init__ function, fboitem class. Then it works but an error window, vtkoutputwindow, will be displayed. Then try to close the vtkoutputwindow (maybe call the Win32 API findwindow?) Recommended solution: import PyQt5 instead of pyside2; Or using QQuickView().setSource to load qml window; Or load another independent general qml window before load the qml-vtk window. ''' # engine1 = QQmlApplicationEngine() # qml file must begin with ApplicationWindow, not Item # engine1.load(os.path.join(os.path.dirname(__file__), "main.qml")) # another independent general qml window # engine = QQmlApplicationEngine() # engine.load(os.path.join(os.path.dirname(__file__), "app.qml")) # the qml-vtk window # if not engine.rootObjects(): # sys.exit(-1) sys.exit(app.exec_())
def main(): argv = sys.argv # Trick to set the style / not found how to do it in pythonic way argv.extend(["-style", "universal"]) app = QGuiApplication(argv) # why needed now? app.setOrganizationName("Some Company") app.setOrganizationDomain("somecompany.com") app.setApplicationName("Amazing Application") qmlRegisterType(FigureCanvasQTAggToolbar, "Backend", 1, 0, "FigureToolbar") imgProvider = MatplotlibIconProvider() # !! You must specified the QApplication as parent of QQmlApplicationEngine # otherwise a segmentation fault is raised when exiting the app engine = QQmlApplicationEngine(parent=app) engine.addImageProvider("mplIcons", imgProvider) context = engine.rootContext() data_model = DataSeriesModel() context.setContextProperty("dataModel", data_model) mainApp = Form(data=data_model) context.setContextProperty("draw_mpl", mainApp) engine.load(QUrl('main.qml')) win = engine.rootObjects()[0] mainApp.figure = win.findChild(QObject, "figure").getFigure() rc = app.exec_() # There is some trouble arising when deleting all the objects here # but I have not figure out how to solve the error message. # It looks like 'app' is destroyed before some QObject sys.exit(rc)
import ressource def shutdown(): '''Delete engine and qml object before python garbage collection''' del globals()["engine"] if __name__ == "__main__": #QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling) #bug on linux scaling if activated sys.argv += ['--style', 'material'] app = QGuiApplication(sys.argv) app.aboutToQuit.connect(shutdown) # set variables for settings app.setApplicationName("DipSim") app.setOrganizationName("IPR") app.setOrganizationDomain("IPR.com") hypervisor = SimHypervisor() # python compute hypervisor engine = QQmlApplicationEngine() # UI engine # add necesaary object linking UI and python data engine.rootContext().setContextProperty("hypervisor", hypervisor) engine.rootContext().setContextProperty("primCell", hypervisor.primCell) engine.rootContext().setContextProperty("dipModel", hypervisor.dipModel) engine.rootContext().setContextProperty("dipModelMinEnergy", hypervisor.dipModelMinEnergy) engine.rootContext().setContextProperty("dipModelMinEnergyMC", hypervisor.dipModelMinEnergyMC)
from bean.ProcessBean import ProcessBean from bean.SettingsBean import SettingsBean from controller.SettingsController import SettingsController from controller.ProcessController import ProcessController from core.Logger import Logger import resources if __name__ == "__main__": # Set up the application window app = QGuiApplication(sys.argv) version = "1.0.2" app.setOrganizationName("DV") app.setApplicationName("CSV-Synchronizer") app.setApplicationVersion(version) Logger().info("Start applicazione CSV-Synchronizer") Logger().info("Versione: " + version) # qmlFile = QFile(":/ui/main.qml") # qmlFile.open(QFile.ReadOnly | QFile.Text) # Load the QML file # qmlFile = os.path.join(os.path.dirname(__file__), "./ui/main.qml") qmlRegisterType(SettingsController, "SettingsController", 1, 0, "QMLSettingsController") qmlRegisterType(ProcessController, "ProcessController", 1, 0, "QMLProcessController") qmlRegisterType(ProcessBean, "ProcessBean", 1, 0, "QMLProcessBean") qmlRegisterType(SettingsBean, "SettingsBean", 1, 0, "QMLSettingsBean")