示例#1
0
    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)
示例#2
0
 def on_topic_control_btn_clicked(self):
     try:
         if self.sub is None and self.ssh_output_file is None:
             if self.__msg_class:
                 self.sub = rospy.Subscriber(self.topic, self.__msg_class,
                                             self._msg_handle)
             else:
                 self._on_display_anchorClicked(QUrl(self._masteruri))
             self.topic_control_button.setText('stop')
             self.topic_control_button.setIcon(
                 QIcon(':/icons/deleket_deviantart_stop.png'))
         else:
             if self.sub is not None:
                 self.sub.unregister()
                 self.sub = None
             elif self.ssh_output_file is not None:
                 self.ssh_output_file.close()
                 self.ssh_error_file.close()
                 self.ssh_output_file = None
             self.topic_control_button.setText('play')
             self.topic_control_button.setIcon(
                 QIcon(':/icons/deleket_deviantart_play.png'))
             self.no_str_checkbox.setEnabled(True)
             self.no_arr_checkbox.setEnabled(True)
     except Exception as e:
         rospy.logwarn('Error while stop/play echo for topic %s: %s' %
                       (self.topic, e))
示例#3
0
    def __init__(self, context):
        """
        Constructor
        """
        super(CarlaControlPlugin, self).__init__(context)
        self.setObjectName('CARLA Control')

        self._widget = QWidget()

        self._node = CompatibleNode('rqt_carla_control_node')

        package_share_dir = roscomp.get_package_share_directory(
            'rqt_carla_control')
        ui_file = os.path.join(package_share_dir, 'resource',
                               'CarlaControl.ui')

        loadUi(ui_file, self._widget)
        self._widget.setObjectName('CarlaControl')
        if context.serial_number() > 1:
            self._widget.setWindowTitle(self._widget.windowTitle() +
                                        (' (%d)' % context.serial_number()))

        self.pause_icon = QIcon(
            QPixmap(os.path.join(package_share_dir, 'resource', 'pause.png')))
        self.play_icon = QIcon(
            QPixmap(os.path.join(package_share_dir, 'resource', 'play.png')))
        self._widget.pushButtonStepOnce.setIcon(
            QIcon(
                QPixmap(
                    os.path.join(package_share_dir, 'resource',
                                 'step_once.png'))))

        self.carla_status = None
        self.carla_status_subscriber = self._node.new_subscription(
            CarlaStatus,
            "/carla/status",
            self.carla_status_changed,
            qos_profile=10)

        self.carla_control_publisher = self._node.new_publisher(
            CarlaControl, "/carla/control", qos_profile=10)

        self._widget.pushButtonPlayPause.setDisabled(True)
        self._widget.pushButtonStepOnce.setDisabled(True)
        self._widget.pushButtonPlayPause.setIcon(self.play_icon)
        self._widget.pushButtonPlayPause.clicked.connect(
            self.toggle_play_pause)
        self._widget.pushButtonStepOnce.clicked.connect(self.step_once)

        context.add_widget(self._widget)

        if roscomp.get_ros_version() == 2:
            spin_thread = threading.Thread(target=self._node.spin, daemon=True)
            spin_thread.start()
示例#4
0
    def make_icon(self, image_list, mode=QIcon.Normal, state=QIcon.On):
        """
        Helper function to create QIcons from lists of image files
        Warning: svg files interleaved with other files will not render correctly

        :param image_list: list of image paths to layer into an icon.
        :type image: list of str
        :param mode: The mode of the QIcon to be created.
        :type mode: int
        :param state: the state of the QIcon to be created.
        :type state: int
        """
        if type(image_list) is not list:
            image_list = [image_list]
        if len(image_list) <= 0:
            raise TypeError('The list of images is empty.')

        num_svg = 0
        for item in image_list:
            if item[-4:].lower() == '.svg':
                num_svg = num_svg + 1

        if num_svg != len(image_list):
            # Legacy support for non-svg images
            icon_pixmap = QPixmap()
            icon_pixmap.load(image_list[0])
            painter = QPainter(icon_pixmap)
            for item in image_list[1:]:
                painter.drawPixmap(0, 0, QPixmap(item))
            icon = QIcon()
            icon.addPixmap(icon_pixmap, mode, state)
            painter.end()
            return icon
        else:
            #  rendering SVG files into a QImage
            renderer = QSvgRenderer(image_list[0])
            icon_image = QImage(renderer.defaultSize(), QImage.Format_ARGB32)
            icon_image.fill(0)
            painter = QPainter(icon_image)
            renderer.render(painter)
            if len(image_list) > 1:
                for item in image_list[1:]:
                    renderer.load(item)
                    renderer.render(painter)
            painter.end()
            #  Convert QImage into a pixmap to create the icon
            icon_pixmap = QPixmap()
            icon_pixmap.convertFromImage(icon_image)
            icon = QIcon(icon_pixmap)
            return icon
示例#5
0
def rocon_icon_to_qicon(icon):
    """
    :param rocon_std_msgs.Icon icon: icon to use for the pixmap
    """
    pixmap = QPixmap()
    pixmap.loadFromData(icon.data, format=icon.format)
    return QIcon(pixmap)
