예제 #1
0
  def __init__(self, masteruri, ns='/', parent=None):
    '''
    @param masteruri: if the master uri is not None, the parameter are retrieved from ROS parameter server.
    @type masteruri: C{str}
    @param ns: namespace of the parameter retrieved from the ROS parameter server.
    @type ns: C{str}
    '''
    ParameterDialog.__init__(self, dict(), parent=parent)
    self.masteruri = masteruri
    self.ns = ns
    self.is_delivered = False
    self.is_send = False
    self.mIcon = QtGui.QIcon(":/icons/default_cfg.png")
    self.setWindowIcon(self.mIcon)
    self.resize(450,300)
    self.add_new_button = QtGui.QPushButton()
    self.add_new_button.setIcon(QtGui.QIcon(':/icons/crystal_clear_add.png'))
    self.add_new_button.clicked.connect(self._on_add_parameter)
    self.add_new_button.setToolTip('Adds a new parameter to the list')
    self.add_new_button.setFlat(True)
    self.buttonBox.addButton(self.add_new_button, QtGui.QDialogButtonBox.ActionRole)
    self.showLoadSaveButtons()
#    self.apply_button = QtGui.QPushButton(self.tr("&Ok"))
#    self.apply_button.clicked.connect(self._on_apply)
#    self.buttonBox.addButton(self.apply_button, QtGui.QDialogButtonBox.ApplyRole)
#    self.buttonBox.accepted.connect(self._on_apply)
    self.setText(' '.join(['Obtaining parameters from the parameter server', masteruri, '...']))
    self.parameterHandler = ParameterHandler()
    self.parameterHandler.parameter_list_signal.connect(self._on_param_list)
    self.parameterHandler.parameter_values_signal.connect(self._on_param_values)
    self.parameterHandler.delivery_result_signal.connect(self._on_delivered_values)
    self.parameterHandler.requestParameterList(masteruri, ns)
예제 #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(QtCore.QUrl(
                     self._masteruri))
             self.topic_control_button.setText('stop')
             self.topic_control_button.setIcon(
                 QtGui.QIcon(':/icons/deleket_deviantart_stop.png'))
         else:
             if not self.sub is None:
                 self.sub.unregister()
                 self.sub = None
             elif not self.ssh_output_file is 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(
                 QtGui.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, menu_button):
     QtGui.QMenu.__init__(self)
     self.button = menu_button
     try:
         rqt_icon_path = roslib.packages.find_resource(
             'rqt_gui', 'rqt.png').pop()
         menu_button.setText('')
         menu_button.setIcon(QtGui.QIcon(rqt_icon_path))
         # creates a default config menu
         self.action_rqt_console = QtGui.QAction(
             QtGui.QIcon.fromTheme('mail-message-new'),
             "&Console",
             self,
             statusTip=
             '"<p>Starts a python GUI plugin for displaying and filtering '
             'ROS log messages that is connected to the selected master.</p>"',
             triggered=self.on_show_console_clicked)
         self.addAction(self.action_rqt_console)
         self.action_rqt_logger_level = QtGui.QAction(
             QtGui.QIcon.fromTheme('format-indent-more'),
             "&Logger Level",
             self,
             statusTip=
             '"<p>Starts a python GUI plugin for configuring the level of '
             'ROS loggers that is connected to the selected master.</p>"',
             triggered=self.on_show_logger_level_clicked)
         self.addAction(self.action_rqt_logger_level)
         self.action_rqt_tf_tree = QtGui.QAction(
             QtGui.QIcon.fromTheme('preferences-system-network'),
             "&TF Tree",
             self,
             statusTip=
             '"<p>Starts a python GUI plugin for visualizing the TF tree'
             'that is connected to the selected master.</p>"',
             triggered=self.on_show_tf_tree_clicked)
         self.addAction(self.action_rqt_tf_tree)
         self.action_rqt_ros_graph = QtGui.QAction(
             QtGui.QIcon(":/icons/button_graph.png"),
             "Ros &Graph",
             self,
             statusTip=
             '"<p>Starts a python GUI plugin for visualizing the ROS computation graph'
             'that is connected to the selected master</p>"',
             triggered=self.on_show_ros_graph_clicked)
         self.addAction(self.action_rqt_ros_graph)
         self.addSeparator()
         self.action_rqt = QtGui.QAction(
             QtGui.QIcon(rqt_icon_path),
             "&Rqt GUI",
             self,
             statusTip='"<p>Start the rqt GUI'
             'that is connected to the selected master</p>"',
             triggered=self.on_start_rqt_clicked)
         self.addAction(self.action_rqt)
         menu_button.setMenu(self)
     except Exception as e:
         print '%s' % e
         menu_button.setEnabled(False)
         menu_button.setToolTip(
             'rqt_gui not found! Please install rqt to use its plugins!')
