def _create_found_frame(self): self.found_files_frame = ff_frame = QGroupBox("recursive search") ff_frame.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.found_files_vbox_layout = QVBoxLayout(ff_frame) self.found_files_vbox_layout.setSpacing(0) self.found_files_vbox_layout.setContentsMargins(0, 0, 0, 0) self.found_files_list = QListWidget(ff_frame) self.found_files_list.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.found_files_list.setFrameStyle(QFrame.StyledPanel) self.found_files_list.itemActivated.connect(self.on_itemActivated) self.found_files_list.setStyleSheet("QListWidget {" "background-color:transparent;" "}" "QListWidget::item {" "background-color:transparent;" "}" "QListWidget::item:selected {" "background-color: darkgray;" "}") self.found_files_vbox_layout.addWidget(self.found_files_list) ff_frame.setCheckable(True) ff_frame.setChecked(False) ff_frame.setFlat(True) self.found_files_list.setVisible(False) return self.found_files_frame
def beginGroup(self, obj): parent, layout = self.__get_immediate_parent() panel = QGroupBox(obj.name, parent) if obj.layout == "grid": l = QGridLayout() elif obj.layout == "vertical": l = QVBoxLayout() else: l = QHBoxLayout() self.__increase_nesting_level(panel, l)
def add_widget_with_frame(parent, widget, text=""): box_layout = QHBoxLayout() box_layout.addWidget(widget) group_box = QGroupBox() group_box.setStyleSheet( "QGroupBox { border: 1px solid gray; border-radius: 4px; margin-top: 0.5em; } QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; }" ) group_box.setTitle(text) group_box.setLayout(box_layout) parent.addWidget(group_box)
def __init__(self, updater, config): super(BoxGroup, self).__init__(updater, config) self.box = QGroupBox(self.name) self.box.setLayout(self.grid)
def __init__(self, context): super(PbDGUI, self).__init__(context) self.setObjectName('PbDGUI') self._widget = QWidget() self.speech_cmd_publisher = rospy.Publisher('recognized_command', Command) self.gui_cmd_publisher = rospy.Publisher('gui_command', GuiCommand) rospy.Subscriber('experiment_state', ExperimentState, self.exp_state_cb) rospy.Subscriber('robotsound', SoundRequest, self.robotSoundReceived) QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10)) self.exp_state_sig.connect(self.update_state) self.commands = dict() self.commands[Command.TEST_MICROPHONE] = 'Test microphone' self.commands[Command.NEW_DEMONSTRATION] = 'New demonstration' self.commands[Command.START_RECORDING] = 'Start recording' self.commands[Command.STOP_RECORDING] = 'Stop recording' self.commands[Command.REPLAY_DEMONSTRATION] = 'Replay demonstration' self.commands[Command.DETECT_SURFACE] = 'Detect surface' self.commands[Command.TAKE_TOOL] = 'Take tool' self.commands[Command.RELEASE_TOOL] = 'Release tool' self.commands[Command.SAVE_ARM_POSE] = 'Save arm pose' self.currentAction = -1 self.currentStep = -1 allWidgetsBox = QtGui.QVBoxLayout() actionBox = QGroupBox('Demonstrations', self._widget) self.actionGrid = QtGui.QGridLayout() self.actionGrid.setHorizontalSpacing(0) for i in range(6): self.actionGrid.addItem(QtGui.QSpacerItem(90, 90), 0, i, QtCore.Qt.AlignCenter) self.actionGrid.setColumnStretch(i, 0) self.actionIcons = dict() actionBoxLayout = QtGui.QHBoxLayout() actionBoxLayout.addLayout(self.actionGrid) actionBox.setLayout(actionBoxLayout) actionButtonGrid = QtGui.QHBoxLayout() actionButtonGrid.addWidget( self.create_button(Command.NEW_DEMONSTRATION)) self.stepsBox = QGroupBox('No demonstrations', self._widget) self.stepsGrid = QtGui.QGridLayout() self.l_model = QtGui.QStandardItemModel(self) self.l_view = self._create_table_view(self.l_model, self.l_row_clicked_cb) self.r_model = QtGui.QStandardItemModel(self) self.r_view = self._create_table_view(self.r_model, self.r_row_clicked_cb) self.stepsGrid.addItem(QtGui.QSpacerItem(280, 10), 0, 0, 2, 3) self.stepsGrid.addItem(QtGui.QSpacerItem(10, 10), 0, 1, 2, 3) self.stepsGrid.addItem(QtGui.QSpacerItem(280, 10), 0, 2, 2, 3) self.stepsGrid.addWidget(QtGui.QLabel('Left Arm'), 0, 0) self.stepsGrid.addWidget(QtGui.QLabel('Right Arm'), 0, 2) self.stepsGrid.addWidget(self.l_view, 1, 0) self.stepsGrid.addWidget(self.r_view, 1, 2) stepsBoxLayout = QtGui.QHBoxLayout() stepsBoxLayout.addLayout(self.stepsGrid) self.stepsBox.setLayout(stepsBoxLayout) stepsButtonGrid = QtGui.QHBoxLayout() stepsButtonGrid.addWidget( self.create_button(Command.REPLAY_DEMONSTRATION)) motionButtonGrid = QtGui.QHBoxLayout() motionButtonGrid.addWidget(self.create_button(Command.START_RECORDING)) motionButtonGrid.addWidget(self.create_button(Command.STOP_RECORDING)) misc_grid = QtGui.QHBoxLayout() misc_grid.addWidget(self.create_button(Command.TEST_MICROPHONE)) misc_grid.addWidget(self.create_button(Command.DETECT_SURFACE)) misc_grid.addStretch(1) misc_grid2 = QtGui.QHBoxLayout() misc_grid2.addWidget(self.create_button(Command.TAKE_TOOL)) misc_grid2.addWidget(self.create_button(Command.RELEASE_TOOL)) misc_grid2.addStretch(1) misc_grid3 = QtGui.QHBoxLayout() misc_grid3.addWidget(self.create_button(Command.SAVE_ARM_POSE)) misc_grid3.addStretch(1) speechGroupBox = QGroupBox('Robot Speech', self._widget) speechGroupBox.setObjectName('RobotSpeechGroup') speechBox = QtGui.QHBoxLayout() self.speechLabel = QtGui.QLabel('Robot has not spoken yet') palette = QtGui.QPalette() palette.setColor(QtGui.QPalette.Foreground, QtCore.Qt.blue) self.speechLabel.setPalette(palette) speechBox.addWidget(self.speechLabel) speechGroupBox.setLayout(speechBox) allWidgetsBox.addWidget(actionBox) allWidgetsBox.addLayout(actionButtonGrid) allWidgetsBox.addWidget(self.stepsBox) allWidgetsBox.addLayout(motionButtonGrid) allWidgetsBox.addLayout(stepsButtonGrid) allWidgetsBox.addItem(QtGui.QSpacerItem(100, 20)) allWidgetsBox.addLayout(misc_grid) allWidgetsBox.addItem(QtGui.QSpacerItem(100, 20)) allWidgetsBox.addLayout(misc_grid2) allWidgetsBox.addItem(QtGui.QSpacerItem(100, 40)) allWidgetsBox.addLayout(misc_grid3) allWidgetsBox.addItem(QtGui.QSpacerItem(100, 20)) allWidgetsBox.addWidget(speechGroupBox) allWidgetsBox.addStretch(1) # Fix layout and add main widget to the user interface QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('plastique')) vAllBox = QtGui.QVBoxLayout() vAllBox.addLayout(allWidgetsBox) vAllBox.addStretch(1) hAllBox = QtGui.QHBoxLayout() hAllBox.addLayout(vAllBox) hAllBox.addStretch(1) self._widget.setObjectName('PbDGUI') self._widget.setLayout(hAllBox) context.add_widget(self._widget) rospy.loginfo('Will wait for the experiment state service...') rospy.wait_for_service('get_experiment_state') exp_state_srv = rospy.ServiceProxy('get_experiment_state', GetExperimentState) rospy.loginfo('Got response from the experiment state service...') response = exp_state_srv() self.update_state(response.state)
def __init__(self, context): super(PbDGUI, self).__init__(context) self.setObjectName('PbDGUI') self._widget = QWidget() self.speech_cmd_publisher = rospy.Publisher('recognized_command', Command) self.gui_cmd_publisher = rospy.Publisher('gui_command', GuiCommand) rospy.Subscriber('experiment_state', ExperimentState, self.exp_state_cb) rospy.Subscriber('robotsound', SoundRequest, self.robotSoundReceived) QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10)) self.exp_state_sig.connect(self.update_state) self.commands = dict() self.commands[Command.CREATE_NEW_ACTION] = 'New action' self.commands[Command.TEST_MICROPHONE] = 'Test microphone' self.commands[Command.NEXT_ACTION] = 'Next action' self.commands[Command.PREV_ACTION] = 'Previous action' self.commands[Command.SAVE_POSE] = 'Save pose' self.commands[Command.RELAX_RIGHT_ARM] = 'Relax right arm' self.commands[Command.RELAX_LEFT_ARM] = 'Relax left arm' self.commands[Command.FREEZE_RIGHT_ARM] = 'Freeze right arm' self.commands[Command.FREEZE_LEFT_ARM] = 'Freeze left arm' self.commands[Command.OPEN_RIGHT_HAND] = 'Open right hand' self.commands[Command.OPEN_LEFT_HAND] = 'Open left hand' self.commands[Command.CLOSE_RIGHT_HAND] = 'Close right hand' self.commands[Command.CLOSE_LEFT_HAND] = 'Close left hand' self.commands[Command.CLOSE_LEFT_HAND] = 'Close left hand' self.commands[Command.EXECUTE_ACTION] = 'Execute action' self.commands[Command.STOP_EXECUTION] = 'Stop execution' self.commands[Command.DELETE_ALL_STEPS] = 'Delete all' self.commands[Command.DELETE_LAST_STEP] = 'Delete last' self.commands[Command.RECORD_OBJECT_POSE] = 'Record object poses' self.currentAction = -1 self.currentStep = -1 allWidgetsBox = QtGui.QVBoxLayout() actionBox = QGroupBox('Actions', self._widget) self.actionGrid = QtGui.QGridLayout() self.actionGrid.setHorizontalSpacing(0) for i in range(6): self.actionGrid.addItem(QtGui.QSpacerItem(90, 90), 0, i, QtCore.Qt.AlignCenter) self.actionGrid.setColumnStretch(i, 0) self.actionIcons = dict() actionBoxLayout = QtGui.QHBoxLayout() actionBoxLayout.addLayout(self.actionGrid) actionBox.setLayout(actionBoxLayout) actionButtonGrid = QtGui.QHBoxLayout() actionButtonGrid.addWidget( self.create_button(Command.CREATE_NEW_ACTION)) self.stepsBox = QGroupBox('No actions created yet', self._widget) self.stepsGrid = QtGui.QGridLayout() self.l_model = QtGui.QStandardItemModel(self) self.l_view = self._create_table_view(self.l_model, self.l_row_clicked_cb) self.r_model = QtGui.QStandardItemModel(self) self.r_view = self._create_table_view(self.r_model, self.r_row_clicked_cb) self.stepsGrid.addItem(QtGui.QSpacerItem(280, 10), 0, 0, 2, 3) self.stepsGrid.addItem(QtGui.QSpacerItem(10, 10), 0, 1, 2, 3) self.stepsGrid.addItem(QtGui.QSpacerItem(280, 10), 0, 2, 2, 3) self.stepsGrid.addWidget(QtGui.QLabel('Left Arm'), 0, 0) self.stepsGrid.addWidget(QtGui.QLabel('Right Arm'), 0, 2) self.stepsGrid.addWidget(self.l_view, 1, 0) self.stepsGrid.addWidget(self.r_view, 1, 2) stepsBoxLayout = QtGui.QHBoxLayout() stepsBoxLayout.addLayout(self.stepsGrid) self.stepsBox.setLayout(stepsBoxLayout) stepsButtonGrid = QtGui.QHBoxLayout() stepsButtonGrid.addWidget(self.create_button(Command.SAVE_POSE)) stepsButtonGrid.addWidget(self.create_button(Command.EXECUTE_ACTION)) stepsButtonGrid.addWidget(self.create_button(Command.STOP_EXECUTION)) stepsButtonGrid.addWidget(self.create_button(Command.DELETE_ALL_STEPS)) stepsButtonGrid.addWidget(self.create_button(Command.DELETE_LAST_STEP)) misc_grid = QtGui.QHBoxLayout() misc_grid.addWidget(self.create_button(Command.TEST_MICROPHONE)) misc_grid.addWidget(self.create_button(Command.RECORD_OBJECT_POSE)) misc_grid.addStretch(1) misc_grid2 = QtGui.QHBoxLayout() misc_grid2.addWidget(self.create_button(Command.RELAX_RIGHT_ARM)) misc_grid2.addWidget(self.create_button(Command.RELAX_LEFT_ARM)) misc_grid2.addWidget(self.create_button(Command.FREEZE_RIGHT_ARM)) misc_grid2.addWidget(self.create_button(Command.FREEZE_LEFT_ARM)) misc_grid2.addStretch(1) misc_grid3 = QtGui.QHBoxLayout() misc_grid3.addWidget(self.create_button(Command.OPEN_RIGHT_HAND)) misc_grid3.addWidget(self.create_button(Command.OPEN_LEFT_HAND)) misc_grid3.addWidget(self.create_button(Command.CLOSE_RIGHT_HAND)) misc_grid3.addWidget(self.create_button(Command.CLOSE_LEFT_HAND)) misc_grid3.addStretch(1) misc_grid4 = QtGui.QHBoxLayout() misc_grid4.addWidget(self.create_button(Command.PREV_ACTION)) misc_grid4.addWidget(self.create_button(Command.NEXT_ACTION)) misc_grid4.addStretch(1) speechGroupBox = QGroupBox('Robot Speech', self._widget) speechGroupBox.setObjectName('RobotSpeechGroup') speechBox = QtGui.QHBoxLayout() self.speechLabel = QtGui.QLabel('Robot has not spoken yet') palette = QtGui.QPalette() palette.setColor(QtGui.QPalette.Foreground, QtCore.Qt.blue) self.speechLabel.setPalette(palette) speechBox.addWidget(self.speechLabel) speechGroupBox.setLayout(speechBox) allWidgetsBox.addWidget(actionBox) allWidgetsBox.addLayout(actionButtonGrid) allWidgetsBox.addWidget(self.stepsBox) allWidgetsBox.addLayout(stepsButtonGrid) allWidgetsBox.addItem(QtGui.QSpacerItem(100, 20)) allWidgetsBox.addLayout(misc_grid) allWidgetsBox.addItem(QtGui.QSpacerItem(100, 20)) allWidgetsBox.addLayout(misc_grid2) allWidgetsBox.addLayout(misc_grid3) allWidgetsBox.addItem(QtGui.QSpacerItem(100, 20)) allWidgetsBox.addLayout(misc_grid4) allWidgetsBox.addItem(QtGui.QSpacerItem(100, 20)) allWidgetsBox.addWidget(speechGroupBox) allWidgetsBox.addStretch(1) # Fix layout and add main widget to the user interface QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('plastique')) vAllBox = QtGui.QVBoxLayout() vAllBox.addLayout(allWidgetsBox) vAllBox.addStretch(1) hAllBox = QtGui.QHBoxLayout() hAllBox.addLayout(vAllBox) hAllBox.addStretch(1) self._widget.setObjectName('PbDGUI') self._widget.setLayout(hAllBox) context.add_widget(self._widget) rospy.loginfo('Will wait for the experiment state service...') rospy.wait_for_service('get_experiment_state') exp_state_srv = rospy.ServiceProxy('get_experiment_state', GetExperimentState) rospy.loginfo('Got response from the experiment state service...') response = exp_state_srv() self.update_state(response.state)