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, context): super(Builder, self).__init__(context) self.setObjectName('BeetreeBuilder') # 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('beetree_builder') + '/ui/main.ui' # Load the ui attributes into the main widget loadUi(ui_path, self._widget) self._widget.setObjectName('BeetreeBuilderPluginUi') # 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 setNodeState(self, running_nodes, stopped_nodes, error_nodes): ''' Sets the state of this capability. @param running_nodes: a list with running nodes. @type running_nodes: C{[str]} @param stopped_nodes: a list with not running nodes. @type stopped_nodes: C{[str]} @param error_nodes: a list with nodes having a problem. @type error_nodes: C{[str]} ''' self.setAutoFillBackground(True) self.setBackgroundRole(QPalette.Base) palette = QPalette() if error_nodes: brush = QBrush(QColor(255, 100, 0)) elif running_nodes and stopped_nodes: brush = QBrush(QColor(140, 185, 255)) # 30, 50, 255 elif running_nodes: self.on_button.setFlat(True) self.off_button.setFlat(False) brush = QBrush(QColor(59, 223, 18)) # 59, 223, 18 else: brush = QBrush(QColor(255, 255, 255)) self.on_button.setFlat(False) self.off_button.setFlat(True) palette.setBrush(QPalette.Active, QPalette.Base, brush) brush.setStyle(Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Base, brush) self.setPalette(palette)
def __init__(self, context): super(WorkspaceUI, self).__init__(context) self.setObjectName('Instructor Workspace UI') # 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/workspace.ui' # Load the ui attributes into the main widget loadUi(ui_path, self._widget) self._widget.setObjectName('InstructorWorkspaceUI') self._widget.setWindowTitle('Instructor Workspace UI') # 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: title = self._widget.windowTitle() + (' (%d)' % context.serial_number()) self._widget.setWindowTitle(title) # Add widget to the user interface context.add_widget(self._widget) palette = QPalette() palette.setColor(QPalette.Background, Qt.white) self._widget.setPalette(palette) # Hide things to start with self._widget.fiducial_found_widget.hide() self._widget.add_fiducial_widget.hide() # Connect things self._widget.add_ok_btn.clicked.connect(self.add_ok_event) self._widget.add_cancel_btn.clicked.connect(self.add_cancel_event) self._widget.fiducial_name_edit.textChanged.connect(self.name_entered_event) # Add listener to detect AR markers self.tf_listen = tf.TransformListener() # Add predicator publisher self.pub_predicates = rospy.Publisher('predicator/input', PredicateList) # Clean params for landmarks rospy.loginfo('Cleaning up previous workspace landmark params') params = rospy.get_param_names() landmarks = [p for p in params if "instructor_landmark" in p] rospy.loginfo(landmarks) for marker in landmarks: rospy.loginfo('Removed '+str(marker)) rospy.delete_param(marker) # Add timer self.timer = QtCore.QTimer() self.connect(self.timer, QtCore.SIGNAL("timeout()"), self.update) self.timer.start(100)
def __init__(self, context): super(BTV, self).__init__(context) self._dotcode_sub = None # Give QObjects reasonable names self.setObjectName("BTV") # Create QWidget self._widget = QWidget() # Get path to UI file rp = rospkg.RosPack() ui_file = os.path.join(rp.get_path('behavior_tree_visualizer'), 'resource', 'rqt_dot.ui') # Extend the widget with all attributes and children from UI file loadUi(ui_file, self._widget) # Give QObjects reasonable names self._widget.setObjectName('BTVPluginUi') # 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) self._widget.stop_button.setCheckable(True) self._widget.stop_button.clicked[bool].connect( self._handle_stop_clicked) self._widget.all_nodes_button.setCheckable(True) self._widget.all_nodes_button.clicked[bool].connect( self._handle_all_nodes_clicked) self._widget.show_line_edit.returnPressed.connect( self._handle_show_line_returnPressed) self._widget.show_button.clicked.connect(self._handle_show_clicked) self._widget.centering_button.clicked.connect( self._handle_centering_clicked) self.draw_all_nodes = False self.centering = False self.show_node_name = "" self.set_subscriber()
def __init__(self, parent=None): QTextEdit.__init__(self, parent) self._reader = None self.setAutoFillBackground(False) self.setReadOnly(True) self.setUndoRedoEnabled(False) self.setAutoFormatting(QTextEdit.AutoNone) self.setAcceptRichText(False) # self.textBrowser.document().setMaximumBlockCount(100) p = QPalette() p.setColor(QPalette.Base, Qt.black) p.setColor(QPalette.Text, Qt.white) self.setPalette(p)
def __init__(self, context): super(Dot, self).__init__(context) self._dotcode_sub = None # Give QObjects reasonable names self.setObjectName('Dot') # 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 # Create QWidget self._widget = QWidget() # Get path to UI file which is a sibling of this file # in this example the .ui and .py file are in the same folder ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'rqt_dot.ui') # Extend the widget with all attributes and children from UI file loadUi(ui_file, self._widget) # Give QObjects reasonable names self._widget.setObjectName('DotPluginUi') # 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) self._widget.subscribe_button.setCheckable(True) self._widget.subscribe_button.clicked[bool].connect( self._handle_subscribe_clicked)
def __init__(self, context): super(CalibrationUI, self).__init__(context) self.setObjectName('Instructor Calibration UI') # 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/calibration.ui' # Load the ui attributes into the main widget loadUi(ui_path, self._widget) self._widget.setObjectName('InstructorCalibrationUI') self._widget.setWindowTitle('Instructor Calibration UI') # 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) # Initialize empty set of available markers for each camera for c in range(self.n_cameras): self.camera_marker_frame_names[c] = {} self.cameras_calibrated += [False] # Add listener to detect AR markers self.tf_listen = tf.TransformListener() self.tf_broadcast = tf.TransformBroadcaster() # Add timer self.timer = QtCore.QTimer() self.connect(self.timer, QtCore.SIGNAL("timeout()"), self.update) self.timer.start(100) self._widget.done_btn.clicked.connect(self.done_event) self._widget.recalibrate_btn.clicked.connect(self.recalibrate_event) ### Change Indicator Sample Code --------------------------------------# self._widget.done_btn.setStyleSheet('color:#999999')
def __init__(self, name): super(HiroNXNameLabel, self).__init__() palette = QPalette() self.setStyleSheet( 'font-size: larger; font-weight: bold; color: #ffffff; background-color: darkgreen;' ) self.setText(name)
def __init__(self, context): super(Dot, self).__init__(context) self._dotcode_sub = None # Give QObjects reasonable names self.setObjectName('Dot') # 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 # Create QWidget self._widget = QWidget() # Get path to UI file which is a sibling of this file # in this example the .ui and .py file are in the same folder ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'rqt_dot.ui') # Extend the widget with all attributes and children from UI file loadUi(ui_file, self._widget) # Give QObjects reasonable names self._widget.setObjectName('DotPluginUi') # 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) self._widget.subscribe_button.setCheckable(True) self._widget.subscribe_button.clicked[bool].connect(self._handle_subscribe_clicked)
def __init__(self, widget): super(TopicDataWidget, self).__init__() rospkgPack = rospkg.RosPack() uiFile = os.path.join(rospkgPack.get_path('my_topic_viewer'), 'resource', 'TopicViewer.ui') loadUi(uiFile, self) self._updateTimer = QTimer(self) self._updateTimer.timeout.connect(self.timeoutCallback) self._palette = QPalette() self._palette.setColor() self._widget = widget self._topicName = TOPIC_NAME self._subscriber = None self.subscribeTopic(self._topicName)
def __init__(self, context): super(DotMatViewer, self).__init__(context) self.context = context self.maxrate = 10 self.topic = 'dotcode' self.arrows = False self.width = 2.0 # Create the figure canvas and attach it to the context self.widget = MatPlotWidget() self.widget.setObjectName(self.PLUGIN_TITLE) self.widget.setWindowTitle(self.PLUGIN_TITLE) if context.serial_number() > 1: self.widget.setWindowTitle(self.widget.windowTitle() + (' (%d)' % context.serial_number())) context.add_widget(self.widget) # Set the color palette palette = QPalette () palette.setColor(QPalette.Background, Qt.white) self.widget.setPalette(palette) # Subscribe to the specified topic self.last_update = rospy.get_time() self.sub = rospy.Subscriber(self.topic, String, self.dot_graph_cb)
def setNodeState(self, running_nodes, stopped_nodes, error_nodes): ''' Sets the state of this capability. :param running_nodes: a list with running nodes. :type running_nodes: [str] :param stopped_nodes: a list with not running nodes. :type stopped_nodes: [str] :param error_nodes: a list with nodes having a problem. :type error_nodes: [str] ''' self.setAutoFillBackground(True) self.setBackgroundRole(QPalette.Base) palette = QPalette() if error_nodes: brush = QBrush(QColor(255, 100, 0)) elif running_nodes and stopped_nodes: brush = QBrush(QColor(140, 185, 255)) # 30, 50, 255 elif running_nodes: self.on_button.setFlat(True) self.off_button.setFlat(False) brush = QBrush(QColor(59, 223, 18)) # 59, 223, 18 else: brush = QBrush(QColor(255, 255, 255)) self.on_button.setFlat(False) self.off_button.setFlat(True) palette.setBrush(QPalette.Active, QPalette.Base, brush) brush.setStyle(Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Base, brush) self.setPalette(palette)
def __init__(self, context): super(DotMatViewer, self).__init__(context) self.context = context self.maxrate = 10 self.topic = 'dotcode' self.arrows = False self.width = 2.0 # Create the figure canvas and attach it to the context self.widget = MatPlotWidget() self.widget.setObjectName(self.PLUGIN_TITLE) self.widget.setWindowTitle(self.PLUGIN_TITLE) if context.serial_number() > 1: self.widget.setWindowTitle(self.widget.windowTitle() + (' (%d)' % context.serial_number())) context.add_widget(self.widget) # Set the color palette palette = QPalette() palette.setColor(QPalette.Background, Qt.white) self.widget.setPalette(palette) # Subscribe to the specified topic self.last_update = rospy.get_time() self.sub = rospy.Subscriber(self.topic, String, self.dot_graph_cb)
def __init__(self, context): super(Smach, self).__init__(context) self.initialized = 0 self._dotcode_sub = None self._topic_dict = {} self._update_thread = WorkerThread(self._update_thread_run, self._update_finished) # Give QObjects reasonable names self.setObjectName('Smach') # 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 # Create QWidget self._widget = QWidget() # Get path to UI file which is a sibling of this file # in this example the .ui and .py file are in the same folder ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'rqt_smach.ui') # Extend the widget with all attributes and children from UI file loadUi(ui_file, self._widget) # Give QObjects reasonable names self._widget.ns_refresh_button.setIcon(QIcon.fromTheme('view-refresh')) self._widget.setObjectName('SmachPluginUi') # 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) #Connect widgets with corresponding methods self._widget.namespace_input.currentIndexChanged.connect( self._handle_ns_changed) self._widget.ns_refresh_button.clicked.connect(self.refresh_combo_box) self._widget.restrict_ns.clicked.connect(self.refresh_combo_box) self._widget.ud_path_input.currentIndexChanged.connect( self._handle_ud_path) self._widget.ud_set_initial.clicked.connect(self._handle_ud_set_path) self._widget.ud_text_browser.setReadOnly(1) self._widget.show_implicit_button.clicked.connect( self._handle_show_implicit) self._widget.help_button.setIcon(QIcon.fromTheme('help-contents')) self._widget.help_button.clicked.connect(self._handle_help) self._widget.tree.clicked.connect(self._handle_tree_clicked) #Depth and width spinners: self._widget.depth_input.setRange(-1, 1337) self._widget.depth_input.setValue(-1) self._widget.depth_input.valueChanged.connect(self._set_depth) self._widget.label_width_input.setRange(1, 1337) self._widget.label_width_input.setValue(40) self._widget.label_width_input.valueChanged.connect(self._set_width) self._widget.tree.setColumnCount(1) self._widget.tree.setHeaderLabels(["Containers"]) self._widget.tree.show() self._ns = "" self.refresh_combo_box() # Bind path list self._widget.path_input.currentIndexChanged.connect( self._handle_path_changed) #Keep Combo Boxes sorted self._widget.namespace_input.setInsertPolicy(6) self._widget.path_input.setInsertPolicy(6) self._widget.ud_path_input.setInsertPolicy(6) #Set up mouse actions for xdot widget self._widget.xdot_widget.register_select_callback(self.select_cb) # Create graph data structures # Containers is a map of (container path) -> container proxy self._containers = {} self._top_containers = {} # smach introspection client self._client = smach_ros.IntrospectionClient() self._selected_paths = [] # Message subscribers self._structure_subs = {} self._status_subs = {} # Initialize xdot display state self._path = '/' self._needs_zoom = True self._structure_changed = True self._max_depth = -1 self._show_all_transitions = False self._label_wrapper = textwrap.TextWrapper(40, break_long_words=True) self._graph_needs_refresh = True self._tree_needs_refresh = True self._keep_running = True self._update_server_list() self._update_graph() self._update_tree() # Start a timer to update the server list self._server_timer = QTimer(self) self._server_timer.timeout.connect(self._update_server_list) self._server_timer.start(1000) # Start a timer to update the graph display self._graph_timer = QTimer(self) self._graph_timer.timeout.connect(self._update_graph) self._graph_timer.start(1093) # Start a timer to update the._widget.tree display self._tree_timer = QTimer(self) self._tree_timer.timeout.connect(self._update_tree) self._tree_timer.start(1217)
def __init__(self, context): super(Conman, self).__init__(context) self._dotcode_sub = None self._topic_dict = {} self._update_thread = WorkerThread(self._update_thread_run, self._update_finished) # Give QObjects reasonable names self.setObjectName('Conman') # 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 # Create QWidget self._widget = QWidget() # Get path to UI file which is a sibling of this file # in this example the .ui and .py file are in the same folder ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'rqt_conman.ui') # Extend the widget with all attributes and children from UI file loadUi(ui_file, self._widget) # Give QObjects reasonable names self._widget.ns_refresh_button.setIcon(QIcon.fromTheme('view-refresh')) self._widget.setObjectName('ConmanPluginUi') # 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) #self._widget.subscribe_button.setCheckable(True) self._widget.namespace_input.currentIndexChanged.connect( self._handle_refresh_clicked) self._widget.ns_refresh_button.clicked.connect(self.refresh_combo_box) self._widget.refresh_button.clicked[bool].connect( self._handle_refresh_clicked) self._widget.commit_button.clicked[bool].connect( self._handle_commit_clicked) #self._widget.xdot_widget.connect( #self._widget.xdot_widget, SIGNAL('_update_graph'), self._widget.xdot_widget.set_dotcode) self.update_graph_sig.connect(self._update_graph) self.blocks = {} self.groups = {} self._ns = "" self._actions_connected = False self.enable_widgets(False) self.new_dotcode_data = '' self.update_timer = QTimer(self) self.update_timer.setInterval(50) self.update_timer.timeout.connect(self._update_widgets) #self.update_timer.start() self._get_blocks = None self._set_blocks = None self._blocks_model = QStandardItemModel(0, 4) self._blocks_model.setHeaderData(0, Qt.Horizontal, "") self._blocks_model.setHeaderData(1, Qt.Horizontal, "Action") self._blocks_model.setHeaderData(2, Qt.Horizontal, "State") self._blocks_model.setHeaderData(3, Qt.Horizontal, "Block") self._widget.blocks_table.setModel(self._blocks_model) self._blocks_delegate = BlocksDelegate(self) self._widget.blocks_table.setItemDelegate(self._blocks_delegate) self._blocks_model.itemChanged.connect(self.block_changed) self._groups_model = QStandardItemModel(0, 4) self._groups_model.setHeaderData(0, Qt.Horizontal, "") self._groups_model.setHeaderData(1, Qt.Horizontal, "") self._groups_model.setHeaderData(2, Qt.Horizontal, "") self._groups_model.setHeaderData(3, Qt.Horizontal, "Group") self._widget.groups_table.setModel(self._groups_model) self._groups_delegate = GroupsDelegate(self) self._widget.groups_table.setItemDelegate(self._groups_delegate) self.refresh_combo_box()
import rospy import rospkg from qt_gui.plugin import Plugin from python_qt_binding import loadUi from python_qt_binding.QtWidgets import QWidget from python_qt_binding import QtCore from python_qt_binding.QtGui import QPalette RESP_RATE_TOPIC = 'full_resp_rate' HEART_RATE_TOPIC = 'full_heart_rate' SKIN_TEMP_TOPIC = 'full_skin_temp' VALID_DURATION_SEC = 5.0 OLD_PALETTE = QPalette(QtCore.Qt.black) OFF_NOMINAL_PALETTE = QPalette(QtCore.Qt.red) NOMINAL_PALETTE = QPalette(QtCore.Qt.green) from std_msgs.msg import Float32 class VitalsReadout(Plugin): def __init__(self, context): super(VitalsReadout, self).__init__(context) # Give QObjects reasonable names self.setObjectName('VitalsReadout') # Process standalone plugin command-line arguments from argparse import ArgumentParser parser = ArgumentParser()
def __init__(self, context): super(Smach, self).__init__(context) self.initialized = 0 self._dotcode_sub = None self._topic_dict = {} self._update_thread = WorkerThread(self._update_thread_run, self._update_finished) # Give QObjects reasonable names self.setObjectName('Smach') # 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 # Create QWidget self._widget = QWidget() # Get path to UI file which is a sibling of this file # in this example the .ui and .py file are in the same folder ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'rqt_smach.ui') # Extend the widget with all attributes and children from UI file loadUi(ui_file, self._widget) # Give QObjects reasonable names self._widget.ns_refresh_button.setIcon(QIcon.fromTheme('view-refresh')) self._widget.setObjectName('SmachPluginUi') # 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) #Connect widgets with corresponding methods self._widget.namespace_input.currentIndexChanged.connect(self._handle_ns_changed) self._widget.ns_refresh_button.clicked.connect(self.refresh_combo_box) self._widget.restrict_ns.clicked.connect(self.refresh_combo_box) self._widget.ud_path_input.currentIndexChanged.connect(self._handle_ud_path) self._widget.ud_set_initial.clicked.connect(self._handle_ud_set_path) self._widget.ud_text_browser.setReadOnly(1) self._widget.show_implicit_button.clicked.connect(self._handle_show_implicit) self._widget.help_button.setIcon(QIcon.fromTheme('help-contents')) self._widget.help_button.clicked.connect(self._handle_help) self._widget.tree.clicked.connect(self._handle_tree_clicked) #Depth and width spinners: self._widget.depth_input.setRange(-1, 1337) self._widget.depth_input.setValue(-1) self._widget.depth_input.valueChanged.connect(self._set_depth) self._widget.label_width_input.setRange(1, 1337) self._widget.label_width_input.setValue(40) self._widget.label_width_input.valueChanged.connect(self._set_width) self._widget.tree.setColumnCount(1) self._widget.tree.setHeaderLabels(["Containers"]) self._widget.tree.show() self._ns = "" self.refresh_combo_box() # Bind path list self._widget.path_input.currentIndexChanged.connect( self._handle_path_changed) #Keep Combo Boxes sorted self._widget.namespace_input.setInsertPolicy(6) self._widget.path_input.setInsertPolicy(6) self._widget.ud_path_input.setInsertPolicy(6) #Set up mouse actions for xdot widget self._widget.xdot_widget.register_select_callback(self.select_cb) # Create graph data structures # Containers is a map of (container path) -> container proxy self._containers = {} self._top_containers = {} # smach introspection client self._client = smach_ros.IntrospectionClient() self._selected_paths = [] # Message subscribers self._structure_subs = {} self._status_subs = {} # Initialize xdot display state self._path = '/' self._needs_zoom = True self._structure_changed = True self._max_depth = -1 self._show_all_transitions = False self._label_wrapper = textwrap.TextWrapper(40,break_long_words=True) self._graph_needs_refresh = True self._tree_needs_refresh = True self._keep_running = True self._update_server_list() self._update_graph() self._update_tree() # Start a timer to update the server list self._server_timer = QTimer(self) self._server_timer.timeout.connect(self._update_server_list) self._server_timer.start(1000) # Start a timer to update the graph display self._graph_timer = QTimer(self) self._graph_timer.timeout.connect(self._update_graph) self._graph_timer.start(1093) # Start a timer to update the._widget.tree display self._tree_timer = QTimer(self) self._tree_timer.timeout.connect(self._update_tree) self._tree_timer.start(1217)
class TopicDataWidget(QWidget): def __init__(self, widget): super(TopicDataWidget, self).__init__() rospkgPack = rospkg.RosPack() uiFile = os.path.join(rospkgPack.get_path('my_topic_viewer'), 'resource', 'TopicViewer.ui') loadUi(uiFile, self) self._updateTimer = QTimer(self) self._updateTimer.timeout.connect(self.timeoutCallback) self._palette = QPalette() self._palette.setColor() self._widget = widget self._topicName = TOPIC_NAME self._subscriber = None self.subscribeTopic(self._topicName) def start(self): self._updateTimer.start(1000) def stop(self): self._updateTimer.stop() def timeoutCallback(self): pass # print 'time out' # rqt override def save_settings(self, plugin_settings, instance_settings): instance_settings.set_value('topic_name', self._topicName) def restore_settings(self, plugin_settings, instance_settings): topicName = instance_settings.value('topic_name') try: self._topicName = eval(topicName) except Exception: topicName = None def shutdown_plugin(self): self.unregisterTopic() self.stop() # subscribe topic def subscribeTopic(self, topicName): # msgClass, self._topicName, _ = get_topic_class(topicName) self._subscriber = rospy.Subscriber(TOPIC_NAME, MSG_CLASS, self.messageCallback) def messageCallback(self, msg): self.setDisplayedData(msg.data, TOPIC_NAME) def unregisterTopic(self): if self._subscriber: self._subscriber.unregister() # Qt def setDisplayedData(self, data, name): if isinstance(data, dict): self.displayData(data) else: dictData = {} if name is None: dictData['unknown'] = data elif isinstance(data, list): dictData = dict(zip(name, data)) else: dictData[name] = data self.displayData(dictData) def displayData(self, dictData): for key in dictData.keys(): self.topicLabel.setText(key+': ') self.topicDataLine.setText(str(dictData[key])) self.topicDataLine.setPalette(self._palette)
def __init__(self, context): super(WorkspaceUI, self).__init__(context) self.setObjectName('Instructor Workspace UI') # 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/workspace.ui' # Load the ui attributes into the main widget loadUi(ui_path, self._widget) self._widget.setObjectName('InstructorWorkspaceUI') self._widget.setWindowTitle('Instructor Workspace UI') # 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: title = self._widget.windowTitle() + (' (%d)' % context.serial_number()) self._widget.setWindowTitle(title) # Add widget to the user interface context.add_widget(self._widget) palette = QPalette() palette.setColor(QPalette.Background, Qt.white) self._widget.setPalette(palette) # Hide things to start with self._widget.fiducial_found_widget.hide() self._widget.add_fiducial_widget.hide() # Connect things self._widget.add_ok_btn.clicked.connect(self.add_ok_event) self._widget.add_cancel_btn.clicked.connect(self.add_cancel_event) self._widget.fiducial_name_edit.textChanged.connect( self.name_entered_event) # Add listener to detect AR markers self.tf_listen = tf.TransformListener() # Add predicator publisher self.pub_predicates = rospy.Publisher('predicator/input', PredicateList) # Clean params for landmarks rospy.loginfo('Cleaning up previous workspace landmark params') params = rospy.get_param_names() landmarks = [p for p in params if "instructor_landmark" in p] rospy.loginfo(landmarks) for marker in landmarks: rospy.loginfo('Removed ' + str(marker)) rospy.delete_param(marker) # Add timer self.timer = QtCore.QTimer() self.connect(self.timer, QtCore.SIGNAL("timeout()"), self.update) self.timer.start(100)
def __init__(self, context): super(Conman, self).__init__(context) self._dotcode_sub = None # Give QObjects reasonable names self.setObjectName('Conman') # 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 # Create QWidget self._widget = QWidget() # Get path to UI file which is a sibling of this file # in this example the .ui and .py file are in the same folder ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'rqt_conman.ui') # Extend the widget with all attributes and children from UI file loadUi(ui_file, self._widget) # Give QObjects reasonable names self._widget.setObjectName('ConmanPluginUi') # 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) #self._widget.subscribe_button.setCheckable(True) self._widget.refresh_button.clicked[bool].connect(self._handle_refresh_clicked) self._widget.commit_button.clicked[bool].connect(self._handle_commit_clicked) #self._widget.xdot_widget.connect( #self._widget.xdot_widget, SIGNAL('_update_graph'), self._widget.xdot_widget.set_dotcode) self.update_graph_sig.connect(self._update_graph) self.blocks = { } self.groups = { } self._ns = "" self._actions_connected = False self.enable_widgets(False) self.new_dotcode_data = '' self.update_timer = QTimer(self) self.update_timer.setInterval(50) self.update_timer.timeout.connect(self._update_widgets) #self.update_timer.start() self._get_blocks = None self._set_blocks = None self._blocks_model = QStandardItemModel(0,4) self._blocks_model.setHeaderData(0, Qt.Horizontal, "") self._blocks_model.setHeaderData(1, Qt.Horizontal, "Action") self._blocks_model.setHeaderData(2, Qt.Horizontal, "State") self._blocks_model.setHeaderData(3, Qt.Horizontal, "Block") self._widget.blocks_table.setModel(self._blocks_model) self._blocks_delegate = BlocksDelegate(self) self._widget.blocks_table.setItemDelegate(self._blocks_delegate) self._blocks_model.itemChanged.connect(self.block_changed) self._groups_model = QStandardItemModel(0,4) self._groups_model.setHeaderData(0, Qt.Horizontal, "") self._groups_model.setHeaderData(1, Qt.Horizontal, "") self._groups_model.setHeaderData(2, Qt.Horizontal, "") self._groups_model.setHeaderData(3, Qt.Horizontal, "Group") self._widget.groups_table.setModel(self._groups_model) self._groups_delegate = GroupsDelegate(self) self._widget.groups_table.setItemDelegate(self._groups_delegate)