Пример #1
0
 def __init__(self, parent=None):
     QWidget.__init__(self, parent)
     self.setObjectName("MainBox")
     self.__on_intern_change = False
     boxLayout = QFormLayout()
     boxLayout.setVerticalSpacing(0)
     self.setLayout(boxLayout)
 def __init__(self, parent=None):
     QWidget.__init__(self, parent)
     self.setObjectName("MainBox")
     self.__on_intern_change = False
     boxLayout = QFormLayout()
     boxLayout.setVerticalSpacing(0)
     self.setLayout(boxLayout)
Пример #3
0
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)
        self.setWindowTitle('Select Binary')
        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.setObjectName("verticalLayout")

        self.content = QWidget()
        self.contentLayout = QFormLayout(self.content)
        self.contentLayout.setVerticalSpacing(0)
        self.verticalLayout.addWidget(self.content)

        self.packages = None

        package_label = QLabel("Package:", self.content)
        self.package_field = QComboBox(self.content)
        self.package_field.setInsertPolicy(QComboBox.InsertAlphabetically)
        self.package_field.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
        self.package_field.setEditable(True)
        self.contentLayout.addRow(package_label, self.package_field)
        binary_label = QLabel("Binary:", self.content)
        self.binary_field = QComboBox(self.content)
#    self.binary_field.setSizeAdjustPolicy(QComboBox.AdjustToContents)
        self.binary_field.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
        self.binary_field.setEditable(True)
        self.contentLayout.addRow(binary_label, self.binary_field)

        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setObjectName("buttonBox")
        self.verticalLayout.addWidget(self.buttonBox)

        self.package_field.setFocus(Qt.TabFocusReason)
        self.package = ''
        self.binary = ''

        if self.packages is None:
            self.package_field.addItems(['packages searching...'])
            self.package_field.setCurrentIndex(0)
            self._fill_packages_thread = PackagesThread()
            self._fill_packages_thread.packages.connect(self._fill_packages)
            self._fill_packages_thread.start()

        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
        QMetaObject.connectSlotsByName(self)
        self.package_field.activated[str].connect(self.on_package_selected)
        if hasattr(self.package_field, "textChanged"):  # qt compatibility
            self.package_field.textChanged.connect(self.on_package_selected)
            self.binary_field.textChanged.connect(self.on_binary_selected)
        else:
            self.package_field.editTextChanged.connect(self.on_package_selected)
            self.binary_field.editTextChanged.connect(self.on_binary_selected)
Пример #4
0
    def _unload_jtc(self):
        # Stop updating the joint positions
        try:
            self.jointStateChanged.disconnect(self._on_joint_state_change)
        except:
            pass

        # Reset ROS interfaces
        self._unregister_state_sub()
        self._unregister_cmd_pub()

        # Clear joint widgets
        # NOTE: Implementation is a workaround for:
        # https://bugreports.qt-project.org/browse/QTBUG-15990 :(
        layout = self._widget.joint_group.layout()
        if layout is not None:
            while layout.count():
                layout.takeAt(0).widget().deleteLater()
            # Delete existing layout by reparenting to temporary
            QWidget().setLayout(layout)
        self._widget.joint_group.setLayout(QFormLayout())

        # Reset joint data
        self._joint_names = []
        self._joint_pos = {}

        # Enforce monitor mode (sending commands disabled)
        self._widget.enable_button.setChecked(False)
	def __init__(self):
		super(DataDialog, self).__init__()
		rp = rospkg.RosPack()
		uiFile = os.path.join(rp.get_path('my_topic_viewer'), 'resource', 'TopicViewer.ui')
		loadUi(uiFile, self)

		self._displayedData = None
		self._displayedName = None
		self._groupBox = QGroupBox()
		self._layout = QFormLayout()
		self._mainLayout = QVBoxLayout();
		self._mainLayout.addWidget(self._groupBox)
class DataDialog(QWidget):

	TOPIC_NAME = 'chatter'
	MSG_CLASS = Float32

	def __init__(self):
		super(DataDialog, self).__init__()
		rp = rospkg.RosPack()
		uiFile = os.path.join(rp.get_path('my_topic_viewer'), 'resource', 'TopicViewer.ui')
		loadUi(uiFile, self)

		self._displayedData = None
		self._displayedName = None
		self._groupBox = QGroupBox()
		self._layout = QFormLayout()
		self._mainLayout = QVBoxLayout();
		self._mainLayout.addWidget(self._groupBox)

