def __init__(self): qInstallMessageHandler(FramUtil.qt_msg_handler) self.rpc = RpcClient() appGuid = 'F3FF80BA-BA05-4277-8063-82A6DB9245A3' self.app = QtSingleApplication(appGuid, sys.argv) self.app.setWindowIcon(QtGui.QIcon("resources/ico/hooklogger.ico")) splash = HookMatrixSplash() splash.show() if self.app.isRunning(): sys.exit(0) self.engine = QQmlApplicationEngine() self.context = self.engine.rootContext() self.context.setContextProperty('rpc', self.rpc) self.db = HookAndLineHookMatrixDB() self.context.setContextProperty('db', self.db) self.state_machine = StateMachine(app=self, db=self.db) self.context.setContextProperty('stateMachine', self.state_machine) self.serial_port_manager = SerialPortManager(app=self, db=self.db) self.context.setContextProperty('serialPortManager', self.serial_port_manager) self.label_printer = LabelPrinter(app=self, db=self.db) self.context.setContextProperty('labelPrinter', self.label_printer) self.sites = Sites(app=self, db=self.db) self.context.setContextProperty('sites', self.sites) self.drops = Drops(app=self, db=self.db) self.context.setContextProperty('drops', self.drops) self.hooks = Hooks(app=self, db=self.db) self.context.setContextProperty('hooks', self.hooks) self.gear_performance = GearPerformance(app=self, db=self.db) self.context.setContextProperty('gearPerformance', self.gear_performance) self.notes = Notes(app=self, db=self.db) self.context.setContextProperty("notes", self.notes) self.settings = Settings(app=self, db=self.db) self.context.setContextProperty("settings", self.settings) self.engine.load(QUrl('qrc:/qml/hookandline_hookmatrix/main_hookmatrix.qml')) splash.close() self.engine.quit.connect(self.app.quit) sys.exit(self.app.exec_())
def __init__(self): qInstallMessageHandler(FramUtil.qt_msg_handler) # self.app = QApplication(sys.argv) appGuid = 'F3FF80BA-BA05-4277-8063-82A6DB9245A2' self.app = QtSingleApplication(appGuid, sys.argv) if self.app.isRunning(): sys.exit(0) self.app.unhandledExceptionCaught.connect(self.exception_caught) self.engine = QQmlApplicationEngine() self.context = self.engine.rootContext() qmlRegisterType(FramTreeItem, 'FramTreeItem', 1, 0, 'FramTreeItem') # Set Contexts wfs = WindowFrameSize() self.context.setContextProperty('wfs', wfs) fl = FramLog() self.context.setContextProperty('framLog', fl) db = TrawlBackdeckDB() self.context.setContextProperty('db', db) self.sound_player = SoundPlayer() self.label_printer = LabelPrinter(app=self, db=db) self.settings = Settings(db=db) self.state_machine = StateMachine(app=self, db=db) self.serial_port_manager = SerialPortManager(app=self, db=db) self.network_testing = NetworkTesting(app=self, db=db) self.protocol_viewer = ProtocolViewer(app=self, db=db) self.home = Home(app=self, db=db) self.haul_selection = HaulSelection(app=self, db=db) self.process_catch = ProcessCatch(app=self, db=db) self.weigh_baskets = WeighBaskets(app=self, db=db) self.fish_sampling = FishSampling(app=self, db=db) self.salmon_sampling = SalmonSampling(app=self, db=db) self.corals_sampling = CoralsSampling(app=self, db=db) self.special_actions = SpecialActions(app=self, db=db) self.qaqc = QAQC(app=self, db=db) self.reports = Reports(db=db) self.notes = Notes(app=self, db=db) self.context.setContextProperty("soundPlayer", self.sound_player) self.context.setContextProperty("settings", self.settings) self.context.setContextProperty("home", self.home) self.context.setContextProperty("haulSelection", self.haul_selection) self.context.setContextProperty('processCatch', self.process_catch) self.context.setContextProperty("weighBaskets", self.weigh_baskets) self.context.setContextProperty("fishSampling", self.fish_sampling) self.context.setContextProperty("salmonSampling", self.salmon_sampling) self.context.setContextProperty("coralsSampling", self.corals_sampling) self.context.setContextProperty("specialActions", self.special_actions) self.context.setContextProperty("qaqc", self.qaqc) self.context.setContextProperty("reports", self.reports) self.context.setContextProperty("serialPortManager", self.serial_port_manager) self.context.setContextProperty("stateMachine", self.state_machine) self.context.setContextProperty("protocolViewer", self.protocol_viewer) self.context.setContextProperty("networkTesting", self.network_testing) self.context.setContextProperty("notes", self.notes) self.engine.load(QUrl('qrc:/qml/trawl/main_backdeck.qml')) self.win = self.engine.rootObjects()[0] self.msg_box = self.win.findChild(QObject, "dlgUnhandledException") self.engine.quit.connect(self.app.quit) sys.exit(self.app.exec_())
def __init__(self): super().__init__() qInstallMessageHandler(FramUtil.qt_msg_handler) # self.app = QApplication(sys.argv) appGuid = 'F3FF80BA-BA05-4277-8063-82A6DB9245A2' self.app = QtSingleApplication(appGuid, sys.argv) self.app.setWindowIcon(QtGui.QIcon("resources/ico/hooklogger_v2.ico")) splash = FpcSplash() splash.show() if self.app.isRunning(): sys.exit(0) # qmlRegisterType(FramTreeItem, 'FramTreeItem', 1, 0, 'FramTreeItem') self.engine = QQmlApplicationEngine() qmlRegisterType(TextFieldDoubleValidator, "FRAM", 1, 0, "TextFieldDoubleValidator") self.context = self.engine.rootContext() fl = FramLog() self.context.setContextProperty('framLog', fl) db = HookandlineFpcDB() self.context.setContextProperty('db', db) # self.textfield_double_validator = TextFieldDoubleValidator() # self.context.setContextProperty('TextFieldDoubleValidator', self.textfield_double_validator) # PyQt5 Threading approach self._rpc_thread = QThread() self._rpc_worker = RpcServer() self._rpc_worker.moveToThread(self._rpc_thread) self._rpc_worker.speciesChanged.connect(self._species_changed) self._rpc_thread.started.connect(self._rpc_worker.run) self._rpc_thread.start() logging.info(f"\tRPC thread and worker established") # Technique that works - traditional python threading, although the queue is not needed anymore # self._queue = Queue() # self._rpc_server = threading.Thread(target=RpcServer, kwargs={'queue': self._queue}) # self._rpc_server.setDaemon(True) # self._rpc_server.start() self.fpc_main = FpcMain(app=self) self.settings = Settings(db=db) self.serial_port_manager = SerialPortManager(app=self, db=db) self.serial_port_simulator = SerialPortSimulator(app=self, db=db) self.data_converter = DataConverter(app=self, db=db) self.sensor_data_feeds = SensorDataFeeds(app=self, db=db) self.species_review = SpeciesReview(app=self, db=db) self.end_of_site_validation = EndOfSiteValidation(app=self, db=db) logging.info(f"\tComponent classes all initialized") self.context.setContextProperty('fpcMain', self.fpc_main) self.context.setContextProperty('settings', self.settings) self.context.setContextProperty('serialPortManager', self.serial_port_manager) self.context.setContextProperty('serialPortSimulator', self.serial_port_simulator) self.context.setContextProperty('dataConverter', self.data_converter) self.context.setContextProperty('sensorDataFeeds', self.sensor_data_feeds) self.context.setContextProperty('speciesReview', self.species_review) self.context.setContextProperty('endOfSiteValidation', self.end_of_site_validation) logging.info(f"\tContext Properties all set") # self.widget = self.app.instance() # self.widget.setAttribute(QtCore.Qt.WA_OpaquePaintEvent) # self.widget.setAttribute(QtCore.Qt.WA_NoSystemBackground) # self.view = QQuickView() # self.view.setSource(QUrl('qrc:/qml/hookandline/main_fpc.qml')) # self.view.show() try: self.engine.load(QUrl('qrc:/qml/hookandline/main_fpc.qml')) splash.close() self.win = self.engine.rootObjects()[0] self.msg_box = self.win.findChild(QObject, "dlgUnhandledException") logging.info(f"\tmain_fpc.qml loaded") self.engine.quit.connect(self.app.quit) sys.exit(self.app.exec_()) except Exception as ex: logging.error(f"error loading the application: {ex}")
def __init__(self): qInstallMessageHandler(FramUtil.qt_msg_handler) self.rpc = RpcClient() # self.app = QApplication(sys.argv) appGuid = 'F3FF80BA-BA05-4277-8063-82A6DB9245A5' self.app = QtSingleApplication(appGuid, sys.argv) if self.app.isRunning(): sys.exit(0) self.app.unhandledExceptionCaught.connect(self.exception_caught) qmlRegisterType(SortFilterProxyModel, "SortFilterProxyModel", 0, 1, "SortFilterProxyModel") self.engine = QQmlApplicationEngine() self.context = self.engine.rootContext() # qmlRegisterType(FramTreeItem, 'FramTreeItem', 1, 0, 'FramTreeItem') # Set Contexts # wfs = WindowFrameSize() # self.context.setContextProperty('wfs', wfs) fl = FramLog() self.context.setContextProperty('framLog', fl) db = HookAndLineHookCutterDB() self.context.setContextProperty('db', db) self.state_machine = StateMachine(app=self, db=db) self.sound_player = SoundPlayer(app=self, db=db) self.serial_port_manager = SerialPortManager(app=self, db=db) self.sites = Sites(app=self, db=db) self.fish_sampling = FishSampling(app=self, db=db) self.label_printer = LabelPrinter(app=self, db=db) self.notes = Notes(app=self, db=db) # self.qaqc = QAQC(app=self, db=db) self.context.setContextProperty("soundPlayer", self.sound_player) self.context.setContextProperty("stateMachine", self.state_machine) self.context.setContextProperty("sites", self.sites) self.context.setContextProperty("fishSampling", self.fish_sampling) self.context.setContextProperty("serialPortManager", self.serial_port_manager) self.context.setContextProperty("labelPrinter", self.label_printer) self.context.setContextProperty("notes", self.notes) # self.context.setContextProperty("qaqc", self.qaqc) # self.setAttribute(QtCore.Qt.WA_DeleteOnClose) try: self.engine.load( QUrl('qrc:/qml/survey_backdeck/main_backdeck.qml')) self.win = self.engine.rootObjects()[0] self.msg_box = self.win.findChild(QObject, "dlgUnhandledException") self.engine.quit.connect(self.app.quit) sys.exit(self.app.exec_()) except Exception as ex: logging.error(f"bad stuff happening: {ex}")
logging.info("-" * 60) # Separate each session with a horizontal line. logging.info(f'OPTECS v{optecs_version} application launched ' + time.strftime("%m/%d/%Y %H:%M")) # Move older log files to a subdirectory, excluding today's ObserverLogUtility.archive_log_files(exclude=[log_filename_for_today]) # perform any migrations required prior to run migrator = ObserverDBMigrations() migrator.perform_migrations() connect_orm() # ObserverORM main_qml = QUrl('qrc:/qml/observer/ObserverLogin.qml') appGuid = '8284d07e-d07c-4aad-8874-36720e37ce53' app = QtSingleApplication(appGuid, sys.argv) logging.info(f'Qt Version: {QT_VERSION_STR}') logging.info(get_db_version_info()) # logging.info('after self.app') if app.isRunning(): logging.error('Application is already running, abort.') sys.exit(-1) engine = QQmlApplicationEngine() context = engine.rootContext() # Set context properties observer_data = ObserverData() context.setContextProperty('observer_data', observer_data)
def __init__(self): logging.info(f"Trawl Analyzer starting at: {arrow.now().format('MM/DD/YYYY HH:mm:ss')}") qInstallMessageHandler(FramUtil.qt_msg_handler) app_guid = str(uuid1()) logging.info(f"uuid={app_guid}") self.app = QtSingleApplication(app_guid, sys.argv) if self.app.isRunning(): sys.exit(0) self.app.unhandledExceptionCaught.connect(self.exception_caught) # self.app.aboutToQuit.connect(self.about_to_quit_callback) self.engine = QQmlApplicationEngine() self.context = self.engine.rootContext() qmlRegisterType(FramTreeItem, 'FramTreeItem', 1, 0, 'FramTreeItem') qmlRegisterType(SortFilterProxyModel, "SortFilterProxyModel", 0, 1, "SortFilterProxyModel") # qmlRegisterType(MatplotlibFigure, "MatplotlibFigure", 1, 0, "MatplotlibFigure") qmlRegisterType(FigureCanvasQTAgg, "MplBackend", 1, 0, "MplFigureCanvas") # Set Contexts # wfs = WindowFrameSize() # self.context.setContextProperty('wfs', wfs) self.settings = Settings(app=self) self.context.setContextProperty("settings", self.settings) fl = FramLog() self.context.setContextProperty('framLog', fl) self.db = TrawlAnalyzerDB() self.context.setContextProperty('db', self.db) self.common_functions = CommonFunctions(app=self) self.context.setContextProperty('commonFunctions', self.common_functions) self.file_management = FileManagement(app=self, db=self.db) self.context.setContextProperty("fileManagement", self.file_management) self.data_completeness = DataCompleteness(app=self, db=self.db) self.context.setContextProperty("dataCompleteness", self.data_completeness) self.time_series = TimeSeries(app=self, db=self.db) self.context.setContextProperty("timeSeries", self.time_series) self.engine.load(QUrl('qrc:/qml/trawl_analyzer/main_trawl_analyzer.qml')) """ Used to access QML objects from Python. References: https://forum.qt.io/topic/62966/parent-in-pyqt5-with-qml http://stackoverflow.com/questions/24111717/how-to-bind-buttons-in-qt-quick-to-python-pyqt-5 """ self.win = self.engine.rootObjects()[0] self.qml_item = self.win.findChild(QObject, "mplFigure") self.time_series.set_qml_item(self.qml_item) self.msg_box = self.win.findChild(QObject, "dlgUnhandledException") self.tracklines_item = self.win.findChild(QObject, "mplTracklines") self.time_series._mpl_map.set_qml_item(self.tracklines_item) self.engine.quit.connect(self.app.quit) sys.exit(self.app.exec_())