示例#6
0
 def __init__(self, tabwidget, parent=None):
     QDockWidget.__init__(self, "LaunchGraph", parent)
     graph_ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'GraphDockWidget.ui')
     loadUi(graph_ui_file, self)
     self.setObjectName('LaunchGraph')
     self.setFeatures(QDockWidget.DockWidgetMovable | QDockWidget.DockWidgetFloatable)
     self._info_icon = QIcon(":/icons/info.png")
     self._tabwidget = tabwidget
     self._current_path = None
     self._root_path = None
     self._current_deep = 0
     self.graphTreeView.setSelectionBehavior(QAbstractItemView.SelectRows)
     model = QStandardItemModel()
     self.graphTreeView.setModel(model)
     self.graphTreeView.setUniformRowHeights(True)
     self.graphTreeView.header().hide()
     self.htmlDelegate = HTMLDelegate(palette=self.palette())
     self.graphTreeView.setItemDelegateForColumn(0, self.htmlDelegate)
     self.graphTreeView.activated.connect(self.on_activated)
     self.graphTreeView.clicked.connect(self.on_clicked)
     self._created_tree = False
     self.has_none_packages = True
     self.has_warnings = False
     self._refill_tree([], False)
     self._fill_graph_thread = None
示例#7
0
    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)
示例#8
0
 def _update_icon(self):
     if self.id in [self.NOTHING, self.NOT_FOUND]:
         return
     icon_pixmap = ''
     if self.id == self.FOLDER:
         icon_pixmap = nm.settings().pixmap('crystal_clear_folder.png')
     elif self.id == self.PACKAGE:
         icon_pixmap = nm.settings().pixmap('crystal_clear_package.png')
     elif self.id == self.LAUNCH_FILE:
         icon_pixmap = nm.settings().pixmap('crystal_clear_launch_file.png')
     elif self.id == self.RECENT_FILE:
         icon_pixmap = nm.settings().pixmap(
             'crystal_clear_launch_file_recent.png')
     elif self.id == self.STACK:
         icon_pixmap = nm.settings().pixmap('crystal_clear_stack.png')
     elif self.id == self.PROFILE:
         icon_pixmap = nm.settings().pixmap('crystal_clear_profile.png')
     elif self.id == self.RECENT_PROFILE:
         icon_pixmap = nm.settings().pixmap(
             'crystal_clear_profile_recent.png')
     elif self.id == self.REMOTE_DAEMON:
         icon_pixmap = nm.settings().pixmap('stock_connect.png')
     elif self.id == self.ROOT:
         icon_pixmap = nm.settings().pixmap('back.png')
     if icon_pixmap:
         self.setIcon(QIcon(icon_pixmap.scaled(16, 16)))
    def __init__(self, context):
        super(LaunchtreeWidget, self).__init__()

        self._rp = rospkg.RosPack()
        self._rp_package_list = self._rp.list()
        res_folder = os.path.join(self._rp.get_path('rqt_launchtree'),
                                  'resource')
        ui_file = os.path.join(res_folder, 'launchtree_widget.ui')
        loadUi(ui_file, self)

        self._block_load = True

        self.editor = 'gedit'  # configure via settings

        self.setObjectName('LaunchtreeWidget')
        self.reload_button.setIcon(QIcon.fromTheme('view-refresh'))

        self._properties_empty_ui = os.path.join(res_folder,
                                                 'properties_empty.ui')
        self._properties_param_ui = os.path.join(res_folder,
                                                 'properties_param.ui')

        self._icon_include = QIcon(os.path.join(res_folder, 'img/include.png'))
        self._icon_node = QIcon(os.path.join(res_folder, 'img/node.png'))
        self._icon_param = QIcon(os.path.join(res_folder, 'img/param.png'))
        self._icon_arg = QIcon(os.path.join(res_folder, 'img/arg.png'))
        self._icon_remap = QIcon(os.path.join(res_folder, 'img/remap.png'))
        self._icon_rosparam = QIcon(
            os.path.join(res_folder, 'img/rosparam_load.png'))
        self._icon_default = QIcon(os.path.join(res_folder, 'img/default.png'))
        self._icon_warn = QIcon(os.path.join(res_folder, 'img/warn.png'))
        self._launch_separator = '  --  '
        self._highlight_color = QColor(255, 255, 150)
        self._neutral_color = QColor(255, 255, 255, 0)

        # connect signals
        self.update_launch_view.connect(self._update_launch_view)
        self.display_load_error.connect(self._display_load_error)
        self.package_select.currentIndexChanged.connect(
            self.update_launchfiles)
        self.launchfile_select.currentIndexChanged.connect(
            lambda idx: self.load_launchfile())
        self.reload_button.clicked.connect(self.load_launchfile)
        self.open_button.clicked.connect(self._root_open_clicked)
        self.launch_view.currentItemChanged.connect(self.launch_entry_changed)
        self.filter_nodes.toggled.connect(lambda t: self._filter_launch_view())
        self.filter_params.toggled.connect(
            lambda t: self._filter_launch_view())
        self.filter_args.toggled.connect(lambda t: self._filter_launch_view())
        self.filter_remaps.toggled.connect(
            lambda t: self._filter_launch_view())
        self.filter_empty.toggled.connect(lambda t: self._filter_launch_view())
        self.search_input.textChanged.connect(
            lambda t: self._filter_launch_view(collapse=t == ''))
        self.launch_open_button.clicked.connect(self._launch_open_clicked)

        self.reset()
    def __init__(self, parent=None):
        super(AeropendulumWidget, self).__init__(parent)

        ui_file = os.path.join(rospkg.RosPack().get_path('rqt_gui_aeropendulum'), 'resource', 'MyPlugin.ui')
        loadUi(ui_file, self)
        self.figure = Figure(facecolor = 'w')
        self.ax = self.figure.add_subplot(111)
        self.canvas = FigureCanvas(self.figure)
        self.toolbar = NavigationToolbar(self.canvas, self)
        self.graphLayout.addWidget(self.toolbar)
        self.graphLayout.addWidget(self.canvas)

        self.setPointInput.setMaxLength(5)
        self.setPointInput.setValidator(QDoubleValidator(0.00, MAX_ANGLE, 2))

        self.kpInput.setValidator(QDoubleValidator())
        self.kiInput.setValidator(QDoubleValidator())
        self.kdInput.setValidator(QDoubleValidator())

        self.setPointSlider.setMinimum(0)
        self.setPointSlider.setMaximum(MAX_ANGLE)
        self.setPointSlider.setValue(0)
        
        # Set icons images
        dirName = os.path.dirname(__file__)
        currentFolderRelativePath = '../../resource/icons/'

        connectIconName = 'link.svg'
        connectIconPath = os.path.normpath(os.path.join(dirName, currentFolderRelativePath, connectIconName))
        self.connectButton.setIcon(QIcon(connectIconPath))
        self.connectButton.setToolTip("Estabelece conexao")

        stepResponseIconName = 'graphs.svg'
        stepResponseIconPath = os.path.normpath(os.path.join(dirName, currentFolderRelativePath, stepResponseIconName))
        self.stepResponseButton.setIcon(QIcon(stepResponseIconPath))
        self.stepResponseButton.setToolTip("Aplica um degrau ao sistema")

        csvIconName = 'csv.svg'
        csvIconPath = os.path.normpath(os.path.join(dirName, currentFolderRelativePath, csvIconName))
        self.csvButton.setIcon(QIcon(csvIconPath))
        self.csvButton.setToolTip("Cria arquivos CSV")

        calibrationIconName = 'target.svg'
        calibrationIconPath = os.path.normpath(os.path.join(dirName, currentFolderRelativePath, calibrationIconName))
        self.calibrationButton.setIcon(QIcon(calibrationIconPath))
        self.calibrationButton.setToolTip("Calibracao do ponto zero")
