Пример #1
0
    def finalize(self):
        """Finalize gui load"""

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

        self.hardware_repository.close()

        qt_import.QApplication.sendPostedEvents()
        qt_import.QApplication.processEvents()

        self.save_size()
Пример #2
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
            qt_import.QApplication.setActiveWindow(main_window)
            if self.no_border:
                main_window.move(0, 0)
                width = qt_import.QApplication.desktop().width()
                height = qt_import.QApplication.desktop().height()
                main_window.resize(qt_import.QSize(width, height))

            # make connections
            widgets_dict = dict([(
                isinstance(w.objectName, collections.Callable)
                and str(w.objectName()) or None,
                w,
            ) for w in qt_import.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:
                                    if not isinstance(sender, NullBrick):
                                        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)

        HWR.beamline.force_emit_signals()

        return main_window