コード例 #1
0
    def __init__(self, context):
        Plugin.__init__(self, context)
        self.setObjectName('RqtGraspViewer')

        self._widget = QWidget()

        ui_file = os.path.join(rospkg.RosPack().get_path('rqt_grasp_viewer'), 'ui', 'RqtGraspViewer.ui')
        loadUi(ui_file, self._widget)
        self._widget.setObjectName('RqtGraspViewerUi')
        context.add_widget(self._widget)

        main_layout = QHBoxLayout()
        self._default_labels = ["obj_id", "object", "grasp_id", "grasp", "quality"]
        self._filemodel = QStandardItemModel(0, 5)
        self._filemodel.setHorizontalHeaderLabels(self._default_labels)

        self._table_view = QTableView()
        self._table_view.setModel(self._filemodel)
        self._table_view.resizeColumnsToContents()

        main_layout.addWidget(self._table_view)
        self._widget.scrollarea.setLayout(main_layout)

        self.init_services()
        self.init_subscribers()

        # self._table_view.clicked.connect(self.on_table_view_clicked)
        self._table_view.selectionModel().selectionChanged.connect(self.on_table_view_select)
コード例 #2
0
    def __init__(self, context):
        Plugin.__init__(self, context)
        self.setObjectName('RqtGraspViewer')

        self._widget = QWidget()

        ui_file = os.path.join(rospkg.RosPack().get_path('rqt_grasp_viewer'),
                               'ui', 'RqtGraspViewer.ui')
        loadUi(ui_file, self._widget)
        self._widget.setObjectName('RqtGraspViewerUi')
        context.add_widget(self._widget)

        main_layout = QHBoxLayout()
        self._default_labels = [
            "obj_id", "object", "grasp_id", "grasp", "quality"
        ]
        self._filemodel = QStandardItemModel(0, 5)
        self._filemodel.setHorizontalHeaderLabels(self._default_labels)

        self._table_view = QTableView()
        self._table_view.setModel(self._filemodel)
        self._table_view.resizeColumnsToContents()

        main_layout.addWidget(self._table_view)
        self._widget.scrollarea.setLayout(main_layout)

        self.init_services()
        self.init_subscribers()

        # self._table_view.clicked.connect(self.on_table_view_clicked)
        self._table_view.selectionModel().selectionChanged.connect(
            self.on_table_view_select)
コード例 #3
0
 def _createEntries(self):
     entryWidget = QWidget(self)
     entryLayout = QHBoxLayout(entryWidget)
     inputWidgets = (self._createParamBox(), self._createAutoRange(),
                     self._createLower(), self._createUpper(),
                     self._createBins(), self._createXScale(),
                     self._createYWeight())
     self._labels = dict()
     # assumes same ordering of entryWidgets above and Histogram.displayData
     for col, inputWidget in zip(Histogram.displayData, inputWidgets):
         fieldWidget = QWidget(self)  # combines label + input
         fieldLayout = QVBoxLayout(fieldWidget)
         fieldLayout.setContentsMargins(QMargins())
         # create label, text is set in _selectParam()
         self._labels[col] = QLabel(self)
         self._labels[col].setAlignment(Qt.AlignHCenter)
         # stack label + input
         fieldLayout.addWidget(self._labels[col])
         fieldLayout.addWidget(inputWidget)
         fieldWidget.setLayout(fieldLayout)
         # add field to row of inputs
         entryLayout.addWidget(fieldWidget)
     entryWidget.setLayout(entryLayout)
     self.pbox.setCurrentIndex(0)
     self.lentry.selectAll()  # select the first input by default
     return entryWidget
コード例 #4
0
 def createWidget(self, parent=None):
     hbox = QHBoxLayout();
     self.waitYesNoCheckbox = QCheckBox('Await speech done');
     hbox.addWidget(self.waitYesNoCheckbox);
     hbox.addWidget(QLabel('Text'));
     self.speechTextField = QPlainTextEdit();
     self.speechTextField.setMaximumWidth(SpeechActionEditor.SPEECH_EDIT_FLD_WIDTH);
     hbox.addWidget(self.speechTextField);
     self.setLayout(hbox);
     self.setMaximumHeight(SpeechActionEditor.SPEECH_EDIT_FLD_HEIGHT + 10);
     self.setMaximumWidth(SpeechActionEditor.SPEECH_EDIT_FLD_WIDTH + self.waitYesNoCheckbox.width());
     return self
