def __init__(self, host, masteruri=None, parent=None): PackageDialog.__init__(self, parent) self.host = host self.setWindowTitle('Run') ns_name_label = QtGui.QLabel("NS/Name:", self.content) self.ns_field = QtGui.QComboBox(self.content) self.ns_field.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)) self.ns_field.setEditable(True) ns_history = nm.history().cachedParamValues('run_dialog/NS') ns_history.insert(0, '/') self.ns_field.addItems(ns_history) self.name_field = QtGui.QLineEdit(self.content) self.name_field.setEnabled(False) horizontalLayout = QtGui.QHBoxLayout() horizontalLayout.addWidget(self.ns_field) horizontalLayout.addWidget(self.name_field) self.contentLayout.addRow(ns_name_label, horizontalLayout) args_label = QtGui.QLabel("Args:", self.content) self.args_field = QtGui.QComboBox(self.content) self.args_field.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) self.args_field.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)) self.args_field.setEditable(True) self.contentLayout.addRow(args_label, self.args_field) args_history = nm.history().cachedParamValues('run_dialog/Args') args_history.insert(0, '') self.args_field.addItems(args_history) host_label = QtGui.QLabel("Host:", self.content) self.host_field = QtGui.QComboBox(self.content) # self.host_field.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) self.host_field.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)) self.host_field.setEditable(True) host_label.setBuddy(self.host_field) self.contentLayout.addRow(host_label, self.host_field) self.host_history = host_history = nm.history().cachedParamValues('/Host') if self.host in host_history: host_history.remove(self.host) host_history.insert(0, self.host) self.host_field.addItems(host_history) master_label = QtGui.QLabel("ROS Master URI:", self.content) self.master_field = QtGui.QComboBox(self.content) self.master_field.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)) self.master_field.setEditable(True) master_label.setBuddy(self.host_field) self.contentLayout.addRow(master_label, self.master_field) self.master_history = master_history = nm.history().cachedParamValues('/Optional Parameter/ROS Master URI') self.masteruri = "ROS_MASTER_URI" if masteruri is None else masteruri if self.masteruri in master_history: master_history.remove(self.masteruri) master_history.insert(0, self.masteruri) self.master_field.addItems(master_history) # self.package_field.setFocus(QtCore.Qt.TabFocusReason) self.package_field.textChanged.connect(self.on_package_selected) self.binary_field.activated[str].connect(self.on_binary_selected)
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setWindowTitle('Select Binary') self.verticalLayout = QtGui.QVBoxLayout(self) self.verticalLayout.setObjectName("verticalLayout") self.content = QtGui.QWidget() self.contentLayout = QtGui.QFormLayout(self.content) self.contentLayout.setVerticalSpacing(0) self.verticalLayout.addWidget(self.content) self.packages = None package_label = QtGui.QLabel("Package:", self.content) self.package_field = QtGui.QComboBox(self.content) self.package_field.setInsertPolicy( QtGui.QComboBox.InsertAlphabetically) self.package_field.setSizePolicy( QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)) self.package_field.setEditable(True) self.contentLayout.addRow(package_label, self.package_field) binary_label = QtGui.QLabel("Binary:", self.content) self.binary_field = QtGui.QComboBox(self.content) # self.binary_field.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) self.binary_field.setSizePolicy( QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)) self.binary_field.setEditable(True) self.contentLayout.addRow(binary_label, self.binary_field) self.buttonBox = QtGui.QDialogButtonBox(self) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setObjectName("buttonBox") self.verticalLayout.addWidget(self.buttonBox) self.package_field.setFocus(QtCore.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() QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), self.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), self.reject) QtCore.QMetaObject.connectSlotsByName(self) self.package_field.activated[str].connect(self.on_package_selected) self.package_field.textChanged.connect(self.on_package_selected)
def createEditor(self, parent, option, index): ''' Creates a editor in the TreeView depending on type of the settings data. ''' item = self._itemFromIndex(index) if item.edit_type() == SettingsValueItem.EDIT_TYPE_AUTODETECT: if isinstance(item.value(), bool): box = QtGui.QCheckBox(parent) box.setFocusPolicy(QtCore.Qt.StrongFocus) box.setAutoFillBackground(True) box.stateChanged.connect(self.edit_finished) return box elif isinstance(item.value(), int): box = QtGui.QSpinBox(parent) box.setValue(item.value()) if not item.value_min() is None: box.setMinimum(item.value_min()) if not item.value_max() is None: box.setMaximum(item.value_max()) return box elif item.edit_type() == SettingsValueItem.EDIT_TYPE_FOLDER: editor = PathEditor(item.value(), parent) editor.editing_finished_signal.connect(self.edit_finished) return editor elif item.edit_type() == SettingsValueItem.EDIT_TYPE_LIST: box = QtGui.QComboBox(parent) box.addItems(item.value_list()) index = box.findText(item.value()) if index >= 0: box.setCurrentIndex(index) box.setEditable(False) return box return QtGui.QStyledItemDelegate.createEditor(self, parent, option, index)
def __init__(self, parent=None): super(LineEditDialog, self).__init__() self.value = None vbox = QtGui.QVBoxLayout(self) # combo box model = QtGui.QStandardItemModel(self) for elm in rospy.get_param_names(): model.setItem(model.rowCount(), 0, QtGui.QStandardItem(elm)) self.combo_box = QtGui.QComboBox(self) self.line_edit = QtGui.QLineEdit() self.combo_box.setLineEdit(self.line_edit) self.combo_box.setCompleter(QtGui.QCompleter()) self.combo_box.setModel(model) self.combo_box.completer().setModel(model) self.combo_box.lineEdit().setText('') vbox.addWidget(self.combo_box) # button button = QPushButton() button.setText("Done") button.clicked.connect(self.buttonCallback) vbox.addWidget(button) self.setLayout(vbox)
def setupUi(self, Dialog): Dialog.setObjectName(_fromUtf8("Dialog")) Dialog.resize(328, 449) self.verticalLayout = QtGui.QVBoxLayout(Dialog) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setContentsMargins(-1, 0, -1, -1) self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.label = QtGui.QLabel(Dialog) self.label.setLineWidth(0) self.label.setObjectName(_fromUtf8("label")) self.horizontalLayout.addWidget(self.label) self.cb_guitype = QtGui.QComboBox(Dialog) self.cb_guitype.setObjectName(_fromUtf8("cb_guitype")) self.horizontalLayout.addWidget(self.cb_guitype) self.verticalLayout.addLayout(self.horizontalLayout) self.treeView = QtGui.QTreeView(Dialog) self.treeView.setObjectName(_fromUtf8("treeView")) self.verticalLayout.addWidget(self.treeView) self.retranslateUi(Dialog) QtCore.QMetaObject.connectSlotsByName(Dialog)
def setup_ui(self): horizontal_layout = QtGui.QHBoxLayout() reload_button = QtGui.QPushButton(parent=self) reload_button.setMaximumWidth(30) reload_button.setIcon(self.style().standardIcon( QtGui.QStyle.SP_BrowserReload)) reload_button.clicked.connect(self.update_combo_items) topic_label = QtGui.QLabel('topic(+data member) name') clear_button = QtGui.QPushButton('all clear') clear_button.setMaximumWidth(200) clear_button.clicked.connect(self.clear_sliders) self._combo = QtGui.QComboBox() self._combo.setEditable(True) self.update_combo_items() self._combo.activated.connect(self.add_slider_from_combo) horizontal_layout.addWidget(reload_button) horizontal_layout.addWidget(topic_label) horizontal_layout.addWidget(self._combo) horizontal_layout.addWidget(clear_button) self._main_vertical_layout = QtGui.QVBoxLayout() self._main_vertical_layout.addLayout(horizontal_layout) self._main_vertical_layout.setAlignment(horizontal_layout, QtCore.Qt.AlignTop) self.setLayout(self._main_vertical_layout)
def __init__(self, topic, msg_type, show_only_rate=False, masteruri=None, use_ssh=False, parent=None): ''' Creates an input dialog. @param topic: the name of the topic @type topic: C{str} @param msg_type: the type of the topic @type msg_type: C{str} @raise Exception: if no topic class was found for the given type ''' QtGui.QDialog.__init__(self, parent=parent) self._masteruri = masteruri masteruri_str = '' if masteruri is None else '[%s]' % masteruri self.setObjectName(' - '.join(['EchoDialog', topic, masteruri_str])) self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) self.setWindowFlags(QtCore.Qt.Window) self.setWindowTitle('%s %s %s' % ('Echo --- ' if not show_only_rate else 'Hz --- ', topic, masteruri_str)) self.resize(728, 512) self.verticalLayout = QtGui.QVBoxLayout(self) self.verticalLayout.setObjectName("verticalLayout") self.verticalLayout.setContentsMargins(1, 1, 1, 1) self.mIcon = QtGui.QIcon(":/icons/crystal_clear_prop_run_echo.png") self.setWindowIcon(self.mIcon) self.topic = topic self.show_only_rate = show_only_rate self.lock = threading.RLock() self.last_printed_count = 0 self.msg_t0 = -1. self.msg_tn = 0 self.times = [] self.message_count = 0 self._rate_message = '' self._scrapped_msgs = 0 self._scrapped_msgs_sl = 0 self._last_received_ts = 0 self.receiving_hz = self.MESSAGE_HZ_LIMIT self.line_limit = self.MESSAGE_LINE_LIMIT self.field_filter_fn = None options = QtGui.QWidget(self) if not show_only_rate: hLayout = QtGui.QHBoxLayout(options) hLayout.setContentsMargins(1, 1, 1, 1) self.no_str_checkbox = no_str_checkbox = QtGui.QCheckBox( 'Hide strings') no_str_checkbox.toggled.connect(self.on_no_str_checkbox_toggled) hLayout.addWidget(no_str_checkbox) self.no_arr_checkbox = no_arr_checkbox = QtGui.QCheckBox( 'Hide arrays') no_arr_checkbox.toggled.connect(self.on_no_arr_checkbox_toggled) hLayout.addWidget(no_arr_checkbox) self.combobox_reduce_ch = QtGui.QComboBox(self) self.combobox_reduce_ch.addItems( [str(self.MESSAGE_LINE_LIMIT), '0', '80', '256', '1024']) self.combobox_reduce_ch.activated[str].connect( self.combobox_reduce_ch_activated) self.combobox_reduce_ch.setEditable(True) self.combobox_reduce_ch.setToolTip( "Set maximum line width. 0 disables the limit.") hLayout.addWidget(self.combobox_reduce_ch) # reduce_ch_label = QtGui.QLabel('ch', self) # hLayout.addWidget(reduce_ch_label) # add spacer spacerItem = QtGui.QSpacerItem(515, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) hLayout.addItem(spacerItem) # add combobox for displaying frequency of messages self.combobox_displ_hz = QtGui.QComboBox(self) self.combobox_displ_hz.addItems([ str(self.MESSAGE_HZ_LIMIT), '0', '0.1', '1', '50', '100', '1000' ]) self.combobox_displ_hz.activated[str].connect( self.on_combobox_hz_activated) self.combobox_displ_hz.setEditable(True) hLayout.addWidget(self.combobox_displ_hz) displ_hz_label = QtGui.QLabel('Hz', self) hLayout.addWidget(displ_hz_label) # add combobox for count of displayed messages self.combobox_msgs_count = QtGui.QComboBox(self) self.combobox_msgs_count.addItems( [str(self.MAX_DISPLAY_MSGS), '0', '50', '100']) self.combobox_msgs_count.activated[str].connect( self.on_combobox_count_activated) self.combobox_msgs_count.setEditable(True) self.combobox_msgs_count.setToolTip( "Set maximum displayed message count. 0 disables the limit.") hLayout.addWidget(self.combobox_msgs_count) displ_count_label = QtGui.QLabel('#', self) hLayout.addWidget(displ_count_label) # add topic control button for unsubscribe and subscribe self.topic_control_button = QtGui.QToolButton(self) self.topic_control_button.setText('stop') self.topic_control_button.setIcon( QtGui.QIcon(':/icons/deleket_deviantart_stop.png')) self.topic_control_button.clicked.connect( self.on_topic_control_btn_clicked) hLayout.addWidget(self.topic_control_button) # add clear button clearButton = QtGui.QToolButton(self) clearButton.setText('clear') clearButton.clicked.connect(self.on_clear_btn_clicked) hLayout.addWidget(clearButton) self.verticalLayout.addWidget(options) self.display = QtGui.QTextBrowser(self) self.display.setReadOnly(True) self.verticalLayout.addWidget(self.display) self.display.document().setMaximumBlockCount(500) self.max_displayed_msgs = self.MAX_DISPLAY_MSGS self._blocks_in_msg = None self.display.setOpenLinks(False) self.display.anchorClicked.connect(self._on_display_anchorClicked) self.status_label = QtGui.QLabel('0 messages', self) self.verticalLayout.addWidget(self.status_label) # subscribe to the topic errmsg = '' try: self.__msg_class = message.get_message_class(msg_type) if not self.__msg_class: errmsg = "Cannot load message class for [%s]. Did you build messages?" % msg_type # raise Exception("Cannot load message class for [%s]. Did you build messages?"%msg_type) except Exception as e: self.__msg_class = None errmsg = "Cannot load message class for [%s]. Did you build messagest?\nError: %s" % ( msg_type, e) # raise Exception("Cannot load message class for [%s]. Did you build messagest?\nError: %s"%(msg_type, e)) # variables for Subscriber self.msg_signal.connect(self._append_message) self.sub = None # vairables for SSH connection self.ssh_output_file = None self.ssh_error_file = None self.ssh_input_file = None self.text_signal.connect(self._append_text) self.text_hz_signal.connect(self._append_text_hz) self._current_msg = '' self._current_errmsg = '' self.text_error_signal.connect(self._append_error_text) # decide, which connection to open if use_ssh: self.__msg_class = None self._on_display_anchorClicked(QtCore.QUrl(self._masteruri)) elif self.__msg_class is None: errtxt = '<pre style="color:red; font-family:Fixedsys,Courier,monospace; padding:10px;">\n%s</pre>' % ( errmsg) self.display.setText('<a href="%s">open using SSH</a>' % (masteruri)) self.display.append(errtxt) else: self.sub = rospy.Subscriber(self.topic, self.__msg_class, self._msg_handle) self.print_hz_timer = QtCore.QTimer() self.print_hz_timer.timeout.connect(self._on_calc_hz) self.print_hz_timer.start(1000)
def __init__(self, plugin): super(ControllerManagerWidget, self).__init__() self._plugin = plugin self.setWindowTitle('Controller Manager') # create layouts vlayout_outer = QtGui.QVBoxLayout(self) vlayout_outer.setObjectName('vert_layout_outer') hlayout_top = QtGui.QHBoxLayout(self) hlayout_top.setObjectName('hori_layout_top') vlayout_outer.addLayout(hlayout_top) # create top bar # controller manager namespace combo box & label cm_ns_label = QtGui.QLabel(self) cm_ns_label.setObjectName('cm_ns_label') cm_ns_label.setText('CM Namespace:') fixed_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed) cm_ns_label.setSizePolicy(fixed_policy) hlayout_top.addWidget(cm_ns_label) cm_namespace_combo = QtGui.QComboBox(self) cm_namespace_combo.setObjectName('cm_namespace_combo') hlayout_top.addWidget(cm_namespace_combo) self.cm_namespace_combo = cm_namespace_combo # load controller combo box & label load_ctrl_label = QtGui.QLabel(self) load_ctrl_label.setObjectName('load_ctrl_label') load_ctrl_label.setText('Load Controller:') fixed_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed) load_ctrl_label.setSizePolicy(fixed_policy) hlayout_top.addWidget(load_ctrl_label) load_ctrl_combo = QtGui.QComboBox(self) load_ctrl_combo.setObjectName('load_ctrl_combo') load_ctrl_size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) load_ctrl_combo.setSizePolicy(load_ctrl_size_policy) hlayout_top.addWidget(load_ctrl_combo) self.load_ctrl_combo = load_ctrl_combo # load control button load_ctrl_button = QtGui.QPushButton(self) load_ctrl_button.setObjectName('load_ctrl_button') button_size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) button_size_policy.setHorizontalStretch(0) button_size_policy.setVerticalStretch(0) button_size_policy.setHeightForWidth( load_ctrl_button.sizePolicy().hasHeightForWidth()) load_ctrl_button.setSizePolicy(button_size_policy) load_ctrl_button.setBaseSize(QtCore.QSize(30, 30)) load_ctrl_button.setIcon(QIcon.fromTheme('list-add')) load_ctrl_button.setIconSize(QtCore.QSize(20, 20)) load_ctrl_button.clicked.connect(self.load_cur_ctrl) hlayout_top.addWidget(load_ctrl_button) # start control button start_ctrl_button = QtGui.QPushButton(self) start_ctrl_button.setObjectName('start_ctrl_button') button_size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) button_size_policy.setHorizontalStretch(0) button_size_policy.setVerticalStretch(0) button_size_policy.setHeightForWidth( start_ctrl_button.sizePolicy().hasHeightForWidth()) start_ctrl_button.setSizePolicy(button_size_policy) start_ctrl_button.setBaseSize(QtCore.QSize(30, 30)) start_ctrl_button.setIcon(QIcon.fromTheme('media-playback-start')) start_ctrl_button.setIconSize(QtCore.QSize(20, 20)) start_ctrl_button.clicked.connect(self.start_cur_ctrl) hlayout_top.addWidget(start_ctrl_button) # create tree/list widget ctrl_list_tree_widget = QtGui.QTreeWidget(self) ctrl_list_tree_widget.setObjectName('ctrl_list_tree_widget') self.ctrl_list_tree_widget = ctrl_list_tree_widget ctrl_list_tree_widget.setColumnCount(len(self._column_names)) ctrl_list_tree_widget.setHeaderLabels(self._column_names_pretty) ctrl_list_tree_widget.sortByColumn(0, Qt.AscendingOrder) ctrl_list_tree_widget.setContextMenuPolicy(Qt.CustomContextMenu) ctrl_list_tree_widget.customContextMenuRequested.connect( self.on_ctrl_list_tree_widget_customContextMenuRequested) vlayout_outer.addWidget(ctrl_list_tree_widget) header = self.ctrl_list_tree_widget.header() header.setResizeMode(QHeaderView.ResizeToContents) header.customContextMenuRequested.connect( self.handle_header_view_customContextMenuRequested) header.setContextMenuPolicy(Qt.CustomContextMenu) self._ctrlers = {} self._column_index = {} for column_name in self._column_names: self._column_index[column_name] = len(self._column_index) # controller manager services self.list_types = {} self.list_ctrlers = {} self.load_ctrler = {} self.unload_ctrler = {} self.switch_ctrlers = {} self.ctrlman_ns_cur = '' self.loadable_params = {} # init and start update timer self._timer_refresh_ctrlers = QTimer(self) self._timer_refresh_ctrlers.timeout.connect(self._refresh_ctrlers_cb)
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) # self.host = host self.setWindowIcon(QtGui.QIcon(":/icons/irondevil_sync.png")) self.setWindowTitle('Sync') self.verticalLayout = QtGui.QVBoxLayout(self) self.verticalLayout.setObjectName("verticalLayout") self.resize(350, 190) self.toolButton_SyncAll = QtGui.QToolButton(self) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(2) sizePolicy.setHeightForWidth( self.toolButton_SyncAll.sizePolicy().hasHeightForWidth()) self.toolButton_SyncAll.setSizePolicy(sizePolicy) self.toolButton_SyncAll.setObjectName("toolButton_SyncAll") self.verticalLayout.addWidget(self.toolButton_SyncAll) self.toolButton_SyncAll.setText( QtGui.QApplication.translate("Form", "Sync All", None, QtGui.QApplication.UnicodeUTF8)) self.toolButton_SyncAll.clicked.connect(self._on_sync_all_clicked) self.toolButton_SyncAllAnyMsg = QtGui.QToolButton(self) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth( self.toolButton_SyncAllAnyMsg.sizePolicy().hasHeightForWidth()) self.toolButton_SyncAllAnyMsg.setSizePolicy(sizePolicy) self.toolButton_SyncAllAnyMsg.setObjectName("toolButton_SyncAllAnyMsg") self.verticalLayout.addWidget(self.toolButton_SyncAllAnyMsg) self.toolButton_SyncAllAnyMsg.setText( QtGui.QApplication.translate("Form", "Sync all (+AnyMsg)", None, QtGui.QApplication.UnicodeUTF8)) self.toolButton_SyncAllAnyMsg.clicked.connect( self._on_sync_all_anymsg_clicked) self.toolButton_SyncTopicOnDemand = QtGui.QToolButton(self) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth( self.toolButton_SyncTopicOnDemand.sizePolicy().hasHeightForWidth()) self.toolButton_SyncTopicOnDemand.setSizePolicy(sizePolicy) self.toolButton_SyncTopicOnDemand.setObjectName( "toolButton_SyncTopicOnDemand") self.verticalLayout.addWidget(self.toolButton_SyncTopicOnDemand) self.toolButton_SyncTopicOnDemand.setText( QtGui.QApplication.translate("Form", "Sync only topics on demand", None, QtGui.QApplication.UnicodeUTF8)) self.toolButton_SyncTopicOnDemand.clicked.connect( self._on_sync_topics_on_demand_clicked) self.toolButton_SelectInterface = QtGui.QToolButton(self) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth( self.toolButton_SelectInterface.sizePolicy().hasHeightForWidth()) self.toolButton_SelectInterface.setSizePolicy(sizePolicy) self.toolButton_SelectInterface.setObjectName( "toolButton_SelectInterface") self.verticalLayout.addWidget(self.toolButton_SelectInterface) self.toolButton_SelectInterface.setText( QtGui.QApplication.translate("Form", "Select an interface", None, QtGui.QApplication.UnicodeUTF8)) self.toolButton_SelectInterface.clicked.connect( self._on_select_interface_clicked) self.interface_field = QtGui.QComboBox(self) self.interface_field.setInsertPolicy( QtGui.QComboBox.InsertAlphabetically) self.interface_field.setSizePolicy( QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)) self.interface_field.setEditable(True) self.interface_field.setVisible(False) self.interface_field.setObjectName("interface_field") self.verticalLayout.addWidget(self.interface_field) self.interface_field.currentIndexChanged[str].connect( self._on_interface_selected) self.toolButton_EditInterface = QtGui.QToolButton(self) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth( self.toolButton_EditInterface.sizePolicy().hasHeightForWidth()) self.toolButton_EditInterface.setSizePolicy(sizePolicy) self.toolButton_EditInterface.setObjectName("toolButton_EditInterface") self.verticalLayout.addWidget(self.toolButton_EditInterface) self.toolButton_EditInterface.setText( QtGui.QApplication.translate("Form", "Edit selected interface", None, QtGui.QApplication.UnicodeUTF8)) self.toolButton_EditInterface.clicked.connect( self._on_edit_interface_clicked) self.toolButton_EditInterface.setVisible(False) self.toolButton_CreateInterface = QtGui.QToolButton(self) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth( self.toolButton_CreateInterface.sizePolicy().hasHeightForWidth()) self.toolButton_CreateInterface.setSizePolicy(sizePolicy) self.toolButton_CreateInterface.setObjectName( "toolButton_CreateInterface") self.verticalLayout.addWidget(self.toolButton_CreateInterface) self.toolButton_CreateInterface.setText( QtGui.QApplication.translate("Form", "Create an interface", None, QtGui.QApplication.UnicodeUTF8)) self.toolButton_CreateInterface.clicked.connect( self._on_create_interface_clicked) self.toolButton_CreateInterface.setVisible(False) self.textedit = Editor('', self) self.hl = SyncHighlighter(self.textedit.document()) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.textedit.setSizePolicy(sizePolicy) self.textedit.setObjectName("syncedit") self.verticalLayout.addWidget(self.textedit) self.textedit.setVisible(False) self._fill_interface_thread = None self._interfaces_files = None self._sync_args = [] self._interface_filename = None self.buttonBox = QtGui.QDialogButtonBox(self) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setObjectName("buttonBox") self.verticalLayout.addWidget(self.buttonBox) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), self.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), self.reject) self._new_iface = True
def __init__(self, context): self.prompt_width = 170 self.input_width = 250 super(SimpleGUI, self).__init__(context) self.setObjectName('SimpleGUI') self._widget = QWidget() self._sound_client = SoundClient() #find relative path for files to load self.local_dir = os.path.dirname(__file__) self.dir = os.path.join(self.local_dir, './lib/rqt_simplegui/') if not os.path.isdir(self.dir): os.makedirs(self.dir) #need to add any additional subfolders as needed if not os.path.isdir(self.dir + 'animations/'): os.makedirs(self.dir + 'animations/') # Creates a subscriber to the ROS topic, having msg type SoundRequest rospy.Subscriber('robotsound', SoundRequest, self.sound_cb) QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10)) self.sound_sig.connect(self.sound_sig_cb) # Code used for saving/ loading arm poses for the robot switch_srv_name = 'pr2_controller_manager/switch_controller' rospy.loginfo('Waiting for switch controller service...') rospy.wait_for_service(switch_srv_name) self.switch_service_client = rospy.ServiceProxy( switch_srv_name, SwitchController) self.r_joint_names = [ 'r_shoulder_pan_joint', 'r_shoulder_lift_joint', 'r_upper_arm_roll_joint', 'r_elbow_flex_joint', 'r_forearm_roll_joint', 'r_wrist_flex_joint', 'r_wrist_roll_joint' ] self.l_joint_names = [ 'l_shoulder_pan_joint', 'l_shoulder_lift_joint', 'l_upper_arm_roll_joint', 'l_elbow_flex_joint', 'l_forearm_roll_joint', 'l_wrist_flex_joint', 'l_wrist_roll_joint' ] self.all_joint_names = [] self.all_joint_poses = [] # Hash tables storing the name of the pose and the # associated positions for that pose, initially empty self.saved_l_poses = {} self.saved_r_poses = {} # Hash tables for storing name of animations and the associated pose list self.saved_animations = {} self.lock = threading.Lock() rospy.Subscriber('joint_states', JointState, self.joint_states_cb) #parsing for animations dir = os.path.dirname(__file__) qWarning(dir) filename = os.path.join(self.dir, 'animations/') ani_path = filename ani_listing = os.listdir(ani_path) for infile in ani_listing: pose_left = [] pose_right = [] left_gripper_states = [] right_gripper_states = [] line_num = 1 for line in fileinput.input(ani_path + infile): if (line_num % 2 == 1): pose = [float(x) for x in line.split()] pose_left.append(pose[:len(pose) / 2]) pose_right.append(pose[len(pose) / 2:]) else: states = line.split() left_gripper_states.append(states[0]) right_gripper_states.append(states[1]) line_num += 1 self.saved_animations[os.path.splitext(infile)[0]] = Quad( pose_left, pose_right, left_gripper_states, right_gripper_states) # Create a trajectory action client r_traj_controller_name = '/r_arm_controller/joint_trajectory_action' self.r_traj_action_client = SimpleActionClient(r_traj_controller_name, JointTrajectoryAction) rospy.loginfo( 'Waiting for a response from the trajectory action server for RIGHT arm...' ) self.r_traj_action_client.wait_for_server() l_traj_controller_name = '/l_arm_controller/joint_trajectory_action' self.l_traj_action_client = SimpleActionClient(l_traj_controller_name, JointTrajectoryAction) rospy.loginfo( 'Waiting for a response from the trajectory action server for LEFT arm...' ) self.l_traj_action_client.wait_for_server() # Navigation functionality initialization self.roomNav = RoomNavigator() self._tf_listener = TransformListener() self.animPlay = AnimationPlayer(None, None, None, None) # Detection and pickup functionality self.pap = PickAndPlaceManager(self._tf_listener, self.roomNav, self.animPlay) QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10)) self.joint_sig.connect(self.joint_sig_cb) # Create a large vertical box that is top aligned large_box = QtGui.QVBoxLayout() large_box.setAlignment(QtCore.Qt.AlignTop) large_box.setMargin(0) large_box.addItem(QtGui.QSpacerItem(10, 0)) # Buttons for controlling the head of the robot head_box = QtGui.QHBoxLayout() head_box.addItem(QtGui.QSpacerItem(230, 0)) head_box.addWidget(self.create_pressed_button('Head Up')) head_box.addStretch(1) large_box.addLayout(head_box) button_box = QtGui.QHBoxLayout() button_box.addItem(QtGui.QSpacerItem(80, 0)) button_box.addWidget(self.create_pressed_button('Head Turn Left')) button_box.addWidget(self.create_pressed_button('Head Down')) button_box.addWidget(self.create_pressed_button('Head Turn Right')) button_box.addStretch(1) button_box.setMargin(0) button_box.setSpacing(0) large_box.addLayout(button_box) # Shows what the robot says speech_box = QtGui.QHBoxLayout() self.speech_label = QtGui.QLabel('Robot has not spoken yet') palette = QtGui.QPalette() palette.setColor(QtGui.QPalette.Foreground, QtCore.Qt.blue) self.speech_label.setPalette(palette) # speech_box.addItem(QtGui.QSpacerItem(100, 0)) #speech_box.addWidget(self.speech_label) # large_box.addLayout(speech_box) # Speak button speak_button_box = QtGui.QHBoxLayout() speech_prompt = QtGui.QLabel('Enter Speech Text:') speech_prompt.setFixedWidth(self.prompt_width) speak_button_box.addWidget(speech_prompt) robot_says = QtGui.QLineEdit(self._widget) robot_says.setFixedWidth(self.input_width) robot_says.textChanged[str].connect(self.onChanged) # speak_button_box.addWidget(robot_says) speak_button_box.addWidget(self.create_button('Speak')) speak_button_box.addStretch(1) large_box.addLayout(speak_button_box) large_box.addItem(QtGui.QSpacerItem(0, 50)) # Buttons for arm poses pose_button_box1 = QtGui.QHBoxLayout() pose_button_box1.addItem(QtGui.QSpacerItem(150, 0)) pose_button_box1.addWidget(self.create_button('Relax Left Arm')) pose_button_box1.addWidget(self.create_button('Relax Right Arm')) pose_button_box1.addStretch(1) large_box.addLayout(pose_button_box1) # Buttons for grippers gripper_button_box = QtGui.QHBoxLayout() gripper_button_box.addItem(QtGui.QSpacerItem(150, 0)) gripper_button_box.addWidget(self.create_button('Open Left Gripper')) gripper_button_box.addWidget(self.create_button('Open Right Gripper')) gripper_button_box.addStretch(1) large_box.addLayout(gripper_button_box) large_box.addItem(QtGui.QSpacerItem(0, 25)) # Buttons for animation animation_box = QtGui.QHBoxLayout() play_anim_label = QtGui.QLabel('Select Animation:') play_anim_label.setFixedWidth(self.prompt_width) animation_box.addWidget(play_anim_label) self.saved_animations_list = QtGui.QComboBox(self._widget) animation_box.addWidget(self.saved_animations_list) pose_time_label = QtGui.QLabel('Duration(sec):') pose_time_label.setFixedWidth(100) animation_box.addWidget(pose_time_label) self.pose_time = QtGui.QLineEdit(self._widget) self.pose_time.setFixedWidth(50) self.pose_time.setText('2.0') animation_box.addWidget(self.pose_time) animation_box.addWidget(self.create_button('Play Animation')) animation_box.addStretch(1) large_box.addLayout(animation_box) animation_box2 = QtGui.QHBoxLayout() animation_name_label = QtGui.QLabel('Enter Animation Name:') animation_name_label.setFixedWidth(self.prompt_width) animation_box2.addWidget(animation_name_label) self.animation_name = QtGui.QLineEdit(self._widget) self.animation_name.setFixedWidth(self.input_width) animation_box2.addWidget(self.animation_name) animation_box2.addWidget(self.create_button('Save Animation')) animation_box2.addStretch(1) large_box.addLayout(animation_box2) animation_box3 = QtGui.QHBoxLayout() pose_name_label = QtGui.QLabel('Enter Pose Name:') pose_name_label.setFixedWidth(self.prompt_width) animation_box3.addWidget(pose_name_label) self.pose_name_temp = QtGui.QLineEdit(self._widget) self.pose_name_temp.setFixedWidth(self.input_width) animation_box3.addWidget(self.pose_name_temp) animation_box3.addWidget(self.create_button('Add Current Pose')) animation_box3.addStretch(1) large_box.addLayout(animation_box3) # Playing around with UI stuff play_box = QtGui.QHBoxLayout() pose_sequence_label = QtGui.QLabel('Current Pose Sequence:') pose_sequence_label.setFixedWidth(self.prompt_width) pose_sequence_label.setAlignment(QtCore.Qt.AlignTop) self.list_widget = QListWidget() self.list_widget.setDragDropMode(QAbstractItemView.InternalMove) self.list_widget.setMaximumSize(self.input_width, 200) play_box.addWidget(pose_sequence_label) play_box.addWidget(self.list_widget) play_box.addStretch(1) large_box.addLayout(play_box) large_box.addItem(QtGui.QSpacerItem(0, 50)) # Buttons for first row of base controls first_base_button_box = QtGui.QHBoxLayout() first_base_button_box.addItem(QtGui.QSpacerItem(70, 0)) first_base_button_box.addWidget( self.create_pressed_button('Rotate Left')) first_base_button_box.addWidget(self.create_pressed_button('^')) first_base_button_box.addWidget( self.create_pressed_button('Rotate Right')) first_base_button_box.addStretch(1) large_box.addLayout(first_base_button_box) # Buttons for second row of base controls second_base_button_box = QtGui.QHBoxLayout() second_base_button_box.addItem(QtGui.QSpacerItem(70, 0)) second_base_button_box.addWidget(self.create_pressed_button('<')) second_base_button_box.addWidget(self.create_pressed_button('v')) second_base_button_box.addWidget(self.create_pressed_button('>')) second_base_button_box.addWidget(self.create_button('Move to Bin')) second_base_button_box.addWidget(self.create_button('Object Detect')) second_base_button_box.addWidget(self.create_button('Clean Room')) second_base_button_box.addStretch(1) large_box.addLayout(second_base_button_box) # Animation related items to store intermediate pose co-ordinates to save self.animation_map = {} self.create_state = False self._widget.setObjectName('SimpleGUI') self._widget.setLayout(large_box) context.add_widget(self._widget) # Look straight and down when launched self.head_x = 1.0 self.head_y = 0.0 self.head_z = 0.5 self.head_action(self.head_x, self.head_y, self.head_z) # Set grippers to closed on initialization self.left_gripper_state = '' self.right_gripper_state = '' self.gripper_action('l', 0.0) self.gripper_action('r', 0.0) # Lab 6 self.marker_publisher = rospy.Publisher('visualization_marker', Marker) # Saved states for poses saved_pose_box = QtGui.QHBoxLayout() self.saved_left_poses = QtGui.QLabel('') self.saved_right_poses = QtGui.QLabel('') saved_pose_box.addWidget(self.saved_left_poses) saved_pose_box.addWidget(self.saved_right_poses) large_box.addLayout(saved_pose_box) # Preload the map of animations self.saved_animations_list.addItems(self.saved_animations.keys()) # Move the torso all the way down # self.torso_down(True) # Autonomous navigation stuff ''' self.locations = [Pose(Point(2.48293590546, 3.90075874329, 0.000), Quaternion(0.000, 0.000, -0.783917630973, 0.620864838632)), Pose(Point(3.70106744766, 0.304672241211, 0.000), Quaternion(0.000, 0.000, 0.950186880196, -0.311680754463)), Pose(Point(2.57326722145, 1.51304531097, 0.000), Quaternion(0.000, 0.000, 0.96127194482, -0.275601611212)), Pose(Point(1.28060531616, 1.52380752563, 0.000), Quaternion(0.000, 0.000, 0.946345258806, -0.323157316388)), Pose(Point(2.11048603058, 0.420155525208, 0.000), Quaternion(0.000, 0.000, 0.945222393391, -0.326427062346)), Pose(Point(2.82733058929, -0.739856719971, 0.000), Quaternion(0.000, 0.000, 0.945473998362, -0.325697587373)), Pose(Point(1.29184818268, -1.90485572815, 0.000), Quaternion(0.000, 0.000, 0.942275557345, -0.334838429739)), Pose(Point(0.722846984863, -1.0921459198, 0.000), Quaternion(0.000, 0.000, 0.949330143731, -0.314280572424))] ''' self.locations = [ Pose(Point(2.04748392105, 2.04748010635, 0.000), Quaternion(0.000, 0.000, -0.776968030817, 0.629540053601)), Pose(Point(2.34193611145, 1.43208932877, 0), Quaternion(0, 0, -0.841674385779, 0.539985396398)), Pose(Point(3.43202018738, -0.258297920227, 0.000), Quaternion(0.000, 0.000, 0.996656413122, -0.0817067572629)), Pose(Point(0.931655406952, -1.96435832977, 0.000), Quaternion(0.000, 0.000, 0.691187586713, 0.722675390458)), Pose(Point(-0.369112968445, 0.0330476760864, 0.000), Quaternion(0.000, 0.000, 0.0275340398899, 0.999620866453)) ] self.index = 1 rospy.loginfo("Completed GUI initialization")
def init_ui(self): # type combobox ui_type_lable = QtGui.QLabel('Robot') ui_type_lable.setStyleSheet('QLabel {font: bold}') ui_type_lable.setMaximumWidth(70) # ui_type_lable.setFont(QtGui.QFont(QtGui.QFont.Bold)) ui_type_lable.setAlignment(QtCore.Qt.AlignCenter) self.ui_type = QtGui.QComboBox() self.ui_type.addItem('MTMR') self.ui_type.addItem('MTML') self.ui_type.addItem('PSM1') self.ui_type.addItem('PSM2') self.ui_type.addItem('PSM3') # self.ui_type.addItem('ECM') ui_hbox_type = QtGui.QHBoxLayout() ui_hbox_type.addWidget(ui_type_lable) ui_hbox_type.addWidget(self.ui_type) self.ui_type.currentIndexChanged.connect(self.slot_type_changed) # control mode # todo: use a for loop gbox = QtGui.QGridLayout() ui_btn_idle = QtGui.QPushButton('Idle') ui_btn_idle.setCheckable(True) ui_btn_idle.setChecked(True) gbox.addWidget(ui_btn_idle, 0, 0) ui_btn_idle.clicked[bool].connect(self.slot_btn_idle) ui_btn_home = QtGui.QPushButton('Home') ui_btn_home.setCheckable(True) gbox.addWidget(ui_btn_home, 0, 1) ui_btn_home.clicked[bool].connect(self.slot_btn_home) ui_btn_grav = QtGui.QPushButton('Gravity') ui_btn_grav.setCheckable(True) gbox.addWidget(ui_btn_grav, 1, 0) ui_btn_grav.clicked[bool].connect(self.slot_btn_grav) ui_btn_vfix = QtGui.QPushButton('Teleop') ui_btn_vfix.setCheckable(True) gbox.addWidget(ui_btn_vfix, 1, 1) ui_btn_vfix.clicked[bool].connect(self.slot_btn_teleop) ui_btn_group = QtGui.QButtonGroup(self._widget) ui_btn_group.addButton(ui_btn_idle) ui_btn_group.addButton(ui_btn_home) ui_btn_group.addButton(ui_btn_grav) ui_btn_group.addButton(ui_btn_vfix) ui_btn_group.setExclusive(True) # connect here self.ui_gbox_control = QtGui.QGroupBox('Control MTM') self.ui_gbox_control.setLayout(gbox) # ---- PSM Control Box ---- gbox = QtGui.QGridLayout() ui_btn_idle = QtGui.QPushButton('Idle') ui_btn_idle.setCheckable(True) ui_btn_idle.setChecked(True) gbox.addWidget(ui_btn_idle, 0, 0) ui_btn_idle.clicked[bool].connect(self.slot_btn_idle) ui_btn_home = QtGui.QPushButton('Home') ui_btn_home.setCheckable(True) gbox.addWidget(ui_btn_home, 0, 1) ui_btn_home.clicked[bool].connect(self.slot_btn_home) ui_btn_grav = QtGui.QPushButton('Teleop') ui_btn_grav.setCheckable(True) gbox.addWidget(ui_btn_grav, 1, 0) ui_btn_grav.clicked[bool].connect(self.slot_btn_teleop) ui_btn_vfix = QtGui.QPushButton('Manual') ui_btn_vfix.setCheckable(True) gbox.addWidget(ui_btn_vfix, 1, 1) ui_btn_vfix.clicked[bool].connect(self.slot_btn_manual) ui_btn_group = QtGui.QButtonGroup(self._widget) ui_btn_group.addButton(ui_btn_idle) ui_btn_group.addButton(ui_btn_home) ui_btn_group.addButton(ui_btn_grav) ui_btn_group.addButton(ui_btn_vfix) ui_btn_group.setExclusive(True) # connect here self.ui_gbox_control_psm = QtGui.QGroupBox('Control PSM') self.ui_gbox_control_psm.setLayout(gbox) self.ui_gbox_control_psm.setVisible(False) # ---- gripper box ----- ui_hbox_gripper = QtGui.QHBoxLayout() ui_gripper_label = QtGui.QLabel('Gripper Angle:') ui_hbox_gripper.addWidget(ui_gripper_label) ui_gbox_gripper = QtGui.QGroupBox('Gripper') ui_gbox_gripper.setLayout(ui_hbox_gripper) # ---- joint position group ----- jnt_pos_hbox = QtGui.QHBoxLayout() jp_widgets = [] jn_widgets = [] for i in range(7): pos_vbox = QtGui.QVBoxLayout() ui_ppos = QwtThermo() ui_ppos.setScalePosition(QwtThermo.NoScale) ui_ppos.setAutoFillBackground(True) ui_ppos.setAlarmLevel(0.8) ui_ppos.setPipeWidth(20) ui_ppos.setValue(0.0) ui_ppos.setMinimumSize(0, 40) ui_ppos.setRange(0.0, 1.0, False) ui_npos = QwtThermo() ui_npos.setScalePosition(QwtThermo.NoScale) ui_npos.setAlarmLevel(0.8) ui_npos.setPipeWidth(20) ui_npos.setValue(0.9) ui_npos.setMinimumSize(0, 40) ui_npos.setRange(1.0, 0.0, False) ui_npos.setValue(0.0) ui_label_jnt = QtGui.QLabel('J' + str(i)) pos_vbox.addWidget(ui_ppos) pos_vbox.addWidget(ui_npos) pos_vbox.addWidget(ui_label_jnt) jnt_pos_hbox.addLayout(pos_vbox) jp_widgets.append(ui_ppos) jn_widgets.append(ui_npos) # ui_btn_jnt_pos = QPushButton('J1') ui_gbox_jnt_pos = QtGui.QGroupBox('Joint Positions (normalized)') ui_gbox_jnt_pos.setLayout(jnt_pos_hbox) self.joint_widgets = zip(jp_widgets, jn_widgets) # joint torque group jnt_eff_hbox = QtGui.QHBoxLayout() tp_widgets = [] tn_widgets = [] for i in range(7): eff_vbox = QtGui.QVBoxLayout() ui_peff = QwtThermo() ui_peff.setScalePosition(QwtThermo.NoScale) ui_peff.setAutoFillBackground(True) ui_peff.setAlarmLevel(0.8) ui_peff.setPipeWidth(20) ui_peff.setValue(0.0) ui_peff.setMinimumSize(0, 30) ui_peff.setRange(0.0, 1.0, False) ui_neff = QwtThermo() ui_neff.setScalePosition(QwtThermo.NoScale) ui_neff.setAlarmLevel(0.8) ui_neff.setPipeWidth(20) ui_neff.setValue(0.9) ui_neff.setMinimumSize(0, 30) ui_neff.setRange(1.0, 0.0, False) ui_neff.setValue(0.0) ui_label_jnt = QtGui.QLabel('J' + str(i)) eff_vbox.addWidget(ui_peff) eff_vbox.addWidget(ui_neff) eff_vbox.addWidget(ui_label_jnt) jnt_eff_hbox.addLayout(eff_vbox) tp_widgets.append(ui_peff) tn_widgets.append(ui_neff) ui_gbox_jnt_eff = QtGui.QGroupBox('Joint Torques (normalized)') ui_gbox_jnt_eff.setLayout(jnt_eff_hbox) self.torque_widgets = zip(tp_widgets, tn_widgets) # make widgets colorful self.dvrk_green = QColor(87, 186, 142) self.dvrk_green_dark = self.dvrk_green.darker() self.dvrk_green_light = self.dvrk_green.lighter() self.dvrk_blue = QColor(80, 148, 204) self.dvrk_blue_dark = self.dvrk_blue.darker() self.dvrk_blue_light = self.dvrk_blue.lighter() self.dvrk_red = QColor(232, 47, 47) self.dvrk_red_dark = self.dvrk_red.darker() self.dvrk_red_light = self.dvrk_red.lighter() self.dvrk_orange = QColor(255, 103, 43) self.dvrk_orange_dark = self.dvrk_orange.darker() # joint_bg_color = self.dvrk_blue_dark.darker() joint_fill_color = self.dvrk_blue joint_alarm_color = self.dvrk_blue_light # self.dvrk_blue_light # torque_bg_color = self.dvrk_green_dark.darker() torque_fill_color = self.dvrk_green torque_alarm_color = self.dvrk_orange # self.dvrk_green_light for w in jp_widgets + jn_widgets: w.setAlarmLevel(0.80) w.setFillColor(joint_fill_color) w.setAlarmColor(joint_alarm_color) p = w.palette() # p.setColor(ui_ppos.backgroundRole(), joint_bg_color) w.setPalette(p) for w in tp_widgets + tn_widgets: w.setAlarmLevel(0.66) w.setFillColor(torque_fill_color) w.setAlarmColor(torque_alarm_color) p = w.palette() # p.setColor(ui_peff.backgroundRole(), torque_bg_color) w.setPalette(p) # main layout main_layout = QtGui.QVBoxLayout() main_layout.addLayout(ui_hbox_type) main_layout.addWidget(self.ui_gbox_control) main_layout.addWidget(self.ui_gbox_control_psm) main_layout.addWidget(ui_gbox_gripper) main_layout.addWidget(ui_gbox_jnt_pos) main_layout.addWidget(ui_gbox_jnt_eff) self._widget.setLayout(main_layout) pass