Exemplo n.º 1
0
class ToolsDock(QDockWidget):
    toolChanged = pyqtSignal(ToolType)

    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = Ui_ToolsDock()
        self.ui.setupUi(self)

    @pyqtSlot(ToolType)
    def on_toolChanged(self, tool):
        # print("tool changed: {}".format(tool))
        self.blockSignals(True)
        if tool == ToolType.SelectTool:
            self.ui.selectBtn.setChecked(True)
        elif tool == ToolType.LineTool:
            self.ui.lineBtn.setChecked(True)
        elif tool == ToolType.NetTool:
            self.ui.netBtn.setChecked(True)
        self.blockSignals(False)

    @pyqtSlot()
    def on_selectBtn_clicked(self):
        self.toolChanged.emit(ToolType.SelectTool)

    @pyqtSlot()
    def on_lineBtn_clicked(self):
        self.toolChanged.emit(ToolType.LineTool)

    @pyqtSlot()
    def on_netBtn_clicked(self):
        self.toolChanged.emit(ToolType.NetTool)
Exemplo n.º 2
0
class ToolsDock(QDockWidget):
    toolChanged = pyqtSignal(ToolType)

    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = Ui_ToolsDock()
        self.ui.setupUi(self)

    @pyqtSlot(ToolType)
    def on_toolChanged(self, tool):
        # print("tool changed: {}".format(tool))
        self.blockSignals(True)
        if tool == ToolType.SelectTool:
            self.ui.selectBtn.setChecked(True)
        elif tool == ToolType.LineTool:
            self.ui.lineBtn.setChecked(True)
        elif tool == ToolType.NetTool:
            self.ui.netBtn.setChecked(True)
        self.blockSignals(False)

    @pyqtSlot()
    def on_selectBtn_clicked(self):
        self.toolChanged.emit(ToolType.SelectTool)

    @pyqtSlot()
    def on_lineBtn_clicked(self):
        self.toolChanged.emit(ToolType.LineTool)

    @pyqtSlot()
    def on_netBtn_clicked(self):
        self.toolChanged.emit(ToolType.NetTool)
Exemplo n.º 3
0
class ToolsDock(QDockWidget):
    toolChanged = pyqtSignal(int)

    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = Ui_ToolsDock()
        self.ui.setupUi(self)
        self._tools = []
        self._widgets = []
        self._spacer = None

    def _clear(self):
        for w in self._widgets:
            self.ui.verticalLayout.removeWidget(w)
            w.setParent(None)
            sip.delete(w)
        self._widgets.clear()
        if self._spacer:
            self.ui.verticalLayout.removeItem(self._spacer)
            sip.delete(self._spacer)
            self._spacer = None

    def initTools(self, tools):
        def tc(i):
            self.toolChanged.emit(i)
        self._tools = tools
        self._clear()
        first = True
        i = 0
        for tool in self._tools:
            b = QPushButton(self.ui.dockWidgetContents)
            b.setCheckable(True)
            b.setChecked(first)
            b.setAutoExclusive(True)
            b.setText(tool.name())
            b.clicked.connect(partial(tc, i))
            first = False
            self._widgets.append(b)
            self.ui.verticalLayout.addWidget(b)
            i += 1
        spacerItem = QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        self.ui.verticalLayout.addItem(spacerItem)
        self._spacer = spacerItem
        #self._widgets.append(spacerItem)

    @pyqtSlot(int)
    def on_toolChanged(self, idx):
        # print("tool changed: {}".format(tool))
        self.blockSignals(True)
        self._widgets[idx].setChecked(True)
        self.blockSignals(False)
Exemplo n.º 4
0
 def __init__(self, parent=None):
     super().__init__(parent)
     self.ui = Ui_ToolsDock()
     self.ui.setupUi(self)
     self._tools = []
     self._widgets = []
     self._spacer = None
Exemplo n.º 5
0
 def __init__(self, parent=None):
     super().__init__(parent)
     self.ui = Ui_ToolsDock()
     self.ui.setupUi(self)
Exemplo n.º 6
0
 def __init__(self, parent=None):
     super().__init__(parent)
     self.ui = Ui_ToolsDock()
     self.ui.setupUi(self)