#		self.setLayout(self._mainLayout);

	def setDisplayedData(self, data, name):
		if isinstance(data, dict):
			self.displayData(data)
		else:
			dictData = {}
			if name is None:
				dictData['unknown'] = data
			elif isinstance(data, list):
				dictData = dict(zip(name, data))
			else:
				dictData[name] = data
			self.displayData(dictData)

	def displayData(self, dictData):
		for key in dictData.keys():
			self._layout.addRow(QLabel(key+': '), QLineEdit(str(dictData[key])))
    def __init__(self, updater, config):
        """
        :param config: defined in dynamic_reconfigure.client.Client
        :type config: Dictionary?
        """

        super(GroupWidget, self).__init__()
        self.state = config['state']
        self.name = config['name']

        self.tab_bar = None  # Every group can have one tab bar
        self.tab_bar_shown = False

        #self.grid = QGridLayout()
        self.grid = QFormLayout()

        self.updater = updater

        self.editor_widgets = []
        self.add_widgets(config)

        # Labels should not stretch
        #self.grid.setColumnStretch(1, 1)
        self.setLayout(self.grid)
Пример #8
0
    def __init__(self, updater, config, nodename):
        '''
        :param config:
        :type config: Dictionary? defined in dynamic_reconfigure.client.Client
        :type nodename: str
        '''

        #TODO figure out what data type 'config' is. It is afterall returned
        #     from dynamic_reconfigure.client.get_parameter_descriptions()
        # ros.org/doc/api/dynamic_reconfigure/html/dynamic_reconfigure.client-pysrc.html#Client

        super(GroupWidget, self).__init__()
        self.state = config['state']
        self.name = config['name']
        self._toplevel_treenode_name = nodename

        # TODO: .ui file needs to be back into usage in later phase.
        #        ui_file = os.path.join(rp.get_path('rqt_reconfigure'),
        #                               'resource', 'singlenode_parameditor.ui')
        #        loadUi(ui_file, self)

        verticalLayout = QVBoxLayout(self)
        verticalLayout.setContentsMargins(QMargins(0, 0, 0, 0))

        _widget_nodeheader = QWidget()
        _h_layout_nodeheader = QHBoxLayout(_widget_nodeheader)
        _h_layout_nodeheader.setContentsMargins(QMargins(0, 0, 0, 0))

        self.nodename_qlabel = QLabel(self)
        font = QFont('Trebuchet MS, Bold')
        font.setUnderline(True)
        font.setBold(True)

        # Button to close a node.
        _icon_disable_node = QIcon.fromTheme('window-close')
        _bt_disable_node = QPushButton(_icon_disable_node, '', self)
        _bt_disable_node.setToolTip('Hide this node')
        _bt_disable_node_size = QSize(36, 24)
        _bt_disable_node.setFixedSize(_bt_disable_node_size)
        _bt_disable_node.pressed.connect(self._node_disable_bt_clicked)

        _h_layout_nodeheader.addWidget(self.nodename_qlabel)
        _h_layout_nodeheader.addWidget(_bt_disable_node)

        self.nodename_qlabel.setAlignment(Qt.AlignCenter)
        font.setPointSize(10)
        self.nodename_qlabel.setFont(font)
        grid_widget = QWidget(self)
        self.grid = QFormLayout(grid_widget)
        verticalLayout.addWidget(_widget_nodeheader)
        verticalLayout.addWidget(grid_widget, 1)
        # Again, these UI operation above needs to happen in .ui file.

        self.tab_bar = None  # Every group can have one tab bar
        self.tab_bar_shown = False

        self.updater = updater

        self.editor_widgets = []
        self._param_names = []

        self._create_node_widgets(config)

        rospy.logdebug('Groups node name={}'.format(nodename))
        self.nodename_qlabel.setText(nodename)
