Esempio n. 1
0
    def finalize(self):
        """Finalize gui load"""

        BaseWidget.set_run_mode(False)  # call .stop() for each brick

        self.hardware_repository.close()

        QtImport.QApplication.sendPostedEvents()
        QtImport.QApplication.processEvents()

        self.save_size()
Esempio n. 2
0
    def finalize(self):
        """Finalize gui load"""

        BaseWidget.set_run_mode(False)  # call .stop() for each brick

        self.hardware_repository.close()

        QtImport.QApplication.sendPostedEvents()
        QtImport.QApplication.processEvents()

        self.save_size()
Esempio n. 3
0
    def execute(self, config):
        """Start in execution mode"""
        self.splash_screen.set_message("Executing configuration...")
        self.splash_screen.set_progress_value(90)
        self.display()

        main_window = None

        if len(self.windows) > 0:
            main_window = self.windows[0]
            main_window.configuration = config
            QtImport.QApplication.setActiveWindow(main_window)
            if self.no_border:
                main_window.move(0, 0)
                width = QtImport.QApplication.desktop().width()
                height = QtImport.QApplication.desktop().height()
                main_window.resize(QtImport.QSize(width, height))

            # make connections
            widgets_dict = dict([(
                isinstance(w.objectName, collections.Callable)
                and str(w.objectName()) or None,
                w,
            ) for w in QtImport.QApplication.allWidgets()])

            def make_connections(items_list):
                """Creates connections"""

                for item in items_list:
                    try:
                        sender = widgets_dict[item["name"]]
                    except KeyError:
                        logging.getLogger().error(
                            "Could not find receiver widget %s" % item["name"])
                    else:
                        for connection in item["connections"]:
                            _receiver = (connection["receiver"]
                                         or connection["receiverWindow"])
                            try:
                                receiver = widgets_dict[_receiver]
                            except KeyError:
                                logging.getLogger().error(
                                    "Could not find " + "receiver widget %s",
                                    _receiver)
                            else:
                                try:
                                    slot = getattr(receiver,
                                                   connection["slot"])
                                    # etattr(sender, connection["signal"]).connect(slot)
                                except AttributeError:
                                    logging.getLogger().error(
                                        "No slot '%s' " % connection["slot"] +
                                        "in receiver %s" % _receiver)
                                else:
                                    getattr(sender,
                                            connection["signal"]).connect(slot)
                                    # sender.connect(sender,
                                    #    QtCore.SIGNAL(connection["signal"]),
                                    #    slot)
                    make_connections(item["children"])

            self.splash_screen.set_progress_value(95)
            self.splash_screen.set_message("Connecting bricks...")
            make_connections(config.windows_list)

            # set run mode for every brick
            self.splash_screen.set_progress_value(100)
            self.splash_screen.set_message("Setting run mode...")
            BaseWidget.set_run_mode(True)

            if self.show_maximized:
                main_window.showMaximized()
            else:
                main_window.show()

            for window in self.windows:
                if window._show:
                    window.show()

        if BaseWidget._menubar:
            BaseWidget._menubar.set_exp_mode(False)

        return main_window
Esempio n. 4
0
    def execute(self, config):
        """Start in execution mode"""
        self.splash_screen.set_message("Executing configuration...")
        self.splash_screen.set_progress_value(90)
        self.display()

        main_window = None

        if len(self.windows) > 0:
            main_window = self.windows[0]
            main_window.configuration = config
            QtImport.QApplication.setActiveWindow(main_window)
            if self.no_border:
                main_window.move(0, 0)
                width = QtImport.QApplication.desktop().width()
                height = QtImport.QApplication.desktop().height()
                main_window.resize(QtImport.QSize(width, height))

            # make connections
            widgets_dict = dict(
                [
                    (
                        isinstance(w.objectName, collections.Callable)
                        and str(w.objectName())
                        or None,
                        w,
                    )
                    for w in QtImport.QApplication.allWidgets()
                ]
            )

            def make_connections(items_list):
                """Creates connections"""

                for item in items_list:
                    try:
                        sender = widgets_dict[item["name"]]
                    except KeyError:
                        logging.getLogger().error(
                            "Could not find receiver widget %s" % item["name"]
                        )
                    else:
                        for connection in item["connections"]:
                            _receiver = (
                                connection["receiver"] or connection["receiverWindow"]
                            )
                            try:
                                receiver = widgets_dict[_receiver]
                            except KeyError:
                                logging.getLogger().error(
                                    "Could not find " + "receiver widget %s", _receiver
                                )
                            else:
                                try:
                                    slot = getattr(receiver, connection["slot"])
                                    # etattr(sender, connection["signal"]).connect(slot)
                                except AttributeError:
                                    logging.getLogger().error(
                                        "No slot '%s' " % connection["slot"]
                                        + "in receiver %s" % _receiver
                                    )
                                else:
                                    getattr(sender, connection["signal"]).connect(slot)
                                    # sender.connect(sender,
                                    #    QtCore.SIGNAL(connection["signal"]),
                                    #    slot)
                    make_connections(item["children"])

            self.splash_screen.set_progress_value(95)
            self.splash_screen.set_message("Connecting bricks...")
            make_connections(config.windows_list)

            # set run mode for every brick
            self.splash_screen.set_progress_value(100)
            self.splash_screen.set_message("Setting run mode...")
            BaseWidget.set_run_mode(True)

            if self.show_maximized:
                main_window.showMaximized()
            else:
                main_window.show()

            for window in self.windows:
                if window._show:
                    window.show()

        if BaseWidget._menubar:
            BaseWidget._menubar.set_exp_mode(False)

        return main_window