def __init__(self, context, actions): super(ActionClientContainerWidget, self).__init__() grid = QGridLayout() grid.setSpacing(1) MAX_COLUMNS = 2 self.setObjectName('ActionClientContainerWidget') self.clear_button = QPushButton("Clear all") self.clear_button.clicked[bool].connect(self._handle_clear_clicked) grid.addWidget(self.clear_button, 0, 0) self.widgets = [] row = 1 column = 0 for k in sorted(actions.keys()): action_name = k widget = ActionClientWidget(context, action_name, actions[k]) grid.addWidget(widget, row, column) self.widgets.append(widget) column += 1 if column >= MAX_COLUMNS: row += 1 column = 0 self.setLayout(grid)
def setup_group_frame(self, group): layout = QVBoxLayout() # grid for buttons for named targets grid = QGridLayout() grid.setSpacing(1) self.button_group = QButtonGroup(self) row = 0 column = 0 named_targets = self.get_named_targets(group) for target in named_targets: button = QPushButton(target) self.button_group.addButton(button) grid.addWidget(button, row, column) column += 1 if column >= self.MAX_COLUMNS: row += 1 column = 0 self.button_group.buttonClicked.connect(self._handle_button_clicked) # grid for show joint value and move arm buttons/text field joint_values_grid = QGridLayout() joint_values_grid.setSpacing(1) button_show_joint_values = QPushButton('Current Joint Values') button_show_joint_values.clicked[bool].connect( self._handle_show_joint_values_clicked) line_edit = QLineEdit() self.text_joint_values.append(line_edit) button_move_to = QPushButton('Move to') button_move_to.clicked[bool].connect(self._handle_move_to_clicked) joint_values_grid.addWidget(button_show_joint_values, 0, 1) joint_values_grid.addWidget(line_edit, 0, 2) joint_values_grid.addWidget(button_move_to, 0, 3) layout.addLayout(grid) line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout.addWidget(line) layout.addLayout(joint_values_grid) frame = QFrame() frame.setLayout(layout) return frame
def __init__(self): super(NodeWidgetsContainer, self).__init__() yaml_file = rospy.get_param("~config_file") stream = open(yaml_file, "r") nodes = yaml.load(stream) rp = rospkg.RosPack() ui_file = os.path.join(rp.get_path('mcr_event_gui'), 'ros', 'resources', 'NodeWidgetsContainer.ui') loadUi(ui_file, self) grid = QGridLayout() grid.setSpacing(1) MAX_COLUMNS = 2 self.setObjectName('NodeWidgetsContainer') self.clear_button = QPushButton("Clear all") self.clear_button.clicked[bool].connect(self._handle_clear_clicked) self.stop_button = QPushButton("Stop all") self.stop_button.clicked[bool].connect(self._handle_stop_clicked) grid.addWidget(self.clear_button, 0, 0) grid.addWidget(self.stop_button, 0, 1) self.widgets = [] row = 1 column = 0 for k in sorted(nodes.keys()): node_name = k widget = NodeEventsWidget(node_name, nodes[k]) width = widget.width() height = widget.height() grid.addWidget(widget, row, column) grid.setColumnMinimumWidth(column, width) grid.setRowMinimumHeight(row, height) self.widgets.append(widget) column += 1 if column >= MAX_COLUMNS: row += 1 column = 0 self.setLayout(grid)