예제 #4
0
 def on_topic_control_btn_clicked(self):
     if self.sub is None:
         self.sub = rospy.Subscriber(self.topic, self.__msg_class,
                                     self._msg_handle)
         self.topic_control_button.setText('stop')
         self.topic_control_button.setIcon(
             QtGui.QIcon(':/icons/deleket_deviantart_stop.png'))
     else:
         self.sub.unregister()
         self.sub = None
         self.topic_control_button.setText('play')
         self.topic_control_button.setIcon(
             QtGui.QIcon(':/icons/deleket_deviantart_play.png'))
예제 #5
0
 def showLoadSaveButtons(self):
   self.load_button = QtGui.QPushButton()
   self.load_button.setIcon(QtGui.QIcon(':/icons/load.png'))
   self.load_button.clicked.connect(self._load_parameter)
   self.load_button.setToolTip('Load parameters from YAML file')
   self.load_button.setFlat(True)
   self.buttonBox.addButton(self.load_button, QtGui.QDialogButtonBox.ActionRole)
   self.save_button = QtGui.QPushButton()
   self.save_button.clicked.connect(self._save_parameter)
   self.save_button.setIcon(QtGui.QIcon(':/icons/save.png'))
   self.save_button.setToolTip('Save parameters to YAML file')
   self.save_button.setFlat(True)
   self.buttonBox.addButton(self.save_button, QtGui.QDialogButtonBox.ActionRole)
예제 #6
0
 def __init__(self, master, parent=None):
     self.name = master.name
     QtGui.QStandardItem.__init__(self, self.name)
     self.parent_item = None
     self._master = master
     self._syncronized = MasterSyncItem.NOT_SYNC
     self.ICONS = {
         MasterSyncItem.SYNC:
         QtGui.QIcon(":/icons/%s_sync.png" % self.ICON_PREFIX),
         MasterSyncItem.NOT_SYNC:
         QtGui.QIcon(":/icons/%s_not_sync.png" % self.ICON_PREFIX),
         MasterSyncItem.START_SYNC:
         QtGui.QIcon(":/icons/%s_start_sync.png" % self.ICON_PREFIX)
     }
     self.setIcon(self.ICONS[MasterSyncItem.NOT_SYNC])
예제 #7
0
    def InspectionWindow(self):
        """Creates a new manual window in a 
            maximized window."""

        self.manual = ManualWindow()
        self.manual.setWindowIcon(QtGui.QIcon(self.icon))
        self.manual.setFixedSize(1920, 1080)
        self.manual.showMaximized()
예제 #8
0
 def __init__(self, master):
     QtCore.QObject.__init__(self)
     self.name = master.name
     self._master = master
     self._syncronized = MasterSyncButtonHelper.NOT_SYNC
     self.ICONS = {
         MasterSyncButtonHelper.SYNC:
         QtGui.QIcon(":/icons/%s_sync.png" % self.ICON_PREFIX),
         MasterSyncButtonHelper.NOT_SYNC:
         QtGui.QIcon(":/icons/%s_not_sync.png" % self.ICON_PREFIX),
         MasterSyncButtonHelper.SWITCHED:
         QtGui.QIcon(":/icons/%s_start_sync.png" % self.ICON_PREFIX)
     }
     self.widget = QtGui.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)
 def __init__(self, name, path, id, parent=None):
   '''
   Initialize the topic item.
   @param name: the topic name
   @type name: C{str}
   '''
   QtGui.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 = id
   if self.id == LaunchItem.FOLDER:
     self.setIcon(QtGui.QIcon(":/icons/crystal_clear_folder.png"))
   elif self.id == LaunchItem.PACKAGE:
     self.setIcon(QtGui.QIcon(":/icons/crystal_clear_package.png"))
   elif self.id == LaunchItem.LAUNCH_FILE:
     self.setIcon(QtGui.QIcon(":/icons/crystal_clear_launch_file.png"))
   elif self.id == LaunchItem.RECENT_FILE:
     self.setIcon(QtGui.QIcon(":/icons/crystal_clear_launch_file_recent.png"))
   elif self.id == LaunchItem.STACK:
     self.setIcon(QtGui.QIcon(":/icons/crystal_clear_stack.png"))
