Exemplo n.º 1
0
 def __init__(self, level=logging.INFO, parent=None):
     # Initialize with parent class
     QtGui.QTableWidget.__init__(self, parent)
     # Customize widget
     self.resize(778, 277)
     self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
     self.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
     self.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
     self.setShowGrid(False)
     self.setSortingEnabled(True)
     self.setAlternatingRowColors(True)
     column_names = [
         u"Nb", u"Date", u"Thread", u"Sequence", u"Type", u"ID", u"Level",
         u"Message"
     ]
     self.setColumnCount(len(column_names))
     self.setRowCount(0)
     for i, name in enumerate(column_names):
         item = QtGui.QTableWidgetItem(name)
         self.setHorizontalHeaderItem(i, item)
     mode = QtGui.QHeaderView.ResizeToContents
     self.horizontalHeader().setResizeMode(mode)
     self.horizontalHeader().setStretchLastSection(True)
     self.verticalHeader().hide()
     self.setItemDelegate(CustomDelegate())
     palette = self.palette()
     name = QtGui.QPalette.AlternateBase
     color = QtCore.Qt.lightGray
     palette.setColor(name, color)
     self.setPalette(palette)
     self.sortByColumn(0, QtCore.Qt.AscendingOrder)
     self.verticalHeader().setDefaultSectionSize(30)
     # Init attributes
     self.signal_handler = SignalHandler(level)
     self.signal_handler.signal.connect(self.handle_log_record)
     add_log_handler(self.signal_handler)
     self.log_items = []
     self.log_count = 0
Exemplo n.º 2
0
 def __init__(self, level=logging.INFO, parent=None):
     # Initialize with parent class
     QtGui.QTableWidget.__init__(self, parent)
     # Customize widget
     self.resize(778, 277)
     self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
     self.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
     self.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
     self.setShowGrid(False)
     self.setSortingEnabled(True)
     self.setAlternatingRowColors(True)
     column_names = [u"Nb", u"Date", u"Thread", u"Sequence",
                     u"Type", u"ID", u"Level", u"Message"]
     self.setColumnCount(len(column_names))
     self.setRowCount(0)
     for i, name in enumerate(column_names):
         item = QtGui.QTableWidgetItem(name)
         self.setHorizontalHeaderItem(i, item)
     mode = QtGui.QHeaderView.ResizeToContents
     self.horizontalHeader().setResizeMode(mode)
     self.horizontalHeader().setStretchLastSection(True)
     self.verticalHeader().hide()
     self.setItemDelegate(CustomDelegate())
     palette = self.palette()
     name = QtGui.QPalette.AlternateBase
     color = QtCore.Qt.lightGray
     palette.setColor(name, color)
     self.setPalette(palette)
     self.sortByColumn(0, QtCore.Qt.AscendingOrder)
     self.verticalHeader().setDefaultSectionSize(30)
     # Init attributes
     self.signal_handler = SignalHandler(level)
     self.signal_handler.signal.connect(self.handle_log_record)
     add_log_handler(self.signal_handler)
     self.log_items = []
     self.log_count = 0