Пример #9
0
    def __init__(self, masteruri, parent=None):
        QDialog.__init__(self, parent)
        self.setWindowTitle('Select Binary')
        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.setObjectName("verticalLayout")

        self.content = QWidget()
        self.contentLayout = QFormLayout(self.content)
        self.contentLayout.setVerticalSpacing(0)
        self.verticalLayout.addWidget(self.content)

        self.packages = None
        self.masteruri = "ROS_MASTER_URI" if masteruri is None else masteruri
        package_label = QLabel("Package:", self.content)
        self.package_field = QComboBox(self.content)
        self.package_field.setInsertPolicy(QComboBox.InsertAlphabetically)
        self.package_field.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
        self.package_field.setEditable(True)
        self.contentLayout.addRow(package_label, self.package_field)
        binary_label = QLabel("Binary:", self.content)
        self.binary_field = QComboBox(self.content)
        self.binary_field.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
        self.binary_field.setEditable(True)
        self.contentLayout.addRow(binary_label, self.binary_field)

        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Ok
                                          | QDialogButtonBox.Cancel)
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setObjectName("buttonBox")
        self.verticalLayout.addWidget(self.buttonBox)

        self.package_field.setFocus(Qt.TabFocusReason)
        self.package = ''
        self.binary = ''
        self._request_bin_thread = None

        if self.packages is None:
            self.package_field.addItems(['packages searching...'])
            self.package_field.setCurrentIndex(0)
        # fill the input fields
        self.packages = {
            name: path
            for path, name in nm.nmd().file.get_packages(
                nmdurl.nmduri(masteruri)).items()
        }
        packages = self.packages.keys()
        packages.sort()
        self.package_field.clear()
        self.package_field.clearEditText()
        self.package_field.addItems(packages)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
        QMetaObject.connectSlotsByName(self)
        self.package_field.activated[str].connect(self.on_package_selected)
        if hasattr(self.package_field, "textChanged"):  # qt compatibility
            self.package_field.textChanged.connect(self.on_package_selected)
            self.binary_field.textChanged.connect(self.on_binary_selected)
        else:
            self.package_field.editTextChanged.connect(
                self.on_package_selected)
            self.binary_field.editTextChanged.connect(self.on_binary_selected)
Пример #10
0
class PackageDialog(QDialog):
    def __init__(self, masteruri, parent=None):
        QDialog.__init__(self, parent)
        self.setWindowTitle('Select Binary')
        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.setObjectName("verticalLayout")

        self.content = QWidget()
        self.contentLayout = QFormLayout(self.content)
        self.contentLayout.setVerticalSpacing(0)
        self.verticalLayout.addWidget(self.content)

        self.packages = None
        self.masteruri = "ROS_MASTER_URI" if masteruri is None else masteruri
        package_label = QLabel("Package:", self.content)
        self.package_field = QComboBox(self.content)
        self.package_field.setInsertPolicy(QComboBox.InsertAlphabetically)
        self.package_field.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
        self.package_field.setEditable(True)
        self.contentLayout.addRow(package_label, self.package_field)
        binary_label = QLabel("Binary:", self.content)
        self.binary_field = QComboBox(self.content)
        self.binary_field.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
        self.binary_field.setEditable(True)
        self.contentLayout.addRow(binary_label, self.binary_field)

        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Ok
                                          | QDialogButtonBox.Cancel)
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setObjectName("buttonBox")
        self.verticalLayout.addWidget(self.buttonBox)

        self.package_field.setFocus(Qt.TabFocusReason)
        self.package = ''
        self.binary = ''
        self._request_bin_thread = None

        if self.packages is None:
            self.package_field.addItems(['packages searching...'])
            self.package_field.setCurrentIndex(0)
        # fill the input fields
        self.packages = {
            name: path
            for path, name in nm.nmd().file.get_packages(
                nmdurl.nmduri(masteruri)).items()
        }
        packages = self.packages.keys()
        packages.sort()
        self.package_field.clear()
        self.package_field.clearEditText()
        self.package_field.addItems(packages)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
        QMetaObject.connectSlotsByName(self)
        self.package_field.activated[str].connect(self.on_package_selected)
        if hasattr(self.package_field, "textChanged"):  # qt compatibility
            self.package_field.textChanged.connect(self.on_package_selected)
            self.binary_field.textChanged.connect(self.on_binary_selected)
        else:
            self.package_field.editTextChanged.connect(
                self.on_package_selected)
            self.binary_field.editTextChanged.connect(self.on_binary_selected)

    def on_package_selected(self, package):
        getnew = False
        if self._request_bin_thread is None:
            getnew = True
        else:
            if self._request_bin_thread.pkgname != package:
                self._request_bin_thread.cancel()
                getnew = True
        if self._request_bin_thread is not None and self._request_bin_thread.pkgname == package:
            # use already got data
            self._request_bin_thread.reemit()
        elif getnew:
            self.binary_field.clear()
            if self.packages and package in self.packages:
                self.binary_field.setEnabled(True)
                self._request_bin_thread = RequestBinariesThread(
                    package, nmdurl.nmduri(self.masteruri))
                self._request_bin_thread.binaries_signal.connect(
                    self._on_new_binaries)
                self._request_bin_thread.start()

    def _on_new_binaries(self, pkgname, binaries):
        # update the binaries
        binaries = [os.path.basename(item) for item in binaries.keys()]
        binaries = list(set(binaries))
        binaries.sort()
        self.binary_field.addItems(binaries)
        self.package = pkgname
        self.binary = self.binary_field.currentText()

    def on_binary_selected(self, binary):
        self.binary = binary
