def _update_client_list(self, service_name): service_list = self.admin_app_info.service_list client_list = service_list[service_name]["client_list"] self._widget.client_tab_widget.clear() for k in client_list.values(): client_name = k["name"] k["index"] = self._widget.client_tab_widget.count() main_widget = QWidget() ver_layout = QVBoxLayout(main_widget) ver_layout.setContentsMargins(9, 9, 9, 9) ver_layout.setSizeConstraint(ver_layout.SetDefaultConstraint) sub_widget = QWidget() sub_widget.setAccessibleName('sub_widget') ver_layout.addWidget(sub_widget) client_context_widget = QPlainTextEdit() client_context_widget.setObjectName(client_name + '_' + 'app_context_widget') client_context_widget.setAccessibleName('app_context_widget') client_context_widget.appendPlainText("client name is " + client_name) #ap><b>uuidp_context_widget.appendHtml(k["app_context"]) ver_layout.addWidget(client_context_widget) #add tab self._widget.client_tab_widget.addTab(main_widget, client_name) pass
def _update_client_tab(self): print('[conductor graph]: _update_client_tab') self.pre_selected_client_name = self.cur_selected_client_name self._widget.tabWidget.clear() for k in self._graph.concert_clients.values(): # Only pull in information from connected or connectable clients if k.state not in [ concert_msgs.ConcertClientState.AVAILABLE, concert_msgs.ConcertClientState.MISSING, concert_msgs.ConcertClientState.UNINVITED ]: continue main_widget = QWidget() ver_layout = QVBoxLayout(main_widget) ver_layout.setContentsMargins(9, 9, 9, 9) ver_layout.setSizeConstraint(ver_layout.SetDefaultConstraint) #button layout sub_widget = QWidget() sub_widget.setAccessibleName('sub_widget') ver_layout.addWidget(sub_widget) #client information layout context_label = QLabel() context_label.setText("Client information") ver_layout.addWidget(context_label) app_context_widget = QPlainTextEdit() app_context_widget.setObjectName(k.concert_alias + '_' + 'app_context_widget') app_context_widget.setAccessibleName('app_context_widget') app_context_widget.appendHtml(k.get_rapp_context()) app_context_widget.setReadOnly(True) cursor = app_context_widget.textCursor() cursor.movePosition(QTextCursor.Start, QTextCursor.MoveAnchor, 0) app_context_widget.setTextCursor(cursor) ver_layout.addWidget(app_context_widget) # new icon path = "" if k.is_new: # This only changes when the concert client changes topic publishes anew path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../resources/images/new.gif") #add tab self._widget.tabWidget.addTab(main_widget, QIcon(path), k.concert_alias) #set previous selected tab for k in range(self._widget.tabWidget.count()): tab_text = self._widget.tabWidget.tabText(k) if tab_text == self.pre_selected_client_name: self._widget.tabWidget.setCurrentIndex(k)
def __init__(self, context): super(SpectrogramPlugin, self).__init__(context) self.setObjectName('Spectrogram') self._widget = QWidget() layout = QVBoxLayout() self._widget.setLayout(layout) layout_ = QHBoxLayout() self.line_edit = QLineEdit() layout_.addWidget(self.line_edit) self.apply_btn = QPushButton("Apply") self.apply_btn.clicked.connect(self.apply_clicked) layout_.addWidget(self.apply_btn) layout.addLayout(layout_) self.fig = Figure((5, 4), dpi=100) self.canvas = FigureCanvas(self.fig) self.axes = self.fig.add_subplot(111) self.fig.tight_layout() layout.addWidget(self.canvas) context.add_widget(self._widget) self.update_signal.connect(self.update_spectrogram) self.subscriber_signal.connect(self.update_subscriber) self.subscriber_signal.emit('spec')
def restore_settings(self, settings): serial_number = settings.value('parent', None) #print 'DockWidget.restore_settings()', 'parent', serial_number, 'settings group', settings._group if serial_number is not None: serial_number = int(serial_number) if self._parent_container_serial_number( ) != serial_number and self._container_manager is not None: floating = self.isFloating() pos = self.pos() new_container = self._container_manager.get_container( serial_number) if new_container is not None: new_parent = new_container.main_window else: new_parent = self._container_manager.get_root_main_window() area = self.parent().dockWidgetArea(self) new_parent.addDockWidget(area, self) if floating: self.setFloating(floating) self.move(pos) title_bar = self.titleBarWidget() title_bar.restore_settings(settings) if title_bar.hide_title_bar and not self.features() & DockWidget.DockWidgetFloatable and \ not self.features() & DockWidget.DockWidgetMovable: self._title_bar_backup = title_bar title_widget = QWidget(self) layout = QHBoxLayout(title_widget) layout.setContentsMargins(0, 0, 0, 0) title_widget.setLayout(layout) self.setTitleBarWidget(title_widget)
def __init__(self, context): super(Visualizer, self).__init__(context) self.setObjectName("Visualizer") self._widget = QWidget() ui_file = os.path.join(rospkg.RosPack().get_path("sai_visualizer"), \ "resource", "visualizer_widget.ui") loadUi(ui_file, self._widget, {"PaintWidget": PaintWidget}) self._widget.setObjectName("VisualizerUi") self._widget.setWindowTitle("SAI Visualizer") # Show _widget.windowTitle on left-top of each plugin (when # it's set in _widget). This is useful when you open multiple # plugins at once. Also if you open multiple instances of your # plugin at once, these lines add number to make it easy to # tell from pane to pane. if context.serial_number() > 1: self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number())) # Add widget to the user interface context.add_widget(self._widget) self._redraw_timer = QTimer() self._redraw_timer.setInterval(16) self._redraw_timer.timeout.connect(self._widget.update) self._redraw_timer.start()
def __init__(self, subsystem, settings, authority=205): QObject.__init__(self) self._subsystem = subsystem self._settings = settings self._authority = authority ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'robot.ui') self._widget = QWidget() loadUi(ui_file, self._widget) self._last_update = rospy.Time.now() self._component_names = dict() self._warnings = [] self._feedback_warnings = dict() self._ocu_client = None self._warning_dialog = self._create_warning_dialog() self._detailed_dialog = self._create_detailed_dialog() self.handoff_dialog = HandoffDialog(self.name, self.subsystem_id, self._settings, self._widget) self.handoff_dialog.button_blink.connect( self._widget.button_handoff.setEnabled) self._widget.button_view.clicked.connect(self._on_robot_view) self._widget.button_control.setText( "%s - %d" % (subsystem.ident.name, self._subsystem.ident.address.subsystem_id)) self._widget.button_control.clicked.connect(self._on_robot_control) self._widget.button_control.setObjectName(subsystem.ident.name) self._widget.button_handoff.setEnabled(False) self._widget.button_handoff.clicked.connect(self.on_show_handoff) self._widget.button_warnings.setEnabled(False) self._widget.button_warnings.clicked.connect(self.on_show_warnings) self._widget.button_details.clicked.connect(self.on_show_details)
def __init__(self, context=None): super(ExampleBtnGUI, self).__init__(context) # Initializes child and base # Give QObjects reasonable names self.setObjectName('ExampleBtnGUI') # Create QWidget self._widget = QWidget() # Get path to UI file which is a sibling of this file pkg_dir = roslib.packages.get_pkg_dir('example_button_gui') ui_file_path = os.path.join(pkg_dir, 'ui/example_button_gui.ui') # Extend the widget with all attributes and children from UI file loadUi(ui_file_path, self._widget) # Give QObjects reasonable names self._widget.setObjectName('ExampleBtnGUIUi') # Show _widget.windowTitle on left-top of each plugin (when # it's set in _widget). This is useful when you open multiple # plugins at once. Also if you open multiple instances of your # plugin at once, these lines add number to make it easy to # tell from pane to pane. if context.serial_number() > 1: self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number())) # Add widget to the user interface context.add_widget(self._widget) # Now Set up our own interface: # ==> Connect the buttons to the functions. simpleBtnDemo is defined in ui/example_button_gui.ui self._widget.simpleBtnDemo.clicked.connect(self.btn_clicked_CB)
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}) ''' QMainWindow.__init__(self, parent) self.setObjectName(' - '.join(['Editor', str(filenames)])) self.setAttribute(Qt.WA_DeleteOnClose, True) self.setWindowFlags(Qt.Window) self.mIcon = QIcon(":/icons/crystal_clear_edit_launch.png") self._error_icon = QIcon(":/icons/crystal_clear_warning.png") self._empty_icon = QIcon() self.setWindowIcon(self.mIcon) window_title = "ROSLaunch Editor" if filenames: window_title = self.__getTabName(filenames[0]) self.setWindowTitle(window_title) self.init_filenames = list(filenames) self._search_thread = None # list with all open files self.files = [] # create tabs for files self.main_widget = QWidget(self) self.verticalLayout = QVBoxLayout(self.main_widget) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setSpacing(1) self.verticalLayout.setObjectName("verticalLayout") self.tabWidget = EditorTabWidget(self) self.tabWidget.setTabPosition(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.tabWidget.currentChanged.connect(self.on_tab_changed) self.verticalLayout.addWidget(self.tabWidget) self.buttons = self._create_buttons() self.verticalLayout.addWidget(self.buttons) self.setCentralWidget(self.main_widget) self.find_dialog = TextSearchFrame(self.tabWidget, self) self.find_dialog.search_result_signal.connect(self.on_search_result) self.find_dialog.replace_signal.connect(self.on_replace) self.addDockWidget(Qt.RightDockWidgetArea, self.find_dialog) self.graph_view = GraphViewWidget(self.tabWidget, self) self.graph_view.load_signal.connect(self.on_graph_load_file) self.graph_view.goto_signal.connect(self.on_graph_goto) self.addDockWidget(Qt.RightDockWidgetArea, self.graph_view) # open the files for f in filenames: if f: self.on_load_request(os.path.normpath(f), search_text) self.readSettings() self.find_dialog.setVisible(False) self.graph_view.setVisible(False)
def __init__(self, context): super(ActuatorPlugin, self).__init__(context) self.setObjectName('ActuatorPlugin') self._widget = QWidget() loadUi(os.path.join(uipath, 'actuatorplugin.ui'), self._widget) context.add_widget(self._widget) self._setvalve = rospy.ServiceProxy('actuator_driver/set_valve', SetValve) self._pulsevalve = rospy.ServiceProxy('actuator_driver/pulse_valve', PulseValve) self._switches_sub = rospy.Subscriber('actuator_driver/switches', Switches, lambda msg: self.switches_changed.emit(msg)) self.switches_changed.connect(self._on_switches_changed) self._widget.findChild(QPushButton, 'shootLeftButton').clicked.connect( lambda: self._pulsevalve(VALVE_SHOOTER_LEFT, rospy.Duration(.3))) self._widget.findChild(QPushButton, 'shootRightButton').clicked.connect( lambda: self._pulsevalve(VALVE_SHOOTER_RIGHT, rospy.Duration(.3))) self._widget.findChild(QPushButton, 'extendButton').clicked.connect( lambda: self._setvalve(VALVE_GAS_POWERED_STICK, True)) self._widget.findChild(QPushButton, 'retractButton').clicked.connect( lambda: self._setvalve(VALVE_GAS_POWERED_STICK, False)) self._widget.findChild(QPushButton, 'openButton').clicked.connect(self._open_grabber) self._widget.findChild(QPushButton, 'closeButton').clicked.connect(self._close_grabber) self._widget.findChild(QPushButton, 'dropButton').clicked.connect( lambda: self._pulsevalve(VALVE_DROPPER, rospy.Duration(.5))) self._widget.findChild(QPushButton, 'shutAllValvesButton').clicked.connect(self._shut_valves)
def __init__(self, context): self._context = context super(Teleop, self).__init__(context) # I'd like these to be also configurable via the gui self.maximum_linear_velocity = rospy.get_param('~maximum_linear_velocity', 2.0) self.maximum_angular_velocity = rospy.get_param('~maximum_angular_velocity', 90 * Teleop.degrees_to_radians) rospy.loginfo("Rocon Teleop : maximum velocities [%s, %s]" % (self.maximum_linear_velocity, self.maximum_angular_velocity)) self._widget = QWidget() rospack = rospkg.RosPack() ui_file = os.path.join(rospack.get_path('rocon_qt_teleop'), 'ui', 'rocon_teleop.ui') loadUi(ui_file, self._widget, {'QCameraView': QCameraView, 'QVirtualJoystickView': QVirtualJoystickView}) if context.serial_number() > 1: self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number())) context.add_widget(self._widget) self.teleop_interface = TeleopInterface(image_received_slot=self._widget.camera_view.on_compressed_image_received) # virtual joystick signals self._widget.virtual_joystick_view.joystick_feedback().connect(self.on_joystick_feedback) self._widget.virtual_joystick_view.mouse_released().connect(self.on_mouse_released) #keyboard control for k in self._widget.children(): try: k.keyPressEvent = self.on_key_press k.keyReleaseEvent = self.on_key_release except: pass
def __init__(self): super(TopicSelection, self).__init__() master = rosgraph.Master('rqt_bag_recorder') self.setWindowTitle("Select the topics you want to record") self.resize(500, 700) self.topic_list = [] self.selected_topics = [] self.items_list = [] self.area = QScrollArea(self) self.main_widget = QWidget(self.area) self.ok_button = QPushButton("Record", self) self.ok_button.clicked.connect(self.onButtonClicked) self.ok_button.setEnabled(False) self.main_vlayout = QVBoxLayout(self) self.main_vlayout.addWidget(self.area) self.main_vlayout.addWidget(self.ok_button) self.setLayout(self.main_vlayout) self.selection_vlayout = QVBoxLayout(self) self.item_all = QCheckBox("All", self) self.item_all.stateChanged.connect(self.updateList) self.selection_vlayout.addWidget(self.item_all) topic_data_list = master.getPublishedTopics('') topic_data_list.sort() for topic, datatype in topic_data_list: self.addCheckBox(topic) self.main_widget.setLayout(self.selection_vlayout) self.area.setWidget(self.main_widget) self.show()
def _create_log_bar(self): self.log_dock = QDockWidget(self) self.log_dock.setObjectName('LogFrame') self.log_dock.setFeatures(QDockWidget.DockWidgetMovable | QDockWidget.DockWidgetFloatable) self.log_bar = QWidget(self) self.horizontal_layout_log_bar = QHBoxLayout(self.log_bar) self.horizontal_layout_log_bar.setContentsMargins(2, 0, 2, 0) self.horizontal_layout_log_bar.setObjectName("horizontal_layout_log_bar") # add info label self._log_warning_count = 0 self.log_browser = QTextEdit() self.log_browser.setObjectName("log_browser") self.log_browser.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.log_browser.setLineWrapMode(QTextEdit.NoWrap) # self.log_browser.setMaximumHeight(120) color = QColor(255, 255, 235) bg_style = "QTextEdit#log_browser { background-color: %s;}" % color.name() self.log_bar.setStyleSheet("%s" % (bg_style)) self.horizontal_layout_log_bar.addWidget(self.log_browser) # add hide button self.clear_log_button = QPushButton("clear", self) self.clear_log_button.setObjectName("clear_log_button") self.clear_log_button.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum) self.clear_log_button.clicked.connect(self.on_clear_log_button_clicked) self.clear_log_button.setFlat(True) self.horizontal_layout_log_bar.addWidget(self.clear_log_button) self.log_dock.setWidget(self.log_bar) return self.log_dock
def __init__(self, context): super(KillPlugin, self).__init__(context) self.setObjectName('KillPlugin') self._listener = KillListener() self._broadcaster = KillBroadcaster(rospy.get_name(), 'Software kill using KillPlugin') self._kill_active = False self._widget = QWidget() loadUi(os.path.join(uipath, 'killplugin.ui'), self._widget) context.add_widget(self._widget) self._widget.findChild(QTableWidget, 'killTable').setHorizontalHeaderLabels( ["Name", "Status", "Description"]) self._widget.findChild(QPushButton, 'killButton').clicked.connect( self._on_kill_clicked) self._widget.findChild(QPushButton, 'unkillButton').clicked.connect( self._on_unkill_clicked) self._widget.findChild(QPushButton, 'runButton').clicked.connect( self._on_run_clicked) self._update_timer = QTimer(self._widget) self._update_timer.timeout.connect(self._on_update) self._update_timer.start(100)
def __init__(self, context): super(SimpleRobotSteeringPlugin, self).__init__(context) self.setObjectName('SimpleRobotSteeringPlugin') self._publisher = None self._widget = QWidget() rp = rospkg.RosPack() ui_file = os.path.join(rp.get_path('bwi_rqt_plugins'), 'resource', 'SimpleRobotSteering.ui') loadUi(ui_file, self._widget) self._widget.setObjectName('SimpleRobotSteeringUi') if context.serial_number() > 1: self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number())) self._widget.keyPressEvent = self.keyPressEvent self._widget.keyReleaseEvent = self.keyReleaseEvent context.add_widget(self._widget) self._widget.topic_line_edit.textChanged.connect( self._on_topic_changed) self.linear_vel = 0 self.angular_vel = 0 # After doing so, key press events seem to work ok. self._widget.w_button.setFocus() # timer to consecutively send twist messages self._update_parameter_timer = QTimer(self) self._update_parameter_timer.timeout.connect( self._on_parameter_changed) self._update_parameter_timer.start(100)
def __init__(self, context): super(EusGUI, self).__init__(context) # Give QObjects reasonable names self.setObjectName('EusGUI') self.msg = None # Create a container widget and give it a layout self._toolbar = QToolBar() self._toolbar.addWidget(QLabel('EusGUI')) self._container = QWidget() self._layout = QVBoxLayout() self._container.setLayout(self._layout) self._layout.addWidget(self._toolbar) self._prev_button = QPushButton('PREV') self._prev_button.clicked.connect(self._prev_cb) self._layout.addWidget(self._prev_button) self._refresh_button = QPushButton('DO IT AGAIN') self._refresh_button.clicked.connect(self._refresh_cb) self._layout.addWidget(self._refresh_button) self._next_button = QPushButton('NEXT') self._next_button.clicked.connect(self._next_cb) self._layout.addWidget(self._next_button) context.add_widget(self._container)
def __init__(self, context): super(DragonButton, self).__init__(context) # Give QObjects reasonable names self.setObjectName('DragonButton') # Create QWidget self._widget = QWidget() # Get path to UI file which should be in the "resource" folder of this package ui_file = os.path.join(rospkg.RosPack().get_path('dragon_button'), 'resource', 'button.ui') # Extend the widget with all attributes and children from UI file loadUi(ui_file, self._widget) # Give QObjects reasonable names self._widget.setObjectName('DragonButton') # Show _widget.windowTitle on left-top of each plugin (when # it's set in _widget). This is useful when you open multiple # plugins at once. Also if you open multiple instances of your # plugin at once, these lines add number to make it easy to # tell from pane to pane. #threading self.lock = threading.Lock() #widget self._widget.pushButton_start.clicked.connect(self.pushButton_start) self._widget.pushButton_start.setStyleSheet( "background-color: rgb(128,255,0)") self._widget.pushButton_rviz.clicked.connect(self.pushButton_rviz) self._widget.pushButton_ok.setStyleSheet( "background-color:rgb(128, 255, 0)") if context.serial_number() > 1: self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number())) # Add widget to the user interface context.add_widget(self._widget)
def __init__(self, context): self._lock = threading.Lock() self._context = context super(MakeAMap, self).__init__(context) # I'd like these to be also configurable via the gui self.initialised = False self.is_setting_dlg_live = False self._widget = QWidget() rospack = rospkg.RosPack() ui_file = os.path.join(rospack.get_path('concert_qt_make_a_map'), 'ui', 'concert_make_a_map.ui') loadUi( ui_file, self._widget, { 'QResourceChooser': QResourceChooser, 'QVideoTeleop': QVideoTeleop, 'QSlamWidget': QSlamWidget }) if context.serial_number() > 1: self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number())) # Setting Resource Chooser Interface #### self._set_resource_chooser_interface() context.add_widget(self._widget) self.setObjectName('Make a Map') self._default_cmd_vel_topic = '/teleop/cmd_vel' self._default_compressed_image_topic = '/teleop/compressed_image' self._default_map_topic = 'map' self._default_scan_topic = '/make_a_map/scan' self._default_robot_pose = 'robot_pose' self._default_wc_namespace_param = 'wc_namespace' self._default_wc_namespace = 'world_canvas'
def __init__(self, context): super(RQTNavigation, self).__init__(context) # Give QObjects reasonable names self.setObjectName('Navigation') # Create QWidget self._widget = QWidget() ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'rqt_navigation.ui') loadUi(ui_file, self._widget) self._widget.setObjectName('rqt_navigation') # Show _widget.windowTitle on left-top of each plugin (when # it's set in _widget). This is useful when you open multiple # plugins at once. Also if you open multiple instances of your # plugin at once, these lines add number to make it easy to # tell from pane to pane. if context.serial_number() > 1: self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number())) # Add widget to the user interface context.add_widget(self._widget) self.loadComboBoxItems() # ROS stuff self.veh = rospy.get_param('/veh') self.topic_name = '/' + self.veh + '/actions_dispatcher_node/plan_request' self.pub = rospy.Publisher(self.topic_name, SourceTargetNodes, queue_size=1, latch=True) self._widget.buttonFindPlan.clicked.connect(self.requestPlan)
def __init__(self, context): super(Builder, self).__init__(context) self.setObjectName('Instructor GUI') # Create QWidget self._widget = QWidget() # Get path to UI file which is a sibling of this file rospack = rospkg.RosPack() ui_path = rospack.get_path('instructor_core') + '/ui/main.ui' # Load the ui attributes into the main widget loadUi(ui_path, self._widget) self._widget.setObjectName('InstructorPluginUi') # Show _widget.windowTitle on left-top of each plugin (when # it's set in _widget). This is useful when you open multiple # plugins at once. Also if you open multiple instances of your # plugin at once, these lines add number to make it easy to # tell from pane to pane. if context.serial_number() > 1: self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number())) # Add widget to the user interface context.add_widget(self._widget) palette = QPalette() palette.setColor(QPalette.Background, Qt.white) self._widget.setPalette(palette) # Add custom options self._widget.node_type_list.addItems(['test1', 'test2'])
def __init__(self, interactive_client_interface=None): self.binded_function = {} self.cur_selected_role = '' self.cur_selected_interaction = None self.interactions = {} self.interactive_client_interface = interactive_client_interface self.interactions_widget = QWidget() # load ui rospack = rospkg.RosPack() path = os.path.join(rospack.get_path('rocon_remocon'), 'ui', 'interactions_list.ui') loadUi(path, self.interactions_widget) # interactions list widget self.interactions_widget.interactions_list_widget.setIconSize( QSize(50, 50)) self.interactions_widget.interactions_list_widget.itemDoubleClicked.connect( self._start_interaction) self.interactions_widget.back_btn.pressed.connect(self._back) self.interactions_widget.interactions_list_widget.itemClicked.connect( self._display_interaction_info) # rocon master item click event self.interactions_widget.stop_interactions_button.pressed.connect( self._stop_interaction) self.interactions_widget.stop_interactions_button.setDisabled(True) self.interactions_widget.closeEvent = self._close_event console.logdebug('init QInteractionsChooser')
def __init__(self, options, title='Exclusive Options', selected_index=None): super(ExclusiveOptionGroup, self).__init__() self.setTitle(title) self.setLayout(QVBoxLayout()) self._button_group = QButtonGroup() self._button_group.setExclusive(True) self._options = options button_id = 0 for option in self._options: button_id += 1 radio_button = QRadioButton( option.get('title', 'option %d' % button_id)) radio_button.setEnabled(option.get('enabled', True)) radio_button.setChecked( option.get('selected', False) or (button_id - 1) == selected_index) radio_button.setToolTip(option.get('tooltip', '')) widget = QWidget() widget.setLayout(QVBoxLayout()) widget.layout().addWidget(radio_button) if 'description' in option: widget.layout().addWidget(QLabel(option['description'])) self._button_group.addButton(radio_button, button_id) self.layout().addWidget(widget)
def __init__(self, context): super(Battery_state, self).__init__(context) # Give QObjects reasonable names self.setObjectName('Battery_state') # Process standalone plugin command-line arguments from argparse import ArgumentParser parser = ArgumentParser() # Add argument(s) to the parser. parser.add_argument("-q", "--quiet", action="store_true", dest="quiet", help="Put plugin in silent mode") args, unknowns = parser.parse_known_args(context.argv()) if not args.quiet: print 'arguments: ', args print 'unknowns: ', unknowns self._widget = QWidget() ui_file = os.path.join(rospkg.RosPack().get_path('rqt_battery_state'), 'resource', 'qt_gui3.ui') loadUi(ui_file, self._widget) self._widget.setObjectName('qt_gui3') if context.serial_number() > 0: self._widget.setWindowTitle('Battery State') # Add widget to the user interface context.add_widget(self._widget) self._update_timer = QTimer(self) self._update_timer.timeout.connect(self._handle_update) self._update_timer.start(1000)#time step self.subscriber = rospy.Subscriber('/my_roomba/battery_state', BatteryState, self.subscriber_callback)
def _unload_jtc(self): # Stop updating the joint positions try: self.jointStateChanged.disconnect(self._on_joint_state_change) except: pass # Reset ROS interfaces self._unregister_state_sub() self._unregister_cmd_pub() # Clear joint widgets # NOTE: Implementation is a workaround for: # https://bugreports.qt-project.org/browse/QTBUG-15990 :( layout = self._widget.joint_group.layout() if layout is not None: while layout.count(): layout.takeAt(0).widget().deleteLater() # Delete existing layout by reparenting to temporary QWidget().setLayout(layout) self._widget.joint_group.setLayout(QFormLayout()) # Reset joint data self._joint_names = [] self._joint_pos = {} # Enforce monitor mode (sending commands disabled) self._widget.enable_button.setChecked(False)
def _init_widget(self): self._init_icon_paths() self.setObjectName('Remocon') self._widget_main = QWidget() rospack = rospkg.RosPack() path = os.path.join(rospack.get_path('rocon_remocon'), 'ui', 'remocon.ui') loadUi(path, self._widget_main) # main widget self._widget_main.list_widget.setIconSize(QSize(50, 50)) self._widget_main.list_widget.itemDoubleClicked.connect( self._connect_rocon_master) # list item double click event self._widget_main.list_widget.itemClicked.connect( self._select_rocon_master) # list item double click event self._widget_main.add_concert_btn.pressed.connect( self._set_add_rocon_master) # add button event self._widget_main.delete_btn.pressed.connect( self._delete_rocon_master) # delete button event self._widget_main.delete_all_btn.pressed.connect( self._delete_all_rocon_masters) # delete all button event self._widget_main.refresh_btn.pressed.connect( self._refresh_all_rocon_master_list) # refresh all button event self._widget_main.list_info_widget.clear()
def __init__(self, context): self._lock = threading.Lock() self._context = context super(MapAnnotation, self).__init__(context) # I'd like these to be also configurable via the gui self.initialised = False self.is_setting_dlg_live = False self._widget = QWidget() rospack = rospkg.RosPack() ui_file = os.path.join(rospack.get_path('concert_qt_map_annotation'), 'ui', 'concert_map_annotation.ui') loadUi(ui_file, self._widget, {'QMapAnnotation': QMapAnnotation}) if context.serial_number() > 1: self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number())) self._default_map_topic = 'map' self._default_viz_markers_topic = 'viz_markers' self._default_wc_namespace_param = 'wc_namespace_param' self._default_wc_namespace = 'world_canvas' context.add_widget(self._widget) self.setObjectName('Map Annotation') # Setting Interface #### self._set_map_annotation_interface()
def __init__(self, context): self._context = context super(AdminApp, self).__init__(context) self.initialised = False self.setObjectName('Admin App') self.is_setting_dlg_live = False self._widget = QWidget() rospack = rospkg.RosPack() ui_file = os.path.join(rospack.get_path('concert_admin_app'), 'ui', 'admin_app.ui') self._widget.setObjectName('AdminApphUi') loadUi(ui_file, self._widget, {}) if context.serial_number() > 1: self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number())) self.current_service = None self.params_layout = None self.params_layout_items = [] self._init_admin_app_interface() self._init_event() self._init_widget() context.add_widget(self._widget)
def __init__(self, context): super(QuestionDialogPlugin, self).__init__(context) # Give QObjects reasonable names self.setObjectName('QuestionDialogPlugin') font_size = rospy.get_param("~font_size", 40) # Create QWidget self._widget = QWidget() self._widget.setFont(QFont("Times", font_size, QFont.Bold)) self._layout = QVBoxLayout(self._widget) self._text_browser = QTextBrowser(self._widget) self._layout.addWidget(self._text_browser) self._button_layout = QHBoxLayout() self._layout.addLayout(self._button_layout) # layout = QVBoxLayout(self._widget) # layout.addWidget(self.button) self._widget.setObjectName('QuestionDialogPluginUI') if context.serial_number() > 1: self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number())) context.add_widget(self._widget) # Setup service provider self.service = rospy.Service('question_dialog', QuestionDialog, self.service_callback) self.response_ready = False self.response = None self.buttons = [] self.text_label = None self.text_input = None self.connect(self._widget, SIGNAL("update"), self.update) self.connect(self._widget, SIGNAL("timeout"), self.timeout)
def __init__(self, context): super(MyPlugin, self).__init__(context) self.setObjectName('MyPlugin') from argparse import ArgumentParser parser = ArgumentParser() parser.add_argument("-q", "--quiet", action="store_true", dest="quiet", help="Put plugin in silent mode") args, unknowns = parser.parse_known_args(context.argv()) if not args.quiet: print 'arguments: ', args print 'unknowns: ', unknowns # Create QWidget self._widget = QWidget() # Get path to UI file which should be in the "resource" folder of this package ui_file = os.path.join(rospkg.RosPack().get_path('rqt_pkg'), 'resource', 'MyPlugin.ui') # Extend the widget with all attributes and children from UI file loadUi(ui_file, self._widget) # Give QObjects reasonable names self._widget.setObjectName('MyPluginUi') # Show _widget.windowTitle on left-top of each plugin (when # it's set in _widget). This is useful when you open multiple # plugins at once. Also if you open multiple instances of your # plugin at once, these lines add number to make it easy to # tell from pane to pane. if context.serial_number() > 1: self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number())) # Add widget to the user interface context.add_widget(self._widget)
def __init__(self, context): super(MasterInfo, self).__init__(context) self.initialised = False self.setObjectName('MasterInfo') self._current_dotcode = None self._master_info = rocon_master_info.get_master_info(0.5) # at worst a small timeout here, but perhaps should be run in a thread. self._widget = QWidget() self._widget.setObjectName('RoconMasterInfoUi') rospack = rospkg.RosPack() ui_file = os.path.join(rospack.get_path('rocon_qt_master_info'), 'ui', 'master_info.ui') loadUi(ui_file, self._widget) if context.serial_number() > 1: self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number())) pixmap = QPixmap() pixmap.loadFromData(self._master_info.icon.data, format=self._master_info.icon.format) self._widget.icon_label.setPixmap(pixmap) self._widget.icon_label.resize(pixmap.width(), pixmap.height()) self._widget.info_label.resize(200, pixmap.height()) self._widget.info_label.setText("<b>Name:</b> %s<br/><b>Rocon Version:</b> %s<br/><b>Description:</b> %s" % (self._master_info.name, self._master_info.version, self._master_info.description)) self._widget.adjustSize() context.add_widget(self._widget)
def __init__(self, context): super(GPSPlugin, self).__init__(context) self.setObjectName('GPS') self._widget = QWidget() loadUi(os.path.join(uipath, 'gps.ui'), self._widget) context.add_widget(self._widget) self.waypoint_ecef = rospy.Publisher('/gps_ecef_waypoint', PointStamped) self.tasks = rospy.Publisher('/task_waypoints', PointStamped) rospy.Subscriber('/gps_conv/pos', PointStamped, pos_callback) self._widget.findChild(QPushButton, 'record_entered_waypoint').clicked.connect( self._on_record_entered_clicked) self._widget.findChild(QPushButton, 'record_current_waypoint').clicked.connect( self._on_record_current_clicked) self._widget.findChild(QPushButton, 'publish_waypoint_list').clicked.connect( self._on_pub_list_clicked) self._widget.findChild(QPushButton, 'delete_').clicked.connect( self._on_delete_clicked) self._update_timer = QTimer(self._widget) self._update_timer.timeout.connect(self._on_update) self._update_timer.start(1000) global tasks for i in tasks: self._widget.findChild(QListWidget, 'waypoint_list').addItem( str(i[0]) + ',' + str(i[1][0]) + ',' + str(i[1][1]) + ',' + str(i[1][2]))