Exemplo n.º 3
0
    def __init__(self, parent=None):
        # Setup UI
        super(EditorWidget, self).__init__(parent)
        self.ui = Ui_PySequenceEditor()
        self.ui.setupUi(self)

        # Customize UI
        self.ui.main_splitter.setStretchFactor(1, 1)
        self.ui.center_splitter.setStretchFactor(0, 1)
        self.logging_tab = LoggingTabWidget(parent=self)
        self.logging_tab.setTabPosition(QtGui.QTabWidget.South)
        self.logging_tab.log_table.verticalHeader().setDefaultSectionSize(20)
        self.logging_tab.resize(0, 0)
        self.ui.center_splitter.addWidget(self.logging_tab)
        self.ui.tab_widget.clear()
        self.control_widget = ControlWidget(parent=self)
        self.ui.horizontalLayout.insertWidget(13, self.control_widget)

        # Monkey Patching
        def dropEvent(self, event):
            QtGui.QTreeWidget.dropEvent(self, event)
            self.currentItemChanged.emit(None, None)
        sub_editor = self.ui.subsequence_editor
        sub_editor.dropEvent = types.MethodType(dropEvent, sub_editor)

        # Stream redirection
        self.save_stdout = sys.stdout
        self.save_stderr = sys.stderr
        safe_write = lambda arg: self.print_signal.emit(arg)
        safe_write.write = safe_write
        sys.stdout = sys.stderr = safe_write
        self.print_signal.connect(self.logging_tab.write)

        # Sequence Engine
        self.control_widget.enable_path_request()
        self.control_widget.path_requested.connect(self.on_path_requested)
        self.control_widget.log_signal.connect(self.log)

        # Property editor initialization
        self.block_model = BlockModel(self, parent=self.ui.property_editor)
        self.block_model.model_changed.connect(partial(self.set_changed, True))
        self.ui.property_editor.setModel(self.block_model)

        # Create block Mapping
        self.block_mapping = {"Begin/End":   {'Begin':  XBM.BEGIN,
                                              'End'  :  XBM.END},
                              "Time":        {'Init':   XBM.TIMEINIT,
                                              'Wait':   XBM.WAIT},
                              "Branch":      {'Branch': XBM.BRANCH},
                              "Subsequence": {'Macro':  XBM.MACRO}}
        action_list = get_action_list()
        self.module_to_name = {module: name for name, module in action_list}
        for name, module in action_list:
            family = module.split(".")[-2].capitalize()
            self.block_mapping.setdefault(family, {})[name] = (XBM.ACTION, module)


        # Block list initialization
        self.ui.block_list.setHeaderLabels(['Block list'])
        self.fill_block_list()
        self.ui.block_list.expandAll()
        self.ui.block_list.resizeColumnToContents(0)
        self.ui.block_list.expandToDepth(0)

        # Sequence initialization
        self.current_sequence = XMLSequence("New sequence")

        # Signals connection
        self.ui.open_button.clicked.connect(self.on_open)
        self.ui.new_button.clicked.connect(self.on_new)
        self.ui.save_button.clicked.connect(self.on_save)
        self.ui.save_as_button.clicked.connect(self.on_save_as)
        self.ui.undo_button.clicked.connect(self.on_undo)
        self.ui.redo_button.clicked.connect(self.on_redo)
        self.ui.about_button.clicked.connect(self.on_about)
        self.ui.zoom_slider.valueChanged.connect(self.on_change_zoom_value)
        self.ui.block_list.itemClicked.connect(self.on_click_family)
        self.ui.tab_widget.tabCloseRequested.connect(self.on_close_tab)
        self.ui.tab_widget.currentChanged.connect(self.update_zoom_slider)
        sub_editor = self.ui.subsequence_editor
        sub_editor.itemDoubleClicked.connect(self.subsequence_double_clicked)
        sub_editor.itemActivated.connect(self.subsequence_activated)
        sub_editor.customContextMenuRequested.connect(self.context_requested)
        sub_editor.currentItemChanged.connect(self.subsequence_changed)
        QtGui.QShortcut(QtGui.QKeySequence.SelectAll, self, self.on_select_all)

        # Update
        self.file_path = None
        self.changed = False
        self.set_changed(False)
        self.update()

        # Logging
        self.log(u'Sequence editor initialized.')


        self.signal_handler = SignalHandler(logging.DEBUG)
        self.signal_handler.signal.connect(self.handle_log_record)
        add_log_handler(self.signal_handler)
