コード例 #1
0
ファイル: StateMachineBrick.py プロジェクト: natxo14/mxcube
    def __init__(self, *args):
        BaseWidget.__init__(self, *args)

        # Hardware objects ----------------------------------------------------
        self.state_machine_hwobj = None

        # Internal values -----------------------------------------------------
        self.cond_list = None
        self.states_list = None
        self.trans_list = None

        self.state_graph_node_list = []
        self.trans_graph_node_list = []
        self.condition_value_dict = {}

        # Properties ----------------------------------------------------------
        self.add_property("hwobj_state_machine", "string", "")

        # Signals ------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        _cond_states_gbox = QtImport.QGroupBox(r"States \ conditions", self)
        self.splitter = QtImport.QSplitter(QtImport.Qt.Vertical, self)
        self.cond_states_table = QtImport.QTableWidget(self.splitter)
        self.log_treewidget = QtImport.QTreeWidget(self.splitter)
        self.graph_graphics_view = QtImport.QGraphicsView(self)
        self.graph_graphics_scene = QtImport.QGraphicsScene(self)

        self.check_icon = Icons.load_icon("Check")
        self.reject_icon = Icons.load_icon("Delete")

        # Layout --------------------------------------------------------------
        _cond_states_gbox_vlayout = QtImport.QVBoxLayout(_cond_states_gbox)
        _cond_states_gbox_vlayout.addWidget(self.splitter)
        _cond_states_gbox_vlayout.setSpacing(2)
        _cond_states_gbox_vlayout.setContentsMargins(2, 2, 2, 2)

        _main_vlayout = QtImport.QHBoxLayout(self)
        _main_vlayout.addWidget(_cond_states_gbox)
        _main_vlayout.addWidget(self.graph_graphics_view)
        _main_vlayout.setSpacing(2)
        _main_vlayout.setContentsMargins(2, 2, 2, 2)

        # Other ---------------------------------------------------------------
        self.cond_states_table.verticalHeader().setDefaultSectionSize(20)
        self.cond_states_table.horizontalHeader().setDefaultSectionSize(20)
        # setSelectionMode(QtImport.QAbstractItemView::SingleSelection);
        font = self.cond_states_table.font()
        font.setPointSize(8)
        self.cond_states_table.setFont(font)

        self.splitter.setSizes([200, 20])
        self.log_treewidget.setColumnCount(6)
        self.log_treewidget.setHeaderLabels(
            ["State", "Start time", "End time", "Total time", "Previous state", "Notes"]
        )
        self.graph_graphics_view.setFixedSize(900, 600)
        self.graph_graphics_scene.setSceneRect(0, 0, 900, 600)
        self.graph_graphics_view.setScene(self.graph_graphics_scene)
        self.graph_graphics_view.setHorizontalScrollBarPolicy(
            QtImport.Qt.ScrollBarAlwaysOff
        )
        self.graph_graphics_view.setVerticalScrollBarPolicy(
            QtImport.Qt.ScrollBarAlwaysOff
        )
        self.graph_graphics_view.setDragMode(QtImport.QGraphicsView.RubberBandDrag)
        self.graph_graphics_view.setRenderHint(QtImport.QPainter.Antialiasing)
        self.graph_graphics_view.setRenderHint(QtImport.QPainter.TextAntialiasing)
