def __init__(self): QtGui.QWidget.__init__(self) self._status = "unknown" self._layout = QtGui.QGridLayout(self) self._widgets = dict() self.__logging_cb_signal.connect(self.logging_cb) self.__start_logging_signal.connect(self.start_logging) self.__stop_logging_signal.connect(self.stop_logging) self._add_widget("pid_label", QtGui.QLabel("PID:", self)) self._add_widget("pid", QtGui.QLineEdit(self)) self._widgets["pid"].setMaximumWidth(50) self._add_widget("label_status", QtGui.QLabel(self)) self._widgets["label_status"].setText("Status: Unknown") self._widgets["label_status"].setTextFormat(QtCore.Qt.RichText) self._add_widget("button_start", QtGui.QPushButton("START", self)) self._add_widget("button_stop", QtGui.QPushButton("STOP", self)) self._widgets["button_start"].clicked.connect( self.__start_logging_signal.emit) self._widgets["button_stop"].clicked.connect( self.__stop_logging_signal.emit) self._widgets["label_warning"] = QtGui.QLabel(self) self._layout.addWidget(self._widgets["label_warning"], 1, 0, 1, 2) self._widgets["label_warning"].setTextFormat(QtCore.Qt.RichText) rospy.Subscriber("/data_logger/status", String, self.__logging_cb_signal.emit) self._logging_start = rospy.ServiceProxy('/data_logger/start', DataLoggerStart) self._logging_stop = rospy.ServiceProxy('/data_logger/stop', DataLoggerStop)
def __init__(self, plugin): super(ConfigDialog, self).__init__() self._plugin = plugin self._interval_spin_box = QtGui.QSpinBox() self._interval_spin_box.setMaximum(10000) self._interval_spin_box.setMinimum(1) self._interval_spin_box.setValue( publisher.TopicPublisherWithTimer.publish_interval) self._interval_spin_box.valueChanged.connect(self.update_interval) self._vertical_layout = QtGui.QVBoxLayout() self._horizontal_layout = QtGui.QHBoxLayout() spin_label = QtGui.QLabel('Publish Interval for repeat [ms]') self._horizontal_layout.addWidget(spin_label) self._horizontal_layout.addWidget(self._interval_spin_box) self._vertical_layout.addLayout(self._horizontal_layout) save_button = QtGui.QPushButton(parent=self) save_button.setIcon(self.style().standardIcon( QtGui.QStyle.SP_DialogSaveButton)) save_button.setText('Save to file') save_button.clicked.connect(self.save_to_file) load_button = QtGui.QPushButton(parent=self) load_button.setIcon(self.style().standardIcon( QtGui.QStyle.SP_DialogOpenButton)) load_button.setText('Load from file') load_button.clicked.connect(self.load_from_file) self._vertical_layout.addWidget(save_button) self._vertical_layout.addWidget(load_button) self.setLayout(self._vertical_layout) self.adjustSize()
def __init__(self, service, parent=None): ''' @param service: Service to call. @type service: L{ServiceInfo} ''' self.service = service slots = service.get_service_class(True)._request_class.__slots__ types = service.get_service_class()._request_class._slot_types ParameterDialog.__init__(self, self._params_from_slots(slots, types), buttons=QtGui.QDialogButtonBox.Close, parent=parent) self.setWindowTitle(''.join(['Call ', service.name])) self.service_resp_signal.connect(self._handle_resp) self.resize(450,300) if not slots: self.setText(''.join(['Wait for response ...'])) thread = threading.Thread(target=self._callService) thread.setDaemon(True) thread.start() else: self.call_service_button = QtGui.QPushButton(self.tr("&Call")) self.call_service_button.clicked.connect(self._on_call_service) self.buttonBox.addButton(self.call_service_button, QtGui.QDialogButtonBox.ActionRole) self.hide_button = QtGui.QPushButton(self.tr("&Hide/Show output")) self.hide_button.clicked.connect(self._on_hide_output) self.buttonBox.addButton(self.hide_button, QtGui.QDialogButtonBox.ActionRole) self.hide_button.setVisible(False) self.showLoadSaveButtons()
def addDynamicBox(self): self._dynamic_items_count = 0 addButton = QtGui.QPushButton("+") addButton.setMaximumSize(25,25) addButton.clicked.connect(self._on_add_dynamic_entry) self.options_layout.addWidget(addButton) self.count_label = QtGui.QLabel('0') self.options_layout.addWidget(self.count_label) remButton = QtGui.QPushButton("-") remButton.setMaximumSize(25,25) remButton.clicked.connect(self._on_rem_dynamic_entry) self.options_layout.addWidget(remButton)
def __init__(self, topic_name, attributes, array_index, publisher, parent, label_text=None): super(ValueWidget, self).__init__(topic_name, publisher, parent=parent) self._parent = parent self._attributes = attributes self._array_index = array_index self._text = ez_model.make_text(topic_name, attributes, array_index) self._horizontal_layout = QtGui.QHBoxLayout() if label_text is None: self._topic_label = QtGui.QLabel(self._text) else: self._topic_label = QtGui.QLabel(label_text) self.close_button = QtGui.QPushButton() self.close_button.setMaximumWidth(30) self.close_button.setIcon(self.style().standardIcon( QtGui.QStyle.SP_TitleBarCloseButton)) self.up_button = QtGui.QPushButton() self.up_button.setIcon(self.style().standardIcon( QtGui.QStyle.SP_ArrowUp)) self.up_button.setMaximumWidth(30) self.down_button = QtGui.QPushButton() self.down_button.setMaximumWidth(30) self.down_button.setIcon(self.style().standardIcon( QtGui.QStyle.SP_ArrowDown)) repeat_label = QtGui.QLabel('repeat') self._repeat_box = QtGui.QCheckBox() self._repeat_box.stateChanged.connect(self.repeat_changed) self._repeat_box.setChecked(publisher.is_repeating()) self._horizontal_layout.addWidget(self._topic_label) self._horizontal_layout.addWidget(self.close_button) self._horizontal_layout.addWidget(self.up_button) self._horizontal_layout.addWidget(self.down_button) self._horizontal_layout.addWidget(repeat_label) self._horizontal_layout.addWidget(self._repeat_box) if self._array_index is not None: self.add_button = QtGui.QPushButton('+') self.add_button.setMaximumWidth(30) self._horizontal_layout.addWidget(self.add_button) else: self.add_button = None self.close_button.clicked.connect( lambda x: self._parent.close_slider(self)) self.up_button.clicked.connect( lambda x: self._parent.move_up_widget(self)) self.down_button.clicked.connect( lambda x: self._parent.move_down_widget(self)) self.setup_ui(self._text)
def showLoadSaveButtons(self): self.load_button = QtGui.QPushButton() self.load_button.setIcon(QtGui.QIcon(':/icons/load.png')) self.load_button.clicked.connect(self._load_parameter) self.load_button.setToolTip('Load parameters from YAML file') self.load_button.setFlat(True) self.buttonBox.addButton(self.load_button, QtGui.QDialogButtonBox.ActionRole) self.save_button = QtGui.QPushButton() self.save_button.clicked.connect(self._save_parameter) self.save_button.setIcon(QtGui.QIcon(':/icons/save.png')) self.save_button.setToolTip('Save parameters to YAML file') self.save_button.setFlat(True) self.buttonBox.addButton(self.save_button, QtGui.QDialogButtonBox.ActionRole)
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) ## rviz.VisualizationFrame is the main container widget of the ## regular RViz application. In this example, we disable everything ## so that the only thing visible is the 3D render window. self.frame = rviz.VisualizationFrame() self.frame.setSplashPath("") self.frame.initialize() # Read the configuration from the config file for visualization. reader = rviz.YamlConfigReader() config = rviz.Config() reader.readFile(config, os.path.join(path, 'config', 'workcell.rviz')) self.frame.load(config) self.setWindowTitle(config.mapGetChild("Title").getValue()) self.frame.setMenuBar(None) self.frame.setHideButtonVisibility(False) self.manager = self.frame.getManager() self.grid_display = self.manager.getRootDisplayGroup().getDisplayAt(0) layout = QtGui.QVBoxLayout() layout.setContentsMargins(9, 0, 9, 0) self.setLayout(layout) h_layout = QtGui.QHBoxLayout() layout.addLayout(h_layout) orbit_button = QtGui.QPushButton("Orbit View") orbit_button.clicked.connect(self.onOrbitButtonClick) h_layout.addWidget(orbit_button) front_button = QtGui.QPushButton("Front View") front_button.clicked.connect(self.onFrontButtonClick) h_layout.addWidget(front_button) right_button = QtGui.QPushButton("Rigth View") right_button.clicked.connect(self.onRightButtonClick) h_layout.addWidget(right_button) top_button = QtGui.QPushButton("Top View") top_button.clicked.connect(self.onTopButtonClick) h_layout.addWidget(top_button) layout.addWidget(self.frame)
def __init__(self, masteruri, cfg, ns, nodes, parent=None): QtGui.QFrame.__init__(self, parent) self._masteruri = masteruri self._nodes = {cfg: {ns: nodes}} frame_layout = QtGui.QVBoxLayout(self) frame_layout.setContentsMargins(0, 0, 0, 0) # create frame for warning label self.warning_frame = warning_frame = QtGui.QFrame() warning_layout = QtGui.QHBoxLayout(warning_frame) warning_layout.setContentsMargins(0, 0, 0, 0) warning_layout.addItem( QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)) self.warning_label = QtGui.QLabel() icon = QtGui.QIcon(':/icons/crystal_clear_warning.png') self.warning_label.setPixmap(icon.pixmap(QtCore.QSize(40, 40))) self.warning_label.setToolTip( 'Multiple configuration for same node found!\nA first one will be selected for the start a node!' ) warning_layout.addWidget(self.warning_label) warning_layout.addItem( QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)) frame_layout.addItem( QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)) frame_layout.addWidget(warning_frame) # create frame for start/stop buttons buttons_frame = QtGui.QFrame() buttons_layout = QtGui.QHBoxLayout(buttons_frame) buttons_layout.setContentsMargins(0, 0, 0, 0) buttons_layout.addItem(QtGui.QSpacerItem(20, 20)) self.on_button = QtGui.QPushButton() self.on_button.setFlat(False) self.on_button.setText("On") self.on_button.clicked.connect(self.on_on_clicked) buttons_layout.addWidget(self.on_button) self.off_button = QtGui.QPushButton() self.off_button.setFlat(True) self.off_button.setText("Off") self.off_button.clicked.connect(self.on_off_clicked) buttons_layout.addWidget(self.off_button) buttons_layout.addItem(QtGui.QSpacerItem(20, 20)) frame_layout.addWidget(buttons_frame) frame_layout.addItem( QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)) self.warning_frame.setVisible(False)
def __init__(self, masteruri, ns='/', parent=None): ''' @param masteruri: if the master uri is not None, the parameter are retrieved from ROS parameter server. @type masteruri: C{str} @param ns: namespace of the parameter retrieved from the ROS parameter server. @type ns: C{str} ''' ParameterDialog.__init__(self, dict(), parent=parent) self.masteruri = masteruri self.ns = ns self.is_delivered = False self.is_send = False self.mIcon = QtGui.QIcon(":/icons/default_cfg.png") self.setWindowIcon(self.mIcon) self.resize(450,300) self.add_new_button = QtGui.QPushButton() self.add_new_button.setIcon(QtGui.QIcon(':/icons/crystal_clear_add.png')) self.add_new_button.clicked.connect(self._on_add_parameter) self.add_new_button.setToolTip('Adds a new parameter to the list') self.add_new_button.setFlat(True) self.buttonBox.addButton(self.add_new_button, QtGui.QDialogButtonBox.ActionRole) self.showLoadSaveButtons() # self.apply_button = QtGui.QPushButton(self.tr("&Ok")) # self.apply_button.clicked.connect(self._on_apply) # self.buttonBox.addButton(self.apply_button, QtGui.QDialogButtonBox.ApplyRole) # self.buttonBox.accepted.connect(self._on_apply) self.setText(' '.join(['Obtaining parameters from the parameter server', masteruri, '...'])) self.parameterHandler = ParameterHandler() self.parameterHandler.parameter_list_signal.connect(self._on_param_list) self.parameterHandler.parameter_values_signal.connect(self._on_param_values) self.parameterHandler.delivery_result_signal.connect(self._on_delivered_values) self.parameterHandler.requestParameterList(masteruri, ns)
def setup_ui(self, name, max_value=100000, min_value=-100000, default_max_value=100, default_min_value=-100, initial_value=0): self._min_spin_box = QtGui.QSpinBox() self._min_spin_box.setMaximum(max_value) self._min_spin_box.setMinimum(min_value) self._slider = QtGui.QSlider(QtCore.Qt.Horizontal) self._slider.setTickPosition(QtGui.QSlider.TicksBelow) self._slider.valueChanged.connect(self.slider_changed) self._max_spin_box = QtGui.QSpinBox() self._max_spin_box.setMaximum(max_value) self._max_spin_box.setMinimum(min_value) self._lcd = QtGui.QLCDNumber() self._lcd.setMaximumHeight(self.LCD_HEIGHT) self._min_spin_box.valueChanged.connect(self._slider.setMinimum) self._max_spin_box.valueChanged.connect(self._slider.setMaximum) self._min_spin_box.setValue(default_min_value) self._max_spin_box.setValue(default_max_value) self._slider.setValue(initial_value) zero_button = QtGui.QPushButton('reset') zero_button.clicked.connect(lambda x: self._slider.setValue(0)) self._horizontal_layout.addWidget(self._min_spin_box) self._horizontal_layout.addWidget(self._slider) self._horizontal_layout.addWidget(self._max_spin_box) self._horizontal_layout.addWidget(self._lcd) self._horizontal_layout.addWidget(zero_button) self.setLayout(self._horizontal_layout)
def setup_ui(self, name): self._min_spin_box = QtGui.QDoubleSpinBox() self._min_spin_box.setMaximum(10000) self._min_spin_box.setMinimum(-10000) self._min_spin_box.setValue(self.DEFAULT_MIN_VALUE) self._slider = QtGui.QSlider(QtCore.Qt.Horizontal) self._slider.setTickPosition(QtGui.QSlider.TicksBelow) self._slider.valueChanged.connect(self.slider_changed) self._max_spin_box = QtGui.QDoubleSpinBox() self._max_spin_box.setMaximum(10000) self._max_spin_box.setMinimum(-10000) self._max_spin_box.setValue(self.DEFAULT_MAX_VALUE) self._lcd = QtGui.QLCDNumber() self._lcd.setMaximumHeight(self.LCD_HEIGHT) self._slider.setValue(50) zero_button = QtGui.QPushButton('reset') zero_button.clicked.connect( lambda x: self._slider.setValue(self.value_to_slider(0.0))) self._horizontal_layout.addWidget(self._min_spin_box) self._horizontal_layout.addWidget(self._slider) self._horizontal_layout.addWidget(self._max_spin_box) self._horizontal_layout.addWidget(self._lcd) self._horizontal_layout.addWidget(zero_button) self.setLayout(self._horizontal_layout)
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setObjectName('FindDialog') self.setWindowTitle('Search') self.verticalLayout = QtGui.QVBoxLayout(self) self.verticalLayout.setObjectName("verticalLayout") self.content = QtGui.QWidget(self) self.contentLayout = QtGui.QFormLayout(self.content) # self.contentLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow) # self.contentLayout.setVerticalSpacing(0) self.contentLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.addWidget(self.content) label = QtGui.QLabel("Find:", self.content) self.search_field = QtGui.QLineEdit(self.content) self.contentLayout.addRow(label, self.search_field) replace_label = QtGui.QLabel("Replace:", self.content) self.replace_field = QtGui.QLineEdit(self.content) self.contentLayout.addRow(replace_label, self.replace_field) self.recursive = QtGui.QCheckBox("recursive search") self.contentLayout.addRow(self.recursive) self.result_label = QtGui.QLabel("") self.verticalLayout.addWidget(self.result_label) self.found_files = QtGui.QListWidget() self.found_files.setVisible(False) self.found_files.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.verticalLayout.addWidget(self.found_files) self.buttonBox = QtGui.QDialogButtonBox(self) self.find_button = QtGui.QPushButton(self.tr("&Find")) self.find_button.setDefault(True) self.buttonBox.addButton(self.find_button, QtGui.QDialogButtonBox.ActionRole) self.replace_button = QtGui.QPushButton(self.tr("&Replace/Find")) self.buttonBox.addButton(self.replace_button, QtGui.QDialogButtonBox.ActionRole) self.buttonBox.addButton(QtGui.QDialogButtonBox.Close) 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) QtCore.QMetaObject.connectSlotsByName(self) self.search_text = '' self.search_pos = QtGui.QTextCursor()
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.frame = rviz.VisualizationFrame() self.frame.setSplashPath("") self.frame.initialize() reader = rviz.YamlConfigReader() config = rviz.Config() reader.readFile(config, os.path.join(path, 'config', 'workcell.rviz')) self.frame.load(config) self.setWindowTitle(config.mapGetChild("Title").getValue()) self.frame.setMenuBar(None) self.frame.setHideButtonVisibility(False) self.manager = self.frame.getManager() self.grid_display = self.manager.getRootDisplayGroup().getDisplayAt(0) layout = QtGui.QVBoxLayout() layout.setContentsMargins(9, 0, 9, 0) self.setLayout(layout) h_layout = QtGui.QHBoxLayout() layout.addLayout(h_layout) orbit_button = QtGui.QPushButton("Orbit View") orbit_button.clicked.connect(self.onOrbitButtonClick) h_layout.addWidget(orbit_button) front_button = QtGui.QPushButton("Front View") front_button.clicked.connect(self.onFrontButtonClick) h_layout.addWidget(front_button) right_button = QtGui.QPushButton("Rigth View") right_button.clicked.connect(self.onRightButtonClick) h_layout.addWidget(right_button) top_button = QtGui.QPushButton("Top View") top_button.clicked.connect(self.onTopButtonClick) h_layout.addWidget(top_button) layout.addWidget(self.frame)
def create_controls(self): """ Create UI controls. """ vbox = QtGui.QVBoxLayout() form = QtGui.QFormLayout() self.num_sigma = QtGui.QDoubleSpinBox() self.num_sigma.setValue(1.0) self.num_sigma.setMinimum(0.0) self.num_sigma.setSingleStep(0.1) self.num_sigma.setMaximum(1e3) self.num_sigma.setDecimals(2) form.addRow(tr("Sigma:"), self.num_sigma) vbox.addLayout(form) self.chk_preview = QtGui.QCheckBox(tr("Preview")) self.chk_preview.setCheckable(True) self.chk_preview.setChecked(False) vbox.addWidget(self.chk_preview) self.chk_preview.toggled[bool].connect(self.set_preview) self.gbo_output = QtGui.QGroupBox(tr("Output")) self.opt_new = QtGui.QRadioButton(tr("New signal")) self.opt_replace = QtGui.QRadioButton(tr("In place")) self.opt_new.setChecked(True) gbo_vbox2 = QtGui.QVBoxLayout() gbo_vbox2.addWidget(self.opt_new) gbo_vbox2.addWidget(self.opt_replace) self.gbo_output.setLayout(gbo_vbox2) vbox.addWidget(self.gbo_output) self.btn_ok = QtGui.QPushButton(tr("&OK")) self.btn_ok.setDefault(True) self.btn_ok.clicked.connect(self.accept) self.btn_cancel = QtGui.QPushButton(tr("&Cancel")) self.btn_cancel.clicked.connect(self.reject) hbox = QtGui.QHBoxLayout() hbox.addWidget(self.btn_ok) hbox.addWidget(self.btn_cancel) vbox.addLayout(hbox) vbox.addStretch(1) self.setLayout(vbox)
def _create_tag_button(self, parent=None): btn = QtGui.QPushButton(parent) btn.setObjectName("tagButton") btn.setText(QtGui.QApplication.translate("XmlEditor", "Add tag", None, QtGui.QApplication.UnicodeUTF8)) btn.setShortcut(QtGui.QApplication.translate("XmlEditor", "Ctrl+T", None, QtGui.QApplication.UnicodeUTF8)) btn.setToolTip('Adds a ROS launch tag to launch file (Ctrl+T)') # creates a tag menu tag_menu = QtGui.QMenu(btn) # group tag add_group_tag_action = QtGui.QAction("<group>", self, statusTip="", triggered=self._on_add_group_tag) tag_menu.addAction(add_group_tag_action) # node tag add_node_tag_action = QtGui.QAction("<node>", self, statusTip="", triggered=self._on_add_node_tag) tag_menu.addAction(add_node_tag_action) # node tag with all attributes add_node_tag_all_action = QtGui.QAction("<node all>", self, statusTip="", triggered=self._on_add_node_tag_all) tag_menu.addAction(add_node_tag_all_action) # include tag with all attributes add_include_tag_all_action = QtGui.QAction("<include>", self, statusTip="", triggered=self._on_add_include_tag_all) tag_menu.addAction(add_include_tag_all_action) # remap add_remap_tag_action = QtGui.QAction("<remap>", self, statusTip="", triggered=self._on_add_remap_tag) tag_menu.addAction(add_remap_tag_action) # env tag add_env_tag_action = QtGui.QAction("<env>", self, statusTip="", triggered=self._on_add_env_tag) tag_menu.addAction(add_env_tag_action) # param tag add_param_tag_action = QtGui.QAction("<param>", self, statusTip="", triggered=self._on_add_param_tag) tag_menu.addAction(add_param_tag_action) # param tag with all attributes add_param_tag_all_action = QtGui.QAction("<param all>", self, statusTip="", triggered=self._on_add_param_tag_all) tag_menu.addAction(add_param_tag_all_action) # rosparam tag with all attributes add_rosparam_tag_all_action = QtGui.QAction("<rosparam>", self, statusTip="", triggered=self._on_add_rosparam_tag_all) tag_menu.addAction(add_rosparam_tag_all_action) # arg tag with default definition add_arg_tag_default_action = QtGui.QAction("<arg default>", self, statusTip="", triggered=self._on_add_arg_tag_default) tag_menu.addAction(add_arg_tag_default_action) # arg tag with value definition add_arg_tag_value_action = QtGui.QAction("<arg value>", self, statusTip="", triggered=self._on_add_arg_tag_value) tag_menu.addAction(add_arg_tag_value_action) # test tag add_test_tag_action = QtGui.QAction("<test>", self, statusTip="", triggered=self._on_add_test_tag) tag_menu.addAction(add_test_tag_action) # test tag with all attributes add_test_tag_all_action = QtGui.QAction("<test all>", self, statusTip="", triggered=self._on_add_test_tag_all) tag_menu.addAction(add_test_tag_all_action) btn.setMenu(tag_menu) return btn
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, path, parent=None): QtGui.QWidget.__init__(self, parent) self.path = path self._layout = QtGui.QHBoxLayout(self) self._layout.setContentsMargins(0, 0, 0, 0) self._layout.setSpacing(0) self._button = QtGui.QPushButton('...') self._button.setMaximumSize(QtCore.QSize(24, 20)) self._button.clicked.connect(self._on_path_select_clicked) self._layout.addWidget(self._button) self._lineedit = QtGui.QLineEdit(path) self._lineedit.returnPressed.connect(self._on_editing_finished) self._layout.addWidget(self._lineedit) self.setLayout(self._layout) self.setFocusProxy(self._button) self.setAutoFillBackground(True)
def add_button(self, text, row, col): """ Adds a button with an option to the GUI :param text: text of the button to add :param row: row where to add the button :param col: column where to add the button """ if text == "": return # self.clear_buttons() b = QtGui.QPushButton() b.setText(text.replace("_", " ")) bcb = ButtonCB(self, text) self._button_cbs.append(bcb) self.button_layout.addWidget(b, row, col) b.clicked.connect(bcb.callback)
def __init__(self, master): QtCore.QObject.__init__(self) self.name = master.name self._master = master self._syncronized = MasterSyncButtonHelper.NOT_SYNC self.ICONS = { MasterSyncButtonHelper.SYNC: QtGui.QIcon(":/icons/%s_sync.png" % self.ICON_PREFIX), MasterSyncButtonHelper.NOT_SYNC: QtGui.QIcon(":/icons/%s_not_sync.png" % self.ICON_PREFIX), MasterSyncButtonHelper.SWITCHED: QtGui.QIcon(":/icons/%s_start_sync.png" % self.ICON_PREFIX) } self.widget = QtGui.QPushButton() # self.widget.setFlat(True) self.widget.setIcon(self.ICONS[MasterSyncButtonHelper.NOT_SYNC]) self.widget.setMaximumSize(48, 48) self.widget.setCheckable(True) self.widget.clicked.connect(self.on_sync_clicked)
def create_controls(self): self.lbl_nav = QtGui.QLabel(tr("Navigate"), self) self.lst_nav = AxesListWidget(self) self.btn_up = QtGui.QToolButton(self) self.btn_up.setArrowType(QtCore.Qt.UpArrow) self.btn_down = QtGui.QToolButton(self) self.btn_down.setArrowType(QtCore.Qt.DownArrow) self.lbl_sig = QtGui.QLabel(tr("Signal"), self) self.lst_sig = AxesListWidget(self) sp = self.lst_sig.sizePolicy() sp.setVerticalPolicy(QtGui.QSizePolicy.Fixed) self.lst_sig.setSizePolicy(sp) sp = self.lst_nav.sizePolicy() sp.setVerticalPolicy(QtGui.QSizePolicy.Fixed) self.lst_nav.setSizePolicy(sp) self.btn_down.clicked.connect(self._move_down) self.btn_up.clicked.connect(self._move_up) self.lst_nav.inserted.connect(self._list_insert) self.lst_sig.inserted.connect(self._list_insert) self.lst_nav.moved.connect(self._list_move) self.lst_sig.moved.connect(self._list_move) self.btn_flip = QtGui.QPushButton(tr("Reverse axes")) self.btn_flip.clicked.connect(self._flip_clicked) vbox = QtGui.QVBoxLayout() vbox.addWidget(self.lbl_nav) vbox.addWidget(self.lst_nav) hbox = QtGui.QHBoxLayout() hbox.addWidget(self.btn_up) hbox.addWidget(self.btn_down) vbox.addLayout(hbox) vbox.addWidget(self.lbl_sig) vbox.addWidget(self.lst_sig) vbox.addWidget(self.btn_flip) w = QtGui.QWidget() w.setLayout(vbox) self.setWidget(w)
def __init__(self, name, param_type, collapsible=True, parent=None): QtGui.QWidget.__init__(self, parent) self.setObjectName(name) self.name = name self.type = param_type self.params = [] self.collapsed = False self.parameter_description = None vLayout = QtGui.QVBoxLayout() vLayout.setSpacing(0) self.options_layout = QtGui.QHBoxLayout() self.param_widget = QtGui.QFrame() self.name_label = QtGui.QLabel(name) font = self.name_label.font() font.setBold(True) self.name_label.setFont(font) self.type_label = QtGui.QLabel(''.join([' (', param_type, ')'])) if collapsible: self.hide_button = QtGui.QPushButton('-') self.hide_button.setFlat(True) self.hide_button.setMaximumSize(20,20) self.hide_button.clicked.connect(self._on_hide_clicked) self.options_layout.addWidget(self.hide_button) self.options_layout.addWidget(self.name_label) self.options_layout.addWidget(self.type_label) self.options_layout.addStretch() vLayout.addLayout(self.options_layout) self.param_widget.setFrameShape(QtGui.QFrame.Box) self.param_widget.setFrameShadow(QtGui.QFrame.Raised) boxLayout = QtGui.QFormLayout() boxLayout.setVerticalSpacing(0) self.param_widget.setLayout(boxLayout) vLayout.addWidget(self.param_widget) self.setLayout(vLayout) if param_type in ['std_msgs/Header']: self.setCollapsed(True)
def __createDistanceSlider(self, label, distance, callback): """Create a slider widget to control the distance from the selected node. * label -- the label for the slider * distance -- the default distance value * callback -- the function to call when the slider is changed """ frame = QtGui.QFrame() layout = QtGui.QHBoxLayout() frame.setLayout(layout) # Create a main label for the slider label = QtGui.QLabel("%s:" % label) layout.addWidget(label) # Create the slider slider = QtGui.QSlider(QtCore.Qt.Horizontal) slider.setMinimum(0) slider.setMaximum(self.__maxDistance) slider.setValue(distance) slider.setTickPosition(QtGui.QSlider.TicksBelow) slider.setTickInterval(1) # Every 1 level slider.valueChanged.connect(callback) layout.addWidget(slider) # Create a label to display the value label = QtGui.QLabel("%s" % distance) layout.addWidget(label) # Add a button to reset the slider to its original value resetButton = QtGui.QPushButton("Reset") resetButton.clicked.connect(self.__getClickWrapper(slider, distance)) layout.addWidget(resetButton) self.__layout.addWidget(frame) return slider, label
def __init__(self, icon, title, text, detailed_text="", buttons=QtGui.QMessageBox.Ok): QtGui.QMessageBox.__init__(self, icon, title, text, buttons) if detailed_text: self.setDetailedText(detailed_text) # self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) # self.setSizeGripEnabled(True) horizontalSpacer = QtGui.QSpacerItem(480, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) layout = self.layout() layout.addItem(horizontalSpacer, layout.rowCount(), 0, 1, layout.columnCount()) if QtGui.QMessageBox.Abort & buttons: self.setEscapeButton(QtGui.QMessageBox.Abort) elif QtGui.QMessageBox.Ignore & buttons: self.setEscapeButton(QtGui.QMessageBox.Ignore) else: self.setEscapeButton(buttons) self.textEdit = textEdit = self.findChild(QtGui.QTextEdit) if textEdit != None: textEdit.setMinimumHeight(0) textEdit.setMaximumHeight(600) textEdit.setMinimumWidth(0) textEdit.setMaximumWidth(600) textEdit.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.ignore_all_btn = QtGui.QPushButton('Don\'t display again') self.addButton(self.ignore_all_btn, QtGui.QMessageBox.HelpRole)
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 create_pressed_button(self, name): btn = QtGui.QPushButton(name, self._widget) btn.setFixedWidth(150) btn.pressed.connect(self.command_cb) btn.setAutoRepeat(True) # To make sure the movement repeats itself return btn
def __init__(self, filenames, search_text='', parent=None): ''' @param filenames: a list with filenames. The last one will be activated. @type filenames: C{[str, ...]} @param search_text: if not empty, searches in new document for first occurrence of the given text @type search_text: C{str} (Default: C{Empty String}) ''' QtGui.QDialog.__init__(self, parent) self.setObjectName(' - '.join(['xmlEditor', str(filenames)])) self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) self.setWindowFlags(QtCore.Qt.Window) self.mIcon = QtGui.QIcon(":/icons/crystal_clear_edit_launch.png") self._error_icon = QtGui.QIcon(":/icons/crystal_clear_warning.png") self._empty_icon = QtGui.QIcon() self.setWindowIcon(self.mIcon) self.setWindowTitle("ROSLaunch Editor"); # self.finished.connect(self.closeEvent) self.init_filenames = list(filenames) self.files = [] '''@ivar: list with all open files ''' # create tabs for files self.verticalLayout = QtGui.QVBoxLayout(self) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setObjectName("verticalLayout") self.tabWidget = QtGui.QTabWidget(self) self.tabWidget.setTabPosition(QtGui.QTabWidget.North) self.tabWidget.setDocumentMode(True) self.tabWidget.setTabsClosable(True) self.tabWidget.setMovable(False) self.tabWidget.setObjectName("tabWidget") self.tabWidget.tabCloseRequested.connect(self.on_close_tab) self.verticalLayout.addWidget(self.tabWidget) # create the buttons line self.buttons = QtGui.QWidget(self) self.horizontalLayout = QtGui.QHBoxLayout(self.buttons) self.horizontalLayout.setContentsMargins(4, 0, 4, 0) self.horizontalLayout.setObjectName("horizontalLayout") # add the search button self.searchButton = QtGui.QPushButton(self) self.searchButton.setObjectName("searchButton") self.searchButton.clicked.connect(self.on_shortcut_find) self.searchButton.setText(QtGui.QApplication.translate("XmlEditor", "Search", None, QtGui.QApplication.UnicodeUTF8)) self.searchButton.setShortcut(QtGui.QApplication.translate("XmlEditor", "Ctrl+F", None, QtGui.QApplication.UnicodeUTF8)) self.searchButton.setToolTip('Open a search dialog (Ctrl+F)') self.horizontalLayout.addWidget(self.searchButton) # add the goto button self.gotoButton = QtGui.QPushButton(self) self.gotoButton.setObjectName("gotoButton") self.gotoButton.clicked.connect(self.on_shortcut_goto) self.gotoButton.setText(QtGui.QApplication.translate("XmlEditor", "Goto line", None, QtGui.QApplication.UnicodeUTF8)) self.gotoButton.setShortcut(QtGui.QApplication.translate("XmlEditor", "Ctrl+L", None, QtGui.QApplication.UnicodeUTF8)) self.gotoButton.setToolTip('Open a goto dialog (Ctrl+L)') self.horizontalLayout.addWidget(self.gotoButton) # add a tag button self.tagButton = self._create_tag_button(self) self.horizontalLayout.addWidget(self.tagButton) # add spacer spacerItem = QtGui.QSpacerItem(515, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) # add line number label self.pos_label = QtGui.QLabel() self.horizontalLayout.addWidget(self.pos_label) # add spacer spacerItem = QtGui.QSpacerItem(515, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) # add save button self.saveButton = QtGui.QPushButton(self) self.saveButton.setObjectName("saveButton") self.saveButton.clicked.connect(self.on_saveButton_clicked) self.saveButton.setText(QtGui.QApplication.translate("XmlEditor", "Save", None, QtGui.QApplication.UnicodeUTF8)) self.saveButton.setShortcut(QtGui.QApplication.translate("XmlEditor", "Ctrl+S", None, QtGui.QApplication.UnicodeUTF8)) self.saveButton.setToolTip('Save the changes to the file (Ctrl+S)') self.horizontalLayout.addWidget(self.saveButton) self.verticalLayout.addWidget(self.buttons) #create the find dialog self.find_dialog = FindDialog(self) self.find_dialog.buttonBox.clicked.connect(self.on_find_dialog_clicked) self.find_dialog.found_files.itemActivated.connect(self.find_dialog_itemActivated) # self._shortcut_find = QtGui.QShortcut(QtGui.QKeySequence(self.tr("Ctrl+F", "find text")), self) # self._shortcut_find.activated.connect(self.on_shortcut_find) #open the files for f in filenames: if f: self.on_load_request(os.path.normpath(f), search_text) self.readSettings()
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) path = rospkg.RosPack().get_path('etna_planning') ## rviz.VisualizationFrame is the main container widget of the ## regular RViz application. In this example, we disable everything ## so that the only thing visible is the 3D render window. self.frame = rviz.VisualizationFrame() self.frame.setSplashPath("") self.frame.initialize() ## The reader reads config file data into the config object. ## VisualizationFrame reads its data from the config object. reader = rviz.YamlConfigReader() config = rviz.Config() # rospack = rospkg.RosPack() # package_path = rospack.get_path('rviz_python_tutorial') # reader.readFile( config, package_path + "config.myviz" ) reader.readFile(config, os.path.join(path, 'config', 'workcell.rviz')) self.frame.load(config) ## You can also store any other application data you like in the ## config object. Here we read the window title from the map key ## called "Title", which has been added by hand to the config file. self.setWindowTitle(config.mapGetChild("Title").getValue()) self.frame.setMenuBar(None) self.frame.setHideButtonVisibility(False) self.manager = self.frame.getManager() ## Since the config file is part of the source code for this ## example, we know that the first display in the list is the ## grid we want to control. Here we just save a reference to ## it for later. self.grid_display = self.manager.getRootDisplayGroup().getDisplayAt(0) layout = QtGui.QVBoxLayout() layout.setContentsMargins(9, 0, 9, 0) self.setLayout(layout) h_layout = QtGui.QHBoxLayout() layout.addLayout(h_layout) orbit_button = QtGui.QPushButton("Orbit View") orbit_button.clicked.connect(self.onOrbitButtonClick) h_layout.addWidget(orbit_button) front_button = QtGui.QPushButton("Front View") front_button.clicked.connect(self.onFrontButtonClick) h_layout.addWidget(front_button) right_button = QtGui.QPushButton("Rigth View") right_button.clicked.connect(self.onRightButtonClick) h_layout.addWidget(right_button) top_button = QtGui.QPushButton("Top View") top_button.clicked.connect(self.onTopButtonClick) h_layout.addWidget(top_button) layout.addWidget(self.frame)
def create_button(self, name, method): btn = QtGui.QPushButton(name, self) btn.clicked.connect(method) return btn
def create_button(self, name, method=None): if method == None: method = self.command_cb btn = QtGui.QPushButton(name, self._widget) btn.clicked.connect(method) return btn
def create_button(self, command): btn = QtGui.QPushButton(self.commands[command], self._widget) btn.clicked.connect(self.command_cb) return btn