示例#11
0
 def create_application(self, argv):
     from python_qt_binding.QtGui import QIcon
     app = super(Main, self).create_application(argv)
     logo = os.path.join(self._ros_pack.get_path('rqt_gui'), 'resource',
                         'rqt.png')
     icon = QIcon(logo)
     app.setWindowIcon(icon)
     return app
示例#12
0
    def __init__(self, context):
        """
        Constructor
        """
        super(CarlaControlPlugin, self).__init__(context)
        self.setObjectName('CARLA Control')

        self._widget = QWidget()
        ui_file = os.path.join(rospkg.RosPack().get_path('rqt_carla_control'),
                               'resource', 'CarlaControl.ui')
        loadUi(ui_file, self._widget)
        self._widget.setObjectName('CarlaControl')
        if context.serial_number() > 1:
            self._widget.setWindowTitle(self._widget.windowTitle() +
                                        (' (%d)' % context.serial_number()))

        self.pause_icon = QIcon(
            QPixmap(
                os.path.join(rospkg.RosPack().get_path('rqt_carla_control'),
                             'resource', 'pause.png')))
        self.play_icon = QIcon(
            QPixmap(
                os.path.join(rospkg.RosPack().get_path('rqt_carla_control'),
                             'resource', 'play.png')))
        self._widget.pushButtonStepOnce.setIcon(
            QIcon(
                QPixmap(
                    os.path.join(
                        rospkg.RosPack().get_path('rqt_carla_control'),
                        'resource', 'step_once.png'))))

        self.carla_status = None
        self.carla_status_subscriber = rospy.Subscriber(
            "/carla/status", CarlaStatus, self.carla_status_changed)
        self.carla_control_publisher = rospy.Publisher("/carla/control",
                                                       CarlaControl,
                                                       queue_size=10)

        self._widget.pushButtonPlayPause.setDisabled(True)
        self._widget.pushButtonStepOnce.setDisabled(True)
        self._widget.pushButtonPlayPause.setIcon(self.play_icon)
        self._widget.pushButtonPlayPause.clicked.connect(
            self.toggle_play_pause)
        self._widget.pushButtonStepOnce.clicked.connect(self.step_once)

        context.add_widget(self._widget)
 def update_embedded_widget_icon(self, widget_object_name, icon_str):
     embed_container = self._embed_containers[widget_object_name]
     # deserialize icon base64-encoded string
     ba = QByteArray.fromBase64(icon_str)
     s = QDataStream(ba, QIODevice.ReadOnly)
     icon = QIcon()
     s >> icon
     embed_container.setWindowIcon(icon)