コード例 #2
0
ファイル: ConnectionEditor.py プロジェクト: natxo14/mxcube
    def __init__(self, configuration):

        QtImport.QDialog.__init__(self, None)

        # Internal values -----------------------------------------------------
        self.has_changed = None
        self.configuration = configuration
        self.signalling_child_dict = {}
        self.receiving_child_dict = {}
        self.connecting_child_dict = {}

        # Signals ------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        main_splitter = QtImport.QSplitter(QtImport.Qt.Vertical, self)
        top_panel = QtImport.QWidget(main_splitter)
        bot_panel = QtImport.QWidget(main_splitter)

        emitter_panel = QtImport.QWidget(top_panel)
        self.emitter_windows_listwidget = QtImport.QListWidget(emitter_panel)
        self.emitter_objects_listwidget = QtImport.QListWidget(emitter_panel)
        self.emitter_signals_listwidget = QtImport.QListWidget(emitter_panel)
        self.emitter_objects_listwidget.setSortingEnabled(True)
        self.emitter_signals_listwidget.setSortingEnabled(True)

        receiver_panel = QtImport.QWidget(top_panel)
        self.receiver_windows_listwidget = QtImport.QListWidget(emitter_panel)
        self.receiver_objects_listwidget = QtImport.QListWidget(emitter_panel)
        self.receiver_slots_listwidget = QtImport.QListWidget(emitter_panel)
        self.receiver_objects_listwidget.setSortingEnabled(True)
        self.receiver_slots_listwidget.setSortingEnabled(True)

        self.add_connection_button = QtImport.QPushButton(
            "Add connection", self)

        self.connections_treewidget = QtImport.QTreeWidget(bot_panel)
        button_panel = QtImport.QWidget(bot_panel)
        self.remove_connection_button = QtImport.QPushButton(
            "Remove connection", button_panel)
        self.ok_button = QtImport.QPushButton("OK", button_panel)
        self.cancel_button = QtImport.QPushButton("Cancel", button_panel)

        # Layout --------------------------------------------------------------
        emitter_panel_layout = QtImport.QGridLayout(emitter_panel)
        emitter_panel_layout.addWidget(
            QtImport.QLabel("<h3>Emitters</h3>", self), 0, 1,
            QtImport.Qt.AlignHCenter)
        emitter_panel_layout.addWidget(QtImport.QLabel("Windows", self), 1, 0)
        emitter_panel_layout.addWidget(QtImport.QLabel("Objects", self), 1, 1)
        emitter_panel_layout.addWidget(QtImport.QLabel("Signals", self), 1, 2)
        emitter_panel_layout.addWidget(self.emitter_windows_listwidget, 2, 0)
        emitter_panel_layout.addWidget(self.emitter_objects_listwidget, 2, 1)
        emitter_panel_layout.addWidget(self.emitter_signals_listwidget, 2, 2)

        receiver_panel_layout = QtImport.QGridLayout(receiver_panel)
        receiver_panel_layout.addWidget(
            QtImport.QLabel("<h3>Receivers</h3>", self), 0, 1,
            QtImport.Qt.AlignHCenter)
        receiver_panel_layout.addWidget(QtImport.QLabel("Windows", self), 1, 0)
        receiver_panel_layout.addWidget(QtImport.QLabel("Objects", self), 1, 1)
        receiver_panel_layout.addWidget(QtImport.QLabel("Slots", self), 1, 2)
        receiver_panel_layout.addWidget(self.receiver_windows_listwidget, 2, 0)
        receiver_panel_layout.addWidget(self.receiver_objects_listwidget, 2, 1)
        receiver_panel_layout.addWidget(self.receiver_slots_listwidget, 2, 2)

        top_panel_layout = QtImport.QHBoxLayout(top_panel)
        top_panel_layout.addWidget(emitter_panel)
        top_panel_layout.addWidget(receiver_panel)
        top_panel_layout.addWidget(self.add_connection_button)
        top_panel_layout.setSpacing(0)
        top_panel_layout.setContentsMargins(0, 0, 0, 0)

        button_panel_layout = QtImport.QHBoxLayout(button_panel)
        button_panel_layout.addWidget(self.remove_connection_button)
        button_panel_layout.addStretch(0)
        button_panel_layout.addWidget(self.ok_button, QtImport.Qt.AlignRight)
        button_panel_layout.addWidget(self.cancel_button,
                                      QtImport.Qt.AlignRight)

        bot_panel_vlayout = QtImport.QVBoxLayout(bot_panel)
        bot_panel_vlayout.addWidget(
            QtImport.QLabel("<h3>Established connections</h3>", bot_panel))
        bot_panel_vlayout.addWidget(self.connections_treewidget)
        bot_panel_vlayout.addWidget(button_panel)

        main_splitter_vbox = QtImport.QVBoxLayout(main_splitter)
        main_splitter_vbox.addWidget(top_panel)
        main_splitter_vbox.addWidget(bot_panel)
        main_splitter_vbox.setSpacing(5)
        main_splitter_vbox.setContentsMargins(2, 2, 2, 2)

        main_layout = QtImport.QVBoxLayout(self)
        main_layout.addWidget(main_splitter)

        # SizePolicies --------------------------------------------------------
        self.add_connection_button.setSizePolicy(QtImport.QSizePolicy.Fixed,
                                                 QtImport.QSizePolicy.Fixed)
        self.remove_connection_button.setSizePolicy(QtImport.QSizePolicy.Fixed,
                                                    QtImport.QSizePolicy.Fixed)
        self.ok_button.setSizePolicy(QtImport.QSizePolicy.Fixed,
                                     QtImport.QSizePolicy.Fixed)
        self.cancel_button.setSizePolicy(QtImport.QSizePolicy.Fixed,
                                         QtImport.QSizePolicy.Fixed)
        self.connections_treewidget.setSizePolicy(
            QtImport.QSizePolicy.Expanding, QtImport.QSizePolicy.Expanding)

        # Qt signal/slot connections ------------------------------------------
        self.emitter_windows_listwidget.currentItemChanged.connect(
            self.emitter_window_changed)
        self.emitter_objects_listwidget.currentItemChanged.connect(
            self.emitter_object_changed)
        self.receiver_windows_listwidget.currentItemChanged.connect(
            self.receiver_window_changed)
        self.receiver_objects_listwidget.currentItemChanged.connect(
            self.receiver_object_changed)
        self.add_connection_button.clicked.connect(
            self.add_connection_button_clicked)
        self.remove_connection_button.clicked.connect(
            self.remove_connection_button_clicked)
        self.ok_button.clicked.connect(self.ok_button_clicked)
        self.cancel_button.clicked.connect(self.cancel_button_clicked)
        self.connections_treewidget.itemSelectionChanged.connect(
            self.connections_treewidget_selection_changed)

        # Other ---------------------------------------------------------------
        self.connections_treewidget.setColumnCount(7)
        self.connections_treewidget.setHeaderLabels([
            "",
            "Emitter window",
            "Emitter object",
            "Signal",
            "Receiver window",
            "Receiver object",
            "Slot",
        ])
        self.setWindowTitle("Connection Editor")
        self.connections_treewidget.setSortingEnabled(True)