예제 #10
0
    def __init__(self, masteruri, cfg, ns, nodes, parent=None):
        QtGui.QFrame.__init__(self, parent)
        self._masteruri = masteruri
        self._nodes = {cfg: {ns: nodes}}
        frame_layout = QtGui.QVBoxLayout(self)
        frame_layout.setContentsMargins(0, 0, 0, 0)
        # create frame for warning label
        self.warning_frame = warning_frame = QtGui.QFrame()
        warning_layout = QtGui.QHBoxLayout(warning_frame)
        warning_layout.setContentsMargins(0, 0, 0, 0)
        warning_layout.addItem(
            QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Expanding))
        self.warning_label = QtGui.QLabel()
        icon = QtGui.QIcon(':/icons/crystal_clear_warning.png')
        self.warning_label.setPixmap(icon.pixmap(QtCore.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(
            QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Expanding))
        frame_layout.addItem(
            QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Expanding))
        frame_layout.addWidget(warning_frame)
        # create frame for start/stop buttons
        buttons_frame = QtGui.QFrame()
        buttons_layout = QtGui.QHBoxLayout(buttons_frame)
        buttons_layout.setContentsMargins(0, 0, 0, 0)
        buttons_layout.addItem(QtGui.QSpacerItem(20, 20))
        self.on_button = QtGui.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 = QtGui.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(QtGui.QSpacerItem(20, 20))
        frame_layout.addWidget(buttons_frame)
        frame_layout.addItem(
            QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Expanding))
        self.warning_frame.setVisible(False)
예제 #11
0
    def __init__(self, argv, key):
        QtGui.QApplication.__init__(self, argv)
        self._memory = QtCore.QSharedMemory(self)
        self._memory.setKey(key)
        if self._memory.attach():
            self._running = True
        else:
            self._running = False
            if not self._memory.create(1):
                raise RuntimeError(self._memory.errorString())

        # Set correct logo
        base_path = os.path.abspath(os.path.dirname(__file__))
        icon_path = os.path.join(base_path, 'images', 'hyperspy.svg')
        QtGui.QApplication.setWindowIcon(QtGui.QIcon(icon_path))
예제 #12
0
 def __init__(self, master, local=False, quality=None, parent=None):
     self.name = ''.join([master.name, ' (localhost)'
                          ]) if local else master.name
     QtGui.QStandardItem.__init__(self, self.name)
     self.parent_item = None
     self._master = master
     self.__quality = quality
     self.descr = ''
     self.ICONS = {
         'green': QtGui.QIcon(":/icons/stock_connect_green.png"),
         'yellow': QtGui.QIcon(":/icons/stock_connect_yellow.png"),
         'red': QtGui.QIcon(":/icons/stock_connect_red.png"),
         'grey': QtGui.QIcon(":/icons/stock_connect.png"),
         'disconnected': QtGui.QIcon(":/icons/stock_disconnect.png"),
         'warning': QtGui.QIcon(':/icons/crystal_clear_warning.png')
     }
     self.master_ip = None
     self._threaded_get_ip()
     self.updateNameView(master, quality, self)