Exemplo n.º 4
0
    def __init__(self, parent=None):
        # Setup UI
        super(EditorWidget, self).__init__(parent)
        self.ui = Ui_PySequenceEditor()
        self.ui.setupUi(self)

        # Customize UI
        self.ui.main_splitter.setStretchFactor(1, 1)
        self.ui.center_splitter.setStretchFactor(0, 1)
        self.logging_tab = LoggingTabWidget(parent=self)
        self.logging_tab.setTabPosition(QtGui.QTabWidget.South)
        self.logging_tab.log_table.verticalHeader().setDefaultSectionSize(20)
        self.logging_tab.resize(0, 0)
        self.ui.center_splitter.addWidget(self.logging_tab)
        self.ui.tab_widget.clear()
        self.control_widget = ControlWidget(parent=self)
        self.ui.horizontalLayout.insertWidget(13, self.control_widget)

        # Monkey Patching
        def dropEvent(self, event):
            QtGui.QTreeWidget.dropEvent(self, event)
            self.currentItemChanged.emit(None, None)

        sub_editor = self.ui.subsequence_editor
        sub_editor.dropEvent = types.MethodType(dropEvent, sub_editor)

        # Stream redirection
        self.save_stdout = sys.stdout
        self.save_stderr = sys.stderr
        safe_write = lambda arg: self.print_signal.emit(arg)
        safe_write.write = safe_write
        sys.stdout = sys.stderr = safe_write
        self.print_signal.connect(self.logging_tab.write)

        # Sequence Engine
        self.control_widget.enable_path_request()
        self.control_widget.path_requested.connect(self.on_path_requested)
        self.control_widget.log_signal.connect(self.log)

        # Property editor initialization
        self.block_model = BlockModel(self, parent=self.ui.property_editor)
        self.block_model.model_changed.connect(partial(self.set_changed, True))
        self.ui.property_editor.setModel(self.block_model)

        # Create block Mapping
        self.block_mapping = {
            "Begin/End": {
                'Begin': XBM.BEGIN,
                'End': XBM.END
            },
            "Time": {
                'Init': XBM.TIMEINIT,
                'Wait': XBM.WAIT
            },
            "Branch": {
                'Branch': XBM.BRANCH
            },
            "Subsequence": {
                'Macro': XBM.MACRO
            }
        }
        action_list = get_action_list()
        self.module_to_name = {module: name for name, module in action_list}
        for name, module in action_list:
            family = module.split(".")[-2].capitalize()
            self.block_mapping.setdefault(family,
                                          {})[name] = (XBM.ACTION, module)

        # Block list initialization
        self.ui.block_list.setHeaderLabels(['Block list'])
        self.fill_block_list()
        self.ui.block_list.expandAll()
        self.ui.block_list.resizeColumnToContents(0)
        self.ui.block_list.expandToDepth(0)

        # Sequence initialization
        self.current_sequence = XMLSequence("New sequence")

        # Signals connection
        self.ui.open_button.clicked.connect(self.on_open)
        self.ui.new_button.clicked.connect(self.on_new)
        self.ui.save_button.clicked.connect(self.on_save)
        self.ui.save_as_button.clicked.connect(self.on_save_as)
        self.ui.undo_button.clicked.connect(self.on_undo)
        self.ui.redo_button.clicked.connect(self.on_redo)
        self.ui.about_button.clicked.connect(self.on_about)
        self.ui.zoom_slider.valueChanged.connect(self.on_change_zoom_value)
        self.ui.block_list.itemClicked.connect(self.on_click_family)
        self.ui.tab_widget.tabCloseRequested.connect(self.on_close_tab)
        self.ui.tab_widget.currentChanged.connect(self.update_zoom_slider)
        sub_editor = self.ui.subsequence_editor
        sub_editor.itemDoubleClicked.connect(self.subsequence_double_clicked)
        sub_editor.itemActivated.connect(self.subsequence_activated)
        sub_editor.customContextMenuRequested.connect(self.context_requested)
        sub_editor.currentItemChanged.connect(self.subsequence_changed)
        QtGui.QShortcut(QtGui.QKeySequence.SelectAll, self, self.on_select_all)

        # Update
        self.file_path = None
        self.changed = False
        self.set_changed(False)
        self.update()

        # Logging
        self.log(u'Sequence editor initialized.')

        self.signal_handler = SignalHandler(logging.DEBUG)
        self.signal_handler.signal.connect(self.handle_log_record)
        add_log_handler(self.signal_handler)