コード例 #5
0
 def _createButtons(self):
     btnWidget = QWidget(self)
     btnLayout = QHBoxLayout(btnWidget)
     okBtn = QPushButton("add", self)
     okBtn.clicked.connect(self.accept)
     cancelBtn = QPushButton("cancel", self)
     cancelBtn.clicked.connect(self.reject)
     btnLayout.addWidget(okBtn)
     btnLayout.addWidget(cancelBtn)
     btnWidget.setLayout(btnLayout)
     return btnWidget
コード例 #6
0
ファイル: mainwindow.py プロジェクト: tangzheng1104/test
 def _setupStartButton(self):
     """Set up "Start/Stop" - button."""
     self.startStopBtn = QPushButton()
     self.startStopBtn.setCheckable(True)
     self.startStopBtn.clicked[bool].connect(self.onStartStopClick)
     btnLayout = QHBoxLayout()
     btnLayout.setContentsMargins(0, 0, 0, 0)
     self.startStopBtn.setSizePolicy(QSizePolicy.Maximum,
                                     QSizePolicy.Maximum)
     btnLayout.addWidget(self.startStopBtn)
     btnWidget = QWidget(self)
     btnWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
     btnWidget.setLayout(btnLayout)
     return btnWidget
コード例 #7
0
    def makeSetting(self, param, activeBtns=False):
        """Creates an input widget for the provided Parameter and configures
        it appropriately.
        """
        if param is None:
            return None
        widget = QWidget(self)
        layout = QHBoxLayout(widget)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addStretch()

        try:
            suffix = param.suffix()
        except AttributeError:
            suffix = None

        if suffix is None:
            layout.addWidget(self._makeLabel(param.displayName()))
        else:
            layout.addWidget(
                self._makeLabel(u"{} ({})".format(param.displayName(),
                                                  suffix)))

        widget.setLayout(layout)
        if isString(param.__doc__):
            # word wrapping by rich text: https://stackoverflow.com/a/4796057
            txt = "<span>{0}</span>".format(param.__doc__)
            # add description as tooltip if available for parameter
            widget.setToolTip(txt)

        # create scalar value input widget with min/max limits
        minmaxValue, widgets = None, []
        if isinstance(param, ParameterNumerical):
            minmaxValue = param.min(), param.max()
        if isinstance(param, ParameterFloat):
            minmaxValue = param.displayValueRange()
        decimals = None
        if hasattr(param, "decimals"):
            decimals = param.decimals()
        w = self._makeEntry(param.name(),
                            param.dtype,
                            param.displayValue(),
                            decimals=decimals,
                            minmax=minmaxValue,
                            parent=widget)
        try:  # set special value text for lower bound, simple solution
            special = param.displayValues(w.minimum())
            w.setSpecialValueText(special)
        except:
            pass
        w.setFixedWidth(FIXEDWIDTH)
        widgets.insert(old_div(len(widgets), 2), w)

        # Special widget settings for active fitting parameters:
        activeBtns = activeBtns and isinstance(param, FitParameterBase)
        if activeBtns:
            # create input boxes for user specified active fitting range
            # within default upper/lower from class definition
            # minmaxValue = type(param).min(), type(param).max()
            activeRange = {
                "min": param.displayActiveRange()[0],
                "max": param.displayActiveRange()[1]
            }
            for bound in "min", "max":
                w = self._makeEntry(param.name() + bound,
                                    param.dtype,
                                    activeRange[bound],
                                    decimals=decimals,
                                    minmax=minmaxValue,
                                    parent=widget)
                w.setPrefix(bound + ": ")
                w.setFixedWidth(FIXEDWIDTH)
                widgets.append(w)
            # create *active* buttons for FitParameters only
            w = self._makeEntry(param.name() + "active",
                                bool,
                                param.isActive(),
                                widgetType=QPushButton,
                                parent=widget)
            w.setText("Active")
            w.setFixedWidth(FIXEDWIDTH * .5)
            widgets.append(w)

        # add input widgets to the layout
        for w in widgets:
            layout.addWidget(w)
            # store the parameter name
            w.parameterName = param.name()
        # configure UI accordingly (hide/show widgets)
        # no backend update, ui was just built, data is still in sync
        self.updateParam(param, emitBackendUpdated=False)
        return widget