예제 #13
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
    '''
        QtGui.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(QtCore.Qt.WA_DeleteOnClose, True)
        self.setWindowFlags(QtCore.Qt.Window)
        self.setWindowTitle('%s %s %s' %
                            ('Echo --- ' if not show_only_rate else 'Hz --- ',
                             topic, masteruri_str))
        self.resize(728, 512)
        self.verticalLayout = QtGui.QVBoxLayout(self)
        self.verticalLayout.setObjectName("verticalLayout")
        self.verticalLayout.setContentsMargins(1, 1, 1, 1)
        self.mIcon = QtGui.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 = QtGui.QWidget(self)
        if not show_only_rate:
            hLayout = QtGui.QHBoxLayout(options)
            hLayout.setContentsMargins(1, 1, 1, 1)
            self.no_str_checkbox = no_str_checkbox = QtGui.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 = QtGui.QCheckBox(
                'Hide arrays')
            no_arr_checkbox.toggled.connect(self.on_no_arr_checkbox_toggled)
            hLayout.addWidget(no_arr_checkbox)
            self.combobox_reduce_ch = QtGui.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 = QtGui.QLabel('ch', self)
            #      hLayout.addWidget(reduce_ch_label)
            # add spacer
            spacerItem = QtGui.QSpacerItem(515, 20,
                                           QtGui.QSizePolicy.Expanding,
                                           QtGui.QSizePolicy.Minimum)
            hLayout.addItem(spacerItem)
            # add combobox for displaying frequency of messages
            self.combobox_displ_hz = QtGui.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 = QtGui.QLabel('Hz', self)
            hLayout.addWidget(displ_hz_label)
            # add combobox for count of displayed messages
            self.combobox_msgs_count = QtGui.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 = QtGui.QLabel('#', self)
            hLayout.addWidget(displ_count_label)
            # add topic control button for unsubscribe and subscribe
            self.topic_control_button = QtGui.QToolButton(self)
            self.topic_control_button.setText('stop')
            self.topic_control_button.setIcon(
                QtGui.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 = QtGui.QToolButton(self)
            clearButton.setText('clear')
            clearButton.clicked.connect(self.on_clear_btn_clicked)
            hLayout.addWidget(clearButton)
            self.verticalLayout.addWidget(options)

        self.display = QtGui.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 = QtGui.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(QtCore.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 = QtCore.QTimer()
        self.print_hz_timer.timeout.connect(self._on_calc_hz)
        self.print_hz_timer.start(1000)
예제 #14
0
 def get_icon(self, skill_type):
     if not skill_type in self.icons:
         file_name = os.path.join(rospkg.RosPack().get_path("skiros2_gui"), "src/skiros2_gui/core/imgs/", "{}.png".format(skill_type if skill_type else "skill"))
         self.icons[skill_type] = QtGui.QIcon(file_name)
     return self.icons[skill_type]
예제 #15
0
 def setupButtons(self, yaml_file):
     """
     Parse yaml file and setup Buttons. Format of the yaml file should be:
     - name: 'button name' (required)
       image: 'path to image for icon' (optional)
       image_size: 'width and height of icon' (optional)
       service: 'service' (required)
       column: 'column index' (optional, defaults to 0)
     """
     self.buttons = []
     with open(yaml_file) as f:
         yaml_data = yaml.load(f)
         # lookup colum direction
         direction = 'vertical'
         for d in yaml_data:
             if d.has_key('direction'):
                 if d['direction'] == 'horizontal':
                     direction = 'horizontal'
                 else:  # d['direction'] == 'vertical':
                     direction = 'vertical'
                 yaml_data.remove(d)
                 break
         # lookup column num
         column_indices = [d['column'] for d in yaml_data]
         max_column_index = max(*column_indices)
         if direction == 'vertical':
             self.layout = QHBoxLayout()
             self.layout_boxes = [
                 QVBoxLayout() for i in range(max_column_index + 1)
             ]
         else:  # direction == 'horizontal'
             self.layout = QVBoxLayout()
             self.layout_boxes = [
                 QHBoxLayout() for i in range(max_column_index + 1)
             ]
         self.button_groups = [
             QGroupBox() for i in range(max_column_index + 1)
         ]
         for button_data in yaml_data:
             # check if all the field is available
             if not button_data.has_key("name"):
                 self.showError("name field is missed in yaml")
                 raise Exception("name field is missed in yaml")
             if not button_data.has_key("service"):
                 self.showError("service field is missed in yaml")
                 raise Exception("service field is missed in yaml")
             if self.button_type == "push":
                 button = QToolButton()
             else:  # self.button_type == "radio":
                 button = QRadioButton()
             button.setSizePolicy(
                 QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
             if button_data.has_key("image"):
                 image_file = get_filename(
                     button_data["image"])[len("file://"):]
                 if os.path.exists(image_file):
                     icon = QtGui.QIcon(image_file)
                     button.setIcon(icon)
                     if button_data.has_key("image_size"):
                         button.setIconSize(
                             QSize(button_data["image_size"][0],
                                   button_data["image_size"][1]))
                     else:
                         button.setIconSize(QSize(100, 100))
             if button_data.has_key("name"):
                 name = button_data['name']
                 button.setText(name)
             if button_data.has_key('service_type'):
                 if button_data['service_type'] == 'Trigger':
                     service_type = Trigger
                 elif button_data['service_type'] == 'Empty':
                     service_type = Empty
                 elif button_data['service_type'] == 'SetBool':
                     service_type = SetBool
                 else:
                     raise Exception("Unsupported service type: {}".format(
                         button_data['service_type']))
             else:
                 service_type = Empty
             if service_type == SetBool:
                 button.setCheckable(True)
             button.clicked.connect(
                 self.buttonCallback(button_data['service'], service_type,
                                     button))
             if self.button_type == "push":
                 button.setToolButtonStyle(
                     QtCore.Qt.ToolButtonTextUnderIcon)
             if ((self.button_type == "radio" or service_type == SetBool)
                     and ("default_value" in button_data
                          and button_data['default_value'])):
                 button.setChecked(True)
             self.layout_boxes[button_data['column']].addWidget(button)
             self.buttons.append(button)
         for i in range(len(self.button_groups)):
             self.button_groups[i].setLayout(self.layout_boxes[i])
         for group in self.button_groups:
             self.layout.addWidget(group)
         self.setLayout(self.layout)
예제 #16
0
    def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)
        #    self.host = host
        self.setWindowIcon(QtGui.QIcon(":/icons/irondevil_sync.png"))
        self.setWindowTitle('Sync')
        self.verticalLayout = QtGui.QVBoxLayout(self)
        self.verticalLayout.setObjectName("verticalLayout")
        self.resize(350, 190)

        self.toolButton_SyncAll = QtGui.QToolButton(self)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(2)
        sizePolicy.setHeightForWidth(
            self.toolButton_SyncAll.sizePolicy().hasHeightForWidth())
        self.toolButton_SyncAll.setSizePolicy(sizePolicy)
        self.toolButton_SyncAll.setObjectName("toolButton_SyncAll")
        self.verticalLayout.addWidget(self.toolButton_SyncAll)
        self.toolButton_SyncAll.setText(
            QtGui.QApplication.translate("Form", "Sync All", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.toolButton_SyncAll.clicked.connect(self._on_sync_all_clicked)

        self.toolButton_SyncAllAnyMsg = QtGui.QToolButton(self)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(1)
        sizePolicy.setHeightForWidth(
            self.toolButton_SyncAllAnyMsg.sizePolicy().hasHeightForWidth())
        self.toolButton_SyncAllAnyMsg.setSizePolicy(sizePolicy)
        self.toolButton_SyncAllAnyMsg.setObjectName("toolButton_SyncAllAnyMsg")
        self.verticalLayout.addWidget(self.toolButton_SyncAllAnyMsg)
        self.toolButton_SyncAllAnyMsg.setText(
            QtGui.QApplication.translate("Form", "Sync all (+AnyMsg)", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.toolButton_SyncAllAnyMsg.clicked.connect(
            self._on_sync_all_anymsg_clicked)

        self.toolButton_SyncTopicOnDemand = QtGui.QToolButton(self)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(1)
        sizePolicy.setHeightForWidth(
            self.toolButton_SyncTopicOnDemand.sizePolicy().hasHeightForWidth())
        self.toolButton_SyncTopicOnDemand.setSizePolicy(sizePolicy)
        self.toolButton_SyncTopicOnDemand.setObjectName(
            "toolButton_SyncTopicOnDemand")
        self.verticalLayout.addWidget(self.toolButton_SyncTopicOnDemand)
        self.toolButton_SyncTopicOnDemand.setText(
            QtGui.QApplication.translate("Form", "Sync only topics on demand",
                                         None, QtGui.QApplication.UnicodeUTF8))
        self.toolButton_SyncTopicOnDemand.clicked.connect(
            self._on_sync_topics_on_demand_clicked)

        self.toolButton_SelectInterface = QtGui.QToolButton(self)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(1)
        sizePolicy.setHeightForWidth(
            self.toolButton_SelectInterface.sizePolicy().hasHeightForWidth())
        self.toolButton_SelectInterface.setSizePolicy(sizePolicy)
        self.toolButton_SelectInterface.setObjectName(
            "toolButton_SelectInterface")
        self.verticalLayout.addWidget(self.toolButton_SelectInterface)
        self.toolButton_SelectInterface.setText(
            QtGui.QApplication.translate("Form", "Select an interface", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.toolButton_SelectInterface.clicked.connect(
            self._on_select_interface_clicked)

        self.interface_field = QtGui.QComboBox(self)
        self.interface_field.setInsertPolicy(
            QtGui.QComboBox.InsertAlphabetically)
        self.interface_field.setSizePolicy(
            QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Fixed))
        self.interface_field.setEditable(True)
        self.interface_field.setVisible(False)
        self.interface_field.setObjectName("interface_field")
        self.verticalLayout.addWidget(self.interface_field)
        self.interface_field.currentIndexChanged[str].connect(
            self._on_interface_selected)

        self.toolButton_EditInterface = QtGui.QToolButton(self)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(1)
        sizePolicy.setHeightForWidth(
            self.toolButton_EditInterface.sizePolicy().hasHeightForWidth())
        self.toolButton_EditInterface.setSizePolicy(sizePolicy)
        self.toolButton_EditInterface.setObjectName("toolButton_EditInterface")
        self.verticalLayout.addWidget(self.toolButton_EditInterface)
        self.toolButton_EditInterface.setText(
            QtGui.QApplication.translate("Form", "Edit selected interface",
                                         None, QtGui.QApplication.UnicodeUTF8))
        self.toolButton_EditInterface.clicked.connect(
            self._on_edit_interface_clicked)
        self.toolButton_EditInterface.setVisible(False)

        self.toolButton_CreateInterface = QtGui.QToolButton(self)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(1)
        sizePolicy.setHeightForWidth(
            self.toolButton_CreateInterface.sizePolicy().hasHeightForWidth())
        self.toolButton_CreateInterface.setSizePolicy(sizePolicy)
        self.toolButton_CreateInterface.setObjectName(
            "toolButton_CreateInterface")
        self.verticalLayout.addWidget(self.toolButton_CreateInterface)
        self.toolButton_CreateInterface.setText(
            QtGui.QApplication.translate("Form", "Create an interface", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.toolButton_CreateInterface.clicked.connect(
            self._on_create_interface_clicked)
        self.toolButton_CreateInterface.setVisible(False)

        self.textedit = Editor('', self)
        self.hl = SyncHighlighter(self.textedit.document())
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Expanding)
        self.textedit.setSizePolicy(sizePolicy)
        self.textedit.setObjectName("syncedit")
        self.verticalLayout.addWidget(self.textedit)
        self.textedit.setVisible(False)

        self._fill_interface_thread = None
        self._interfaces_files = None
        self._sync_args = []
        self._interface_filename = None

        self.buttonBox = QtGui.QDialogButtonBox(self)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setObjectName("buttonBox")
        self.verticalLayout.addWidget(self.buttonBox)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"),
                               self.accept)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"),
                               self.reject)

        self._new_iface = True
예제 #17
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})
    '''
    QtGui.QDialog.__init__(self, parent)
    self.setObjectName(' - '.join(['xmlEditor', str(filenames)]))
    self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
    self.setWindowFlags(QtCore.Qt.Window)
    self.mIcon = QtGui.QIcon(":/icons/crystal_clear_edit_launch.png")
    self._error_icon = QtGui.QIcon(":/icons/crystal_clear_warning.png")
    self._empty_icon = QtGui.QIcon()
    self.setWindowIcon(self.mIcon)
    self.setWindowTitle("ROSLaunch Editor");
#    self.finished.connect(self.closeEvent)
    self.init_filenames = list(filenames)

    self.files = []
    '''@ivar: list with all open files '''

    # create tabs for files
    self.verticalLayout = QtGui.QVBoxLayout(self)
    self.verticalLayout.setContentsMargins(0, 0, 0, 0)
    self.verticalLayout.setObjectName("verticalLayout")
    self.tabWidget = QtGui.QTabWidget(self)
    self.tabWidget.setTabPosition(QtGui.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.verticalLayout.addWidget(self.tabWidget)

    # create the buttons line
    self.buttons = QtGui.QWidget(self)
    self.horizontalLayout = QtGui.QHBoxLayout(self.buttons)
    self.horizontalLayout.setContentsMargins(4, 0, 4, 0)
    self.horizontalLayout.setObjectName("horizontalLayout")
    # add the search button
    self.searchButton = QtGui.QPushButton(self)
    self.searchButton.setObjectName("searchButton")
    self.searchButton.clicked.connect(self.on_shortcut_find)
    self.searchButton.setText(QtGui.QApplication.translate("XmlEditor", "Search", None, QtGui.QApplication.UnicodeUTF8))
    self.searchButton.setShortcut(QtGui.QApplication.translate("XmlEditor", "Ctrl+F", None, QtGui.QApplication.UnicodeUTF8))
    self.searchButton.setToolTip('Open a search dialog (Ctrl+F)')
    self.horizontalLayout.addWidget(self.searchButton)
    # add the goto button
    self.gotoButton = QtGui.QPushButton(self)
    self.gotoButton.setObjectName("gotoButton")
    self.gotoButton.clicked.connect(self.on_shortcut_goto)
    self.gotoButton.setText(QtGui.QApplication.translate("XmlEditor", "Goto line", None, QtGui.QApplication.UnicodeUTF8))
    self.gotoButton.setShortcut(QtGui.QApplication.translate("XmlEditor", "Ctrl+L", None, QtGui.QApplication.UnicodeUTF8))
    self.gotoButton.setToolTip('Open a goto dialog (Ctrl+L)')
    self.horizontalLayout.addWidget(self.gotoButton)
    # add a tag button
    self.tagButton = self._create_tag_button(self)
    self.horizontalLayout.addWidget(self.tagButton)

    # add spacer
    spacerItem = QtGui.QSpacerItem(515, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
    self.horizontalLayout.addItem(spacerItem)
    # add line number label
    self.pos_label = QtGui.QLabel()
    self.horizontalLayout.addWidget(self.pos_label)
    # add spacer
    spacerItem = QtGui.QSpacerItem(515, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
    self.horizontalLayout.addItem(spacerItem)
    # add save button
    self.saveButton = QtGui.QPushButton(self)
    self.saveButton.setObjectName("saveButton")
    self.saveButton.clicked.connect(self.on_saveButton_clicked)
    self.saveButton.setText(QtGui.QApplication.translate("XmlEditor", "Save", None, QtGui.QApplication.UnicodeUTF8))
    self.saveButton.setShortcut(QtGui.QApplication.translate("XmlEditor", "Ctrl+S", None, QtGui.QApplication.UnicodeUTF8))
    self.saveButton.setToolTip('Save the changes to the file (Ctrl+S)')
    self.horizontalLayout.addWidget(self.saveButton)
    self.verticalLayout.addWidget(self.buttons)

    #create the find dialog
    self.find_dialog = FindDialog(self)
    self.find_dialog.buttonBox.clicked.connect(self.on_find_dialog_clicked)
    self.find_dialog.found_files.itemActivated.connect(self.find_dialog_itemActivated)

#    self._shortcut_find = QtGui.QShortcut(QtGui.QKeySequence(self.tr("Ctrl+F", "find text")), self)
#    self._shortcut_find.activated.connect(self.on_shortcut_find)

    #open the files
    for f in filenames:
      if f:
        self.on_load_request(os.path.normpath(f), search_text)

    self.readSettings()
예제 #18
0
 def _publish_finished(self):
     self._publish_thread = None
     self.setIcon(QtGui.QIcon())
예제 #19
0
 def _on_publishing(self):
     self.updateIconView(QtGui.QIcon(':/icons/state_run.png'))
예제 #20
0
 def _on_wait_for_publishing(self):
     self.updateIconView(QtGui.QIcon(':/icons/state_off.png'))