Пример #11
0
class PackageDialog(QDialog):

    def __init__(self, parent=None):
        QDialog.__init__(self, parent)
        self.setWindowTitle('Select Binary')
        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.setObjectName("verticalLayout")

        self.content = QWidget()
        self.contentLayout = QFormLayout(self.content)
        self.contentLayout.setVerticalSpacing(0)
        self.verticalLayout.addWidget(self.content)

        self.packages = None

        package_label = QLabel("Package:", self.content)
        self.package_field = QComboBox(self.content)
        self.package_field.setInsertPolicy(QComboBox.InsertAlphabetically)
        self.package_field.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
        self.package_field.setEditable(True)
        self.contentLayout.addRow(package_label, self.package_field)
        binary_label = QLabel("Binary:", self.content)
        self.binary_field = QComboBox(self.content)
#    self.binary_field.setSizeAdjustPolicy(QComboBox.AdjustToContents)
        self.binary_field.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
        self.binary_field.setEditable(True)
        self.contentLayout.addRow(binary_label, self.binary_field)

        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setObjectName("buttonBox")
        self.verticalLayout.addWidget(self.buttonBox)

        self.package_field.setFocus(Qt.TabFocusReason)
        self.package = ''
        self.binary = ''

        if self.packages is None:
            self.package_field.addItems(['packages searching...'])
            self.package_field.setCurrentIndex(0)
            self._fill_packages_thread = PackagesThread()
            self._fill_packages_thread.packages.connect(self._fill_packages)
            self._fill_packages_thread.start()

        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
        QMetaObject.connectSlotsByName(self)
        self.package_field.activated[str].connect(self.on_package_selected)
        if hasattr(self.package_field, "textChanged"):  # qt compatibility
            self.package_field.textChanged.connect(self.on_package_selected)
            self.binary_field.textChanged.connect(self.on_binary_selected)
        else:
            self.package_field.editTextChanged.connect(self.on_package_selected)
            self.binary_field.editTextChanged.connect(self.on_binary_selected)

    def _fill_packages(self, packages):
        # fill the input fields
        self.packages = packages
        packages = packages.keys()
        packages.sort()
        self.package_field.clear()
        self.package_field.clearEditText()
        self.package_field.addItems(packages)

    def _getBinaries(self, path):
        result = {}
        if os.path.isdir(path):
            fileList = os.listdir(path)
            for f in fileList:
                if f and f[0] != '.' and f not in ['build'] and not f.endswith('.cfg') and not f.endswith('.so'):
                    ret = self._getBinaries(os.path.join(path, f))
                    result = dict(ret.items() + result.items())
        elif os.path.isfile(path) and os.access(path, os.X_OK):
            # create a selection for binaries
            return {os.path.basename(path): path}
        return result

    def on_package_selected(self, package):
        self.binary_field.clear()
        if self.packages and package in self.packages:
            self.binary_field.setEnabled(True)
            path = self.packages[package]
            binaries = self._getBinaries(path).keys()
            try:
                # find binaries in catkin workspace
                from catkin.find_in_workspaces import find_in_workspaces as catkin_find
                search_paths = catkin_find(search_dirs=['libexec', 'share'], project=package, first_matching_workspace_only=True)
                for p in search_paths:
                    binaries += self._getBinaries(p).keys()
            except:
                pass
            binaries = list(set(binaries))
            binaries.sort()
            self.binary_field.addItems(binaries)
            self.package = package
            self.binary = self.binary_field.currentText()

    def on_binary_selected(self, binary):
        self.binary = binary