示例#14
0
 def __init__(self, name, path, lid, parent=None):
     '''
     Initialize the topic item.
     @param name: the topic name
     @type name: C{str}
     '''
     QStandardItem.__init__(self, name)
     self.parent_item = parent
     self.name = name
     self.path = path
     self.package_name = package_name(os.path.dirname(self.path))[0]
     self.id = lid
     if self.id == LaunchItem.FOLDER:
         self.setIcon(QIcon(":/icons/crystal_clear_folder.png"))
     elif self.id == LaunchItem.PACKAGE:
         self.setIcon(QIcon(":/icons/crystal_clear_package.png"))
     elif self.id == LaunchItem.LAUNCH_FILE:
         self.setIcon(QIcon(":/icons/crystal_clear_launch_file.png"))
     elif self.id == LaunchItem.RECENT_FILE:
         self.setIcon(QIcon(":/icons/crystal_clear_launch_file_recent.png"))
     elif self.id == LaunchItem.STACK:
         self.setIcon(QIcon(":/icons/crystal_clear_stack.png"))
     elif self.id == LaunchItem.PROFILE:
         self.setIcon(QIcon(":/icons/crystal_clear_profile.png"))
     elif self.id == LaunchItem.RECENT_PROFILE:
         self.setIcon(QIcon(":/icons/crystal_clear_profile_recent.png"))
示例#15
0
def get_icon(name, type_=None, base_path=None):
    if type_ == 'file' or type_ is None:
        path = name
        if base_path is not None:
            path = os.path.join(base_path, path)
        icon = QIcon(path)
        if len(icon.availableSizes()) == 0:
            raise UserWarning('icon "%s" not found' % str(path))
    elif type_ == 'resource':
        icon = QIcon(name)
        if len(icon.availableSizes()) == 0:
            raise UserWarning('icon "%s" not found' % str(path))
    elif type_ == 'theme':
        # see http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
        icon = QIcon.fromTheme(name)
    else:
        raise UserWarning('unknown icon type "%s"' % str(type_))
    return icon
示例#16
0
    def _add_rocon_master_list_item(self, rocon_master):

        rocon_master.current_row = str(self._widget_main.list_widget.count())

        display_name = str(rocon_master.name) + "\n" + "[" + str(
            rocon_master.uri) + "]"
        self._widget_main.list_widget.insertItem(
            self._widget_main.list_widget.count(), display_name)

        #setting the list font

        font = self._widget_main.list_widget.item(
            self._widget_main.list_widget.count() - 1).font()
        font.setPointSize(13)
        self._widget_main.list_widget.item(
            self._widget_main.list_widget.count() - 1).setFont(font)

        #setToolTip
        rocon_master_info = ""
        rocon_master_info += "rocon_master_index: " + str(
            rocon_master.index) + "\n"
        rocon_master_info += "rocon_master_name: " + str(
            rocon_master.name) + "\n"
        rocon_master_info += "master_uri:  " + str(rocon_master.uri) + "\n"
        rocon_master_info += "host_name:  " + str(
            rocon_master.host_name) + "\n"
        rocon_master_info += "description:  " + str(rocon_master.description)
        self._widget_main.list_widget.item(
            self._widget_main.list_widget.count() -
            1).setToolTip(rocon_master_info)

        #set icon
        if rocon_master.icon == "unknown.png":
            icon = QIcon(self.icon_paths['unknown'])
            self._widget_main.list_widget.item(
                self._widget_main.list_widget.count() - 1).setIcon(icon)
        elif len(rocon_master.icon):
            icon = QIcon(
                os.path.join(utils.get_icon_cache_home(), rocon_master.icon))
            self._widget_main.list_widget.item(
                self._widget_main.list_widget.count() - 1).setIcon(icon)
        else:
            console.logdebug("%s : No icon" % rocon_master.name)
        pass
示例#17
0
    def refresh_interactions_list(self):
        """
        This just does a complete redraw of the interactions with the
        currently selected role. It's a bit brute force doing this
        every time the interactions' 'state' changes, but this suffices for now.
        """
        console.logdebug(
            "Interactions Chooser : refreshing the interactions list")
        self.interactions = self.interactive_client_interface.interactions(
            self.cur_selected_role)
        self.interactions_widget.interactions_list_widget.clear()
        index = 0
        for interaction in self.interactions.values():
            interaction.index = index
            index = index + 1

            self.interactions_widget.interactions_list_widget.insertItem(
                0, interaction.display_name)

            # is it a currently running pairing
            if self.interactive_client_interface.pairing == interaction.hash:
                self.interactions_widget.interactions_list_widget.item(
                    0).setBackground(QColor(100, 100, 150))

            # setting the list font
            font = self.interactions_widget.interactions_list_widget.item(
                0).font()
            font.setPointSize(13)
            self.interactions_widget.interactions_list_widget.item(0).setFont(
                font)

            # setting the icon
            icon = interaction.icon
            if icon == "unknown.png":
                icon = QIcon(self.icon_paths['unknown'])
                self.interactions_widget.interactions_list_widget.item(
                    0).setIcon(icon)
            elif len(icon):
                icon = QIcon(os.path.join(utils.get_icon_cache_home(), icon))
                self.interactions_widget.interactions_list_widget.item(
                    0).setIcon(icon)
            else:
                console.logdebug("%s : No icon" % str(self.rocon_master_name))
 def __init__(self, master):
     QObject.__init__(self)
     self.name = master.name
     self._master = master
     self._syncronized = MasterSyncButtonHelper.NOT_SYNC
     self.ICONS = {
         MasterSyncButtonHelper.SYNC:
         QIcon(":/icons/%s_sync.png" % self.ICON_PREFIX),
         MasterSyncButtonHelper.NOT_SYNC:
         QIcon(":/icons/%s_not_sync.png" % self.ICON_PREFIX),
         MasterSyncButtonHelper.SWITCHED:
         QIcon(":/icons/%s_start_sync.png" % self.ICON_PREFIX)
     }
     self.widget = QPushButton()
     #    self.widget.setFlat(True)
     self.widget.setIcon(self.ICONS[MasterSyncButtonHelper.NOT_SYNC])
     self.widget.setMaximumSize(48, 48)
     self.widget.setCheckable(True)
     self.widget.clicked.connect(self.on_sync_clicked)
