def generateDescription(self, extended=True): tooltip = '' if self.descr_type or self.descr_name or self.descr: tooltip = ''.join(['<h4>', self.descr_name, '</h4><dl>']) if self.descr_type: tooltip = ''.join([tooltip, '<dt>Type: ', self.descr_type, '</dt></dl>']) if extended: try: from docutils import examples if self.descr: tooltip = ''.join([tooltip, '<b><u>Detailed description:</u></b>']) tooltip = ''.join([tooltip, examples.html_body(self.descr, input_encoding='utf8')]) except: import traceback rospy.logwarn("Error while generate description for a tooltip: %s", str(traceback.format_exc())) tooltip = ''.join([tooltip, '<br>']) tooltip = ''.join([tooltip, '<h4>ROS Master URI: ', self.id[0], '</h4>']) tooltip = ''.join([tooltip, '<h4>Host: ', self.id[1], '</h4>']) # get sensors capabilities = [] for j in range(self.rowCount()): item = self.child(j) if isinstance(item, GroupItem): capabilities.append(item.name) if capabilities: tooltip = ''.join([tooltip, '<b><u>Capabilities:</u></b>']) try: from docutils import examples tooltip = ''.join([tooltip, examples.html_body(''.join(['- ', '\n- '.join(capabilities)]), input_encoding='utf8')]) except: import traceback rospy.logwarn("Error while generate description for a tooltip: %s", str(traceback.format_exc())) return ''.join(['<div>', tooltip, '</div>']) if tooltip else ''
def updateTooltip(self): ''' Creates a tooltip description based on text set by L{updateDescription()} and all childs of this host with valid sensor description. The result is returned as a HTML part. @return: the tooltip description coded as a HTML part @rtype: C{str} ''' tooltip = '' if self.descr_type or self.descr_name or self.descr: tooltip = ''.join(['<h4>', self.descr_name, '</h4><dl>']) tooltip = ''.join( [tooltip, '<dt>Type: ', self.descr_type, '</dt></dl>']) tooltip = ''.join([tooltip, '<b><u>Detailed description:</u></b>']) if self.descr: try: from docutils import examples tooltip = ''.join([ tooltip, examples.html_body(self.descr, input_encoding='utf8') ]) except: import traceback rospy.logwarn( "Error while generate description for a tooltip: %s", str(traceback.format_exc())) # get sensors sensors = [] for j in range(self.rowCount()): nodeItem = self.child(j) if nodeItem.node.descr_name: sensor = nodeItem.node.descr_name if nodeItem.node.descr_type: sensor = ' '.join( [sensor, '(', nodeItem.node.descr_type, ')']) sensors.append(sensor) if sensors: tooltip = ''.join([tooltip, '<b><u>sensors:</u></b>']) try: from docutils import examples tooltip = ''.join([ tooltip, examples.html_body(''.join(['- ', '\n- '.join(sensors)]), input_encoding='utf8') ]) except: import traceback rospy.logwarn( "Error while generate description for a tooltip: %s", str(traceback.format_exc())) self.setToolTip(''.join(['<html><body>', tooltip, '</body></html>'] ) if tooltip else self.name) return ''.join(['<div>', tooltip, '</div>']) if tooltip else ''
def updateTooltip(self): ''' Creates a tooltip description based on text set by L{updateDescription()} and all childs of this host with valid sensor description. The result is returned as a HTML part. @return: the tooltip description coded as a HTML part @rtype: C{str} ''' tooltip = '' if self.descr_type or self.descr_name or self.descr: tooltip = ''.join(['<h4>', self.descr_name, '</h4><dl>']) tooltip = ''.join([tooltip, '<dt>Type: ', self.descr_type, '</dt></dl>']) tooltip = ''.join([tooltip, '<b><u>Detailed description:</u></b>']) if self.descr: try: from docutils import examples tooltip = ''.join([tooltip, examples.html_body(self.descr, input_encoding='utf8')]) except: import traceback rospy.logwarn("Error while generate description for a tooltip: %s", str(traceback.format_exc())) # get sensors sensors = [] for j in range(self.rowCount()): nodeItem = self.child(j) if nodeItem.node.descr_name: sensor = nodeItem.node.descr_name if nodeItem.node.descr_type: sensor = ' '.join([sensor, '(', nodeItem.node.descr_type, ')']) sensors.append(sensor) if sensors: tooltip = ''.join([tooltip, '<b><u>sensors:</u></b>']) try: from docutils import examples tooltip = ''.join([tooltip, examples.html_body(''.join(['- ', '\n- '.join(sensors)]), input_encoding='utf8')]) except: import traceback rospy.logwarn("Error while generate description for a tooltip: %s", str(traceback.format_exc())) self.setToolTip(''.join(['<html><body>', tooltip, '</body></html>']) if tooltip else self.name) return ''.join(['<div>', tooltip, '</div>']) if tooltip else ''
def updateDispayedName(self, item, show_ros_names): ''' Updates the name representation of the given QStandardItem @param item: item which represent the URI @type item: L{PySide.QtGui.QStandardItem} @param show_ros_names: show the as ROS names or as their description. @type show_ros_names: C{bool} ''' if self.descr_name and not show_ros_names: item.setText(self.descr_name) else: item.setText(NodeItem.toHTML(self.name)) tooltip = ''.join(['<html><body><h4>', self.name, '</h4><dl>']) tooltip = ''.join([tooltip, '<dt>PID: ', str(self.pid), '</dt></dl>']) uri = nm.nameres().getUri(host=nm.nameres().getHostname(self.uri)) master_discovered = (not uri is None) local = (nm.nameres().getHostname(self.uri) == nm.nameres().getHostname(self.masteruri)) if not self.pid is None: item.setIcon(QtGui.QIcon(':/icons/state_run.png')) elif not local and not master_discovered and not self.uri is None: item.setIcon(QtGui.QIcon(':/icons/state_run.png')) tooltip = ''.join([tooltip, '<dl><dt>(Remote nodes will not be ping, so they are always marked running)</dt></dl>']) # elif not master_discovered and not self.uri is None: # item.setIcon(QtGui.QIcon(':/icons/state_run.png')) elif not self.uri is None: item.setIcon(QtGui.QIcon(':/icons/crystal_clear_warning.png')) if not local and master_discovered: tooltip = ''.join(['<h4>', self.name, ' is not local, however the ROS master on this host is discovered, but no information about this node received!', '</h4>']) else: item.setIcon(QtGui.QIcon()) if self.descr_type or self.descr_name or self.descr: tooltip = ''.join([tooltip, '<b><u>Detailed description:</u></b>']) if self.descr_type: tooltip = ''.join([tooltip, '<dl><dt><b>Sensor type:</b> ', self.descr_type, '</dt>']) if self.descr_name: tooltip = ''.join([tooltip, '<dt><b>Sensor name:</b> ', self.descr_name, '</dt></dl>']) if self.descr: try: from docutils import examples tooltip = ''.join([tooltip, examples.html_body(self.descr, input_encoding='utf8')]) except: import traceback rospy.logwarn("Error while generate description for a node: %s", str(traceback.format_exc())) tooltip = ''.join([tooltip, '</dl></body></html>']) item.setToolTip(tooltip)
def mousePressEvent(self, event): ''' Interpret the mouse events to send the description of a robot or capability if the user click on the header. ''' QtGui.QHeaderView.mousePressEvent(self, event) index = self.logicalIndexAt(event.pos()) if index in range(len(self._data)): suffix = 'Capability' if self.orientation() == QtCore.Qt.Horizontal: suffix = 'Robot' title = ' - '.join([self._data[index]['name'], suffix]) text = self._data[index]['description'] try: from docutils import examples text = examples.html_body(text) except: import traceback rospy.logwarn("Error while generate description for %s: %s", self._data[index]['name'], traceback.format_exc()) self.description_requested_signal.emit(title, text)
def mousePressEvent(self, event): ''' Interpret the mouse events to send the description of a robot or capability if the user click on the header. ''' QtGui.QHeaderView.mousePressEvent(self, event) index = self.logicalIndexAt(event.pos()) if index in range(len(self._data)): suffix = 'Capability' if self.orientation() == QtCore.Qt.Horizontal: suffix = 'Robot' title = ' - '.join([self._data[index]['name'], suffix]) text = self._data[index]['description'] try: from docutils import examples text = examples.html_body(text) except: import traceback rospy.logwarn("Error while generate description for %s: %s", self._data[index]['name'], str(traceback.format_exc())) self.description_requested_signal.emit(title, text)
def generateDescription(self, extended=True): tooltip = '' if self.descr_type or self.descr_name or self.descr: tooltip = ''.join(['<h4>', self.descr_name, '</h4><dl>']) if self.descr_type: tooltip = ''.join([tooltip, '<dt>Type: ', self.descr_type, '</dt></dl>']) if extended: try: from docutils import examples if self.descr: tooltip = ''.join([tooltip, '<b><u>Detailed description:</u></b>']) tooltip = ''.join([tooltip, examples.html_body(self.descr)]) except: import traceback rospy.logwarn("Error while generate description for a tooltip: %s", str(traceback.format_exc())) tooltip = ''.join([tooltip, '<br>']) # get nodes nodes = [] for j in range(self.rowCount()): nodes.append(self.child(j).name) if nodes: tooltip = ''.join([tooltip, self._create_html_list('Nodes:', nodes)]) return ''.join(['<div>', tooltip, '</div>']) if tooltip else ''
def rst_to_html(value): return html_body(value)
def updateDispayedName(self, item, show_ros_names): ''' Updates the name representation of the given QStandardItem @param item: item which represent the URI @type item: L{PySide.QtGui.QStandardItem} @param show_ros_names: show the as ROS names or as their description. @type show_ros_names: C{bool} ''' if self.descr_name and not show_ros_names: item.setText(self.descr_name) else: item.setText(NodeItem.toHTML(self.name)) tooltip = ''.join(['<html><body><h4>', self.name, '</h4><dl>']) tooltip = ''.join([tooltip, '<dt>PID: ', str(self.pid), '</dt></dl>']) uri = nm.nameres().getUri(host=nm.nameres().getHostname(self.uri)) master_discovered = (not uri is None) local = (nm.nameres().getHostname( self.uri) == nm.nameres().getHostname(self.masteruri)) if not self.pid is None: item.setIcon(QtGui.QIcon(':/icons/state_run.png')) elif not local and not master_discovered and not self.uri is None: item.setIcon(QtGui.QIcon(':/icons/state_run.png')) tooltip = ''.join([ tooltip, '<dl><dt>(Remote nodes will not be ping, so they are always marked running)</dt></dl>' ]) # elif not master_discovered and not self.uri is None: # item.setIcon(QtGui.QIcon(':/icons/state_run.png')) elif not self.uri is None: item.setIcon(QtGui.QIcon(':/icons/crystal_clear_warning.png')) if not local and master_discovered: tooltip = ''.join([ '<h4>', self.name, ' is not local, however the ROS master on this host is discovered, but no information about this node received!', '</h4>' ]) else: item.setIcon(QtGui.QIcon()) if self.descr_type or self.descr_name or self.descr: tooltip = ''.join([tooltip, '<b><u>Detailed description:</u></b>']) if self.descr_type: tooltip = ''.join([ tooltip, '<dl><dt><b>Sensor type:</b> ', self.descr_type, '</dt>' ]) if self.descr_name: tooltip = ''.join([ tooltip, '<dt><b>Sensor name:</b> ', self.descr_name, '</dt></dl>' ]) if self.descr: try: from docutils import examples tooltip = ''.join([ tooltip, examples.html_body(self.descr, input_encoding='utf8') ]) except: import traceback rospy.logwarn( "Error while generate description for a node: %s", str(traceback.format_exc())) tooltip = ''.join([tooltip, '</dl></body></html>']) item.setToolTip(tooltip)
def _getHTML( self, text ): return examples.html_body( text )