示例#19
0
 def on_topic_control_btn_clicked(self):
     try:
         if self.sub is None and self.ssh_output_file is None:
             if self.__msg_class:
                 self.sub = rospy.Subscriber(self.topic, self.__msg_class, self._msg_handle)
                 self._start_time = time.time()
             else:
                 self._on_display_anchorClicked(QUrl(self._masteruri))
             self.topicControlButton.setIcon(QIcon(':/icons/sekkyumu_stop.png'))
         else:
             if self.sub is not None:
                 self.sub.unregister()
                 self.sub = None
             elif self.ssh_output_file is not None:
                 self.ssh_output_file.close()
                 self.ssh_error_file.close()
                 self.ssh_output_file = None
             self.topicControlButton.setIcon(QIcon(':/icons/sekkyumu_play.png'))
     except Exception as e:
         rospy.logwarn('Error while stop/play echo for topic %s: %s' % (self.topic, utf8(e)))
示例#20
0
    def __init__(self, parent=None):
        QLineEdit.__init__(self, parent=None)
        self.process_active = False
        # create a reload button with icon
        self.button_reload = button_reload = QToolButton(self)
        icon = QIcon.fromTheme("view-refresh",
                               QIcon(":/icons/oxygen_view_refresh.png"))
        button_reload.setIcon(icon)
        button_reload.setCursor(Qt.ArrowCursor)
        button_reload.setStyleSheet(
            "QToolButton { border: none; padding: 0px; }")

        # create a stop button with icon
        self.button_stop = button_stop = QToolButton(self)
        icon = QIcon.fromTheme("process-stop",
                               QIcon(":/icons/oxygen_view_refresh.png"))
        button_stop.setIcon(icon)
        button_stop.setCursor(Qt.ArrowCursor)
        button_stop.setStyleSheet(
            "QToolButton { border: none; padding: 0px; }")
        button_stop.hide()

        # signals, clear lineEdit if btn pressed; change btn visibility on input
        button_reload.clicked.connect(self._emit_refresh_text)
        self.textChanged[str].connect(self.update_close_button)
        button_stop.clicked.connect(self._process_stop)

        frameWidth = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth)
        self.setStyleSheet("QLineEdit { padding-right: %dpx; } " %
                           (button_reload.sizeHint().width() + frameWidth + 1))
        msz = self.minimumSizeHint()
        self.setMinimumSize(
            max(msz.width(),
                button_reload.sizeHint().height() + frameWidth * 2 + 2),
            max(msz.height(),
                button_reload.sizeHint().height() + frameWidth * 2 + 2))
        self._timer = QTimer(self)
        self._timer.setSingleShot(True)
        self._timer.setInterval(500)
        self._timer.timeout.connect(self._emit_refresh_text)
示例#21
0
  def __init__(self, context):
    '''init initializes the widget and sets up our subscriber, publisher and event handlers'''
    super(PlexilPlanSelectionGUI, self).__init__(context)
    self.setObjectName('PlexilPlanSelectionGUI')

    # Process standalone plugin command-line arguments
    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())

    # Find resources and Create QWidget
    self._widget = QWidget()
    ui_file = os.path.join(rospkg.RosPack().get_path('ow_plexil'), 'rqt_plexil_plan_selection', 'resource', 'plexil_plan_selection.ui')
    loadUi(ui_file, self._widget)
    self._widget.setObjectName('PlexilPlanSelectionUI')
    if context.serial_number() > 1:
      self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
    context.add_widget(self._widget)

    #set window icon
    icon = os.path.join(rospkg.RosPack().get_path('ow_plexil'), 'rqt_plexil_plan_selection', 'resource', 'icon.png')
    self._widget.setWindowIcon(QIcon(icon))
    #pub and sub setup
    self.status_publisher = rospy.Publisher('plexil_plan_selection_status', String, queue_size=20)
    self.status_subscriber = rospy.Subscriber('plexil_plan_selection_status', String, self.status_callback)
    #client placeholder
    self.plan_select_client = None
  
    #Qt signal to modify GUI from callback
    self.monitor_signal[str].connect(self.monitor_status)

    #populates the plan list, shows different plans based off of what launch file is running
    if rospy.get_param('owlat_flag', False):
      owlat_plan_dir = os.path.join(rospkg.RosPack().get_path('ow_plexil'), 'src', 'plans', 'owlat_plans')
      self.populate_plan_list(owlat_plan_dir)
    else:
      ow_plan_dir = os.path.join(rospkg.RosPack().get_path('ow_plexil'), 'src', 'plans')
      self.populate_plan_list(ow_plan_dir)
 
    #sets up tables
    self._widget.sentPlansTable.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContents)
    self._widget.planQueueTable.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContents)
    self._widget.sentPlansTable.insertColumn(0)
    self._widget.sentPlansTable.insertColumn(1)
    self._widget.planQueueTable.insertColumn(0)
    #sets up event listeners
    self._widget.addButton.clicked[bool].connect(self.handle_add_button_clicked)
    self._widget.removeButton.clicked[bool].connect(self.handle_remove_button_clicked)
    self._widget.upButton.clicked[bool].connect(self.handle_up_button_clicked)
    self._widget.downButton.clicked[bool].connect(self.handle_down_button_clicked)
    self._widget.sendButton.clicked[bool].connect(self.handle_send_button_clicked)
    self._widget.resetButton.clicked[bool].connect(self.handle_reset_button_clicked)
示例#22
0
    def _enrich_action(self, action, action_attributes, base_path=None):
        icontype = action_attributes.get('icontype', 'file')
        if 'icon' in action_attributes and action_attributes[
                'icon'] is not None:
            if icontype == 'file':
                path = action_attributes['icon']
                if base_path is not None:
                    path = os.path.join(base_path, path)
                icon = QIcon(path)
                if len(icon.availableSizes()) == 0:
                    raise UserWarning('icon "%s" not found' % str(path))
            elif icontype == 'resource':
                icon = QIcon(action_attributes['icon'])
                if len(icon.availableSizes()) == 0:
                    raise UserWarning('icon "%s" not found' % str(path))
            elif icontype == 'theme':
                # see http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
                icon = QIcon.fromTheme(action_attributes['icon'])
            else:
                raise UserWarning('unknown icon type "%s"' % str(icontype))
            action.setIcon(icon)

        if 'statustip' in action_attributes:
            action.setStatusTip(action_attributes['statustip'])
示例#23
0
    def __init__(self, parent=None):
        super(DynamicGraphButton, self).__init__(parent)
        this_dir, this_filename = os.path.split(__file__)
        stop_button_path = os.path.join(this_dir, "play_button.png")
        play_button_path = os.path.join(this_dir, "stop_button.png")
        finished_button_path = os.path.join(this_dir, "finished_button.png")
        self.icon_play = QIcon(stop_button_path)
        self.icon_stop = QIcon(play_button_path)
        self.icon_finished = QIcon(finished_button_path)

        self.setIcon(self.icon_play)

        self.pressed.connect(self.update)
        self.released.connect(self.update)
        self.clicked.connect(self.update_on_click)

        # states = ["init", "running", "stop"]
        self.state = "init"

        self._start_dg_client = self._get_start_dg_client()
        self._stop_dg_client = self._get_stop_dg_client()

        self.setMaximumWidth(100)
        self.setIconSize(QSize(0.8 * 100, 0.8 * 100))
示例#24
0
    def __init__(self, masteruri, cfg, ns, nodes, parent=None):
        QFrame.__init__(self, parent)
        self._masteruri = masteruri
        self._nodes = {cfg: {ns: nodes}}
        frame_layout = QVBoxLayout(self)
        frame_layout.setContentsMargins(0, 0, 0, 0)
        # create frame for warning label
        self.warning_frame = warning_frame = QFrame(self)
        warning_layout = QHBoxLayout(warning_frame)
        warning_layout.setContentsMargins(0, 0, 0, 0)
        warning_layout.addItem(
            QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
        self.warning_label = QLabel()
        icon = QIcon(':/icons/crystal_clear_warning.png')
        self.warning_label.setPixmap(icon.pixmap(QSize(40, 40)))
        self.warning_label.setToolTip(
            'Multiple configuration for same node found!\nA first one will be selected for the start a node!'
        )
        warning_layout.addWidget(self.warning_label)
        warning_layout.addItem(
            QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
        frame_layout.addItem(
            QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
        frame_layout.addWidget(warning_frame)
        # create frame for start/stop buttons
        buttons_frame = QFrame()
        buttons_layout = QHBoxLayout(buttons_frame)
        buttons_layout.setContentsMargins(0, 0, 0, 0)
        buttons_layout.addItem(QSpacerItem(20, 20))
        self.on_button = QPushButton()
        self.on_button.setFlat(False)
        self.on_button.setText("On")
        self.on_button.clicked.connect(self.on_on_clicked)
        buttons_layout.addWidget(self.on_button)

        self.off_button = QPushButton()
        self.off_button.setFlat(True)
        self.off_button.setText("Off")
        self.off_button.clicked.connect(self.on_off_clicked)
        buttons_layout.addWidget(self.off_button)
        buttons_layout.addItem(QSpacerItem(20, 20))
        frame_layout.addWidget(buttons_frame)
        frame_layout.addItem(
            QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
        self.warning_frame.setVisible(False)
示例#25
0
    def __init__(self, parent=None):
        QLineEdit.__init__(self, parent)
        # Create a clear button with icon
        self.clearBtn = clearBtn = QToolButton(self)
        icon = QIcon.fromTheme("edit-clear", QIcon(":/icons/crystal_clear_button_close.png"))
        clearBtn.setIcon(icon)
        clearBtn.setCursor(Qt.ArrowCursor)
        clearBtn.setStyleSheet("QToolButton { border: none; padding: 0px; }")
        clearBtn.hide()

        # signals, clear lineEdit if btn pressed; change btn visibility on input
        clearBtn.clicked.connect(self.clear)
        self.textChanged[str].connect(self.update_close_button)

        frameWidth = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth)
        self.setStyleSheet("QLineEdit { padding-right: %dpx; } " % (clearBtn.sizeHint().width() + frameWidth + 1))
        msz = self.minimumSizeHint()
        self.setMinimumSize(max(msz.width(), clearBtn.sizeHint().height() + frameWidth * 2 + 2),
                            max(msz.height(), clearBtn.sizeHint().height() + frameWidth * 2 + 2))
示例#26
0
 def _update_icon(self):
     if self.id in [self.NOTHING, self.NOT_FOUND]:
         return
     icon_path = ""
     if self.id == self.FOLDER:
         icon_path = ":/icons/crystal_clear_folder.png"
     elif self.id == self.PACKAGE:
         icon_path = ":/icons/crystal_clear_package.png"
     elif self.id == self.LAUNCH_FILE:
         icon_path = ":/icons/crystal_clear_launch_file.png"
     elif self.id == self.RECENT_FILE:
         icon_path = ":/icons/crystal_clear_launch_file_recent.png"
     elif self.id == self.STACK:
         icon_path = ":/icons/crystal_clear_stack.png"
     elif self.id == self.PROFILE:
         icon_path = ":/icons/crystal_clear_profile.png"
     elif self.id == self.RECENT_PROFILE:
         icon_path = ":/icons/crystal_clear_profile_recent.png"
     elif self.id == self.REMOTE_DAEMON:
         icon_path = ":/icons/stock_connect.png"
     elif self.id == self.ROOT:
         icon_path = ":/icons/back.png"
     if icon_path:
         self.setIcon(QIcon(QPixmap(icon_path).scaled(16, 16)))
 def __init__(self, master, local=False, quality=None, parent=None):
     self.name = ''.join([master.name, ' (localhost)'
                          ]) if local else master.name
     QStandardItem.__init__(self, self.name)
     self.parent_item = None
     self._master = master
     self.local = local
     self.__quality = quality
     self.descr = ''
     self.ICONS = {
         'green': QIcon(":/icons/stock_connect_green.png"),
         'yellow': QIcon(":/icons/stock_connect_yellow.png"),
         'red': QIcon(":/icons/stock_connect_red.png"),
         'grey': QIcon(":/icons/stock_connect.png"),
         'disconnected': QIcon(":/icons/stock_disconnect.png"),
         'warning': QIcon(':/icons/crystal_clear_warning.png'),
         'clock_warn': QIcon(':/icons/crystal_clear_xclock_fail.png')
     }
     self.master_ip = None
     self._master_errors = []
     self._timediff = 0
     self._threaded_get_ip()
     self.updateNameView(master, quality, self)
 def fromTheme(self, icon_name):
     if self.icons_map.has_key(icon_name):
         return QIcon.fromTheme(icon_name, QIcon(self.icons_map[icon_name]))
     else:
         return QIcon.fromTheme(icon_name)
示例#29
0
 def icon(self, name):
     return QIcon(self.icon_path(name))
示例#30
0
    def __init__(self,
                 topic,
                 msg_type,
                 show_only_rate=False,
                 masteruri=None,
                 use_ssh=False,
                 parent=None):
        '''
        Creates an input dialog.
        @param topic: the name of the topic
        @type topic: C{str}
        @param msg_type: the type of the topic
        @type msg_type: C{str}
        @raise Exception: if no topic class was found for the given type
        '''
        QDialog.__init__(self, parent=parent)
        self._masteruri = masteruri
        masteruri_str = '' if masteruri is None else '[%s]' % masteruri
        self.setObjectName(' - '.join(['EchoDialog', topic, masteruri_str]))
        self.setAttribute(Qt.WA_DeleteOnClose, True)
        self.setWindowFlags(Qt.Window)
        self.setWindowTitle('%s %s %s' %
                            ('Echo --- ' if not show_only_rate else 'Hz --- ',
                             topic, masteruri_str))
        self.resize(728, 512)
        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.setObjectName("verticalLayout")
        self.verticalLayout.setContentsMargins(1, 1, 1, 1)
        self.mIcon = QIcon(":/icons/crystal_clear_prop_run_echo.png")
        self.setWindowIcon(self.mIcon)

        self.topic = topic
        self.show_only_rate = show_only_rate
        self.lock = threading.RLock()
        self.last_printed_count = 0
        self.msg_t0 = -1.
        self.msg_tn = 0
        self.times = []

        self.message_count = 0
        self._rate_message = ''
        self._scrapped_msgs = 0
        self._scrapped_msgs_sl = 0

        self._last_received_ts = 0
        self.receiving_hz = self.MESSAGE_HZ_LIMIT
        self.line_limit = self.MESSAGE_LINE_LIMIT

        self.field_filter_fn = None

        options = QWidget(self)
        if not show_only_rate:
            hLayout = QHBoxLayout(options)
            hLayout.setContentsMargins(1, 1, 1, 1)
            self.no_str_checkbox = no_str_checkbox = QCheckBox('Hide strings')
            no_str_checkbox.toggled.connect(self.on_no_str_checkbox_toggled)
            hLayout.addWidget(no_str_checkbox)
            self.no_arr_checkbox = no_arr_checkbox = QCheckBox('Hide arrays')
            no_arr_checkbox.toggled.connect(self.on_no_arr_checkbox_toggled)
            hLayout.addWidget(no_arr_checkbox)
            self.combobox_reduce_ch = QComboBox(self)
            self.combobox_reduce_ch.addItems(
                [str(self.MESSAGE_LINE_LIMIT), '0', '80', '256', '1024'])
            self.combobox_reduce_ch.activated[str].connect(
                self.combobox_reduce_ch_activated)
            self.combobox_reduce_ch.setEditable(True)
            self.combobox_reduce_ch.setToolTip(
                "Set maximum line width. 0 disables the limit.")
            hLayout.addWidget(self.combobox_reduce_ch)
            #      reduce_ch_label = QLabel('ch', self)
            #      hLayout.addWidget(reduce_ch_label)
            # add spacer
            spacerItem = QSpacerItem(515, 20, QSizePolicy.Expanding,
                                     QSizePolicy.Minimum)
            hLayout.addItem(spacerItem)
            # add combobox for displaying frequency of messages
            self.combobox_displ_hz = QComboBox(self)
            self.combobox_displ_hz.addItems([
                str(self.MESSAGE_HZ_LIMIT), '0', '0.1', '1', '50', '100',
                '1000'
            ])
            self.combobox_displ_hz.activated[str].connect(
                self.on_combobox_hz_activated)
            self.combobox_displ_hz.setEditable(True)
            hLayout.addWidget(self.combobox_displ_hz)
            displ_hz_label = QLabel('Hz', self)
            hLayout.addWidget(displ_hz_label)
            # add combobox for count of displayed messages
            self.combobox_msgs_count = QComboBox(self)
            self.combobox_msgs_count.addItems(
                [str(self.MAX_DISPLAY_MSGS), '0', '50', '100'])
            self.combobox_msgs_count.activated[str].connect(
                self.on_combobox_count_activated)
            self.combobox_msgs_count.setEditable(True)
            self.combobox_msgs_count.setToolTip(
                "Set maximum displayed message count. 0 disables the limit.")
            hLayout.addWidget(self.combobox_msgs_count)
            displ_count_label = QLabel('#', self)
            hLayout.addWidget(displ_count_label)
            # add topic control button for unsubscribe and subscribe
            self.topic_control_button = QToolButton(self)
            self.topic_control_button.setText('stop')
            self.topic_control_button.setIcon(
                QIcon(':/icons/deleket_deviantart_stop.png'))
            self.topic_control_button.clicked.connect(
                self.on_topic_control_btn_clicked)
            hLayout.addWidget(self.topic_control_button)
            # add clear button
            clearButton = QToolButton(self)
            clearButton.setText('clear')
            clearButton.clicked.connect(self.on_clear_btn_clicked)
            hLayout.addWidget(clearButton)
            self.verticalLayout.addWidget(options)

        self.display = QTextBrowser(self)
        self.display.setReadOnly(True)
        self.verticalLayout.addWidget(self.display)
        self.display.document().setMaximumBlockCount(500)
        self.max_displayed_msgs = self.MAX_DISPLAY_MSGS
        self._blocks_in_msg = None
        self.display.setOpenLinks(False)
        self.display.anchorClicked.connect(self._on_display_anchorClicked)

        self.status_label = QLabel('0 messages', self)
        self.verticalLayout.addWidget(self.status_label)

        # subscribe to the topic
        errmsg = ''
        try:
            self.__msg_class = message.get_message_class(msg_type)
            if not self.__msg_class:
                errmsg = "Cannot load message class for [%s]. Did you build messages?" % msg_type
#        raise Exception("Cannot load message class for [%s]. Did you build messages?"%msg_type)
        except Exception as e:
            self.__msg_class = None
            errmsg = "Cannot load message class for [%s]. Did you build messagest?\nError: %s" % (
                msg_type, e)
#      raise Exception("Cannot load message class for [%s]. Did you build messagest?\nError: %s"%(msg_type, e))
# variables for Subscriber
        self.msg_signal.connect(self._append_message)
        self.sub = None

        # vairables for SSH connection
        self.ssh_output_file = None
        self.ssh_error_file = None
        self.ssh_input_file = None
        self.text_signal.connect(self._append_text)
        self.text_hz_signal.connect(self._append_text_hz)
        self._current_msg = ''
        self._current_errmsg = ''
        self.text_error_signal.connect(self._append_error_text)

        # decide, which connection to open
        if use_ssh:
            self.__msg_class = None
            self._on_display_anchorClicked(QUrl(self._masteruri))
        elif self.__msg_class is None:
            errtxt = '<pre style="color:red; font-family:Fixedsys,Courier,monospace; padding:10px;">\n%s</pre>' % (
                errmsg)
            self.display.setText('<a href="%s">open using SSH</a>' %
                                 (masteruri))
            self.display.append(errtxt)
        else:
            self.sub = rospy.Subscriber(self.topic, self.__msg_class,
                                        self._msg_handle)

        self.print_hz_timer = QTimer()
        self.print_hz_timer.timeout.connect(self._on_calc_hz)
        self.print_hz_timer.start(1000)