コード例 #1
0
ファイル: menu_rqt.py プロジェクト: bosforox/SeekurJr
 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!')
コード例 #2
0
    def __createMenu(self):
        """Create a menu for the window."""
        # Create a save-as button
        saveAsAction = QtGui.QAction("&Save As", self)
        saveAsAction.setShortcut("Ctrl+S")
        saveAsAction.setStatusTip("Save the graph to a file")
        saveAsAction.triggered.connect(self.__onSaveAs)

        # Create an exit button
        exitAction = QtGui.QAction("&Exit", self)
        exitAction.setShortcut("Escape")
        exitAction.setStatusTip("Exit the application")
        exitAction.triggered.connect(QtGui.qApp.quit)

        # Create the menu bar, and add entries
        menuBar = self.menuBar()

        # Create the file menu
        fileMenu = menuBar.addMenu("&File")
        fileMenu.addAction(saveAsAction)
        fileMenu.addAction(exitAction)
コード例 #3
0
 def __init__(self, parent=None):
     '''
 Creates the window, connects the signals and init the class.
 '''
     QtGui.QDockWidget.__init__(self, parent)
     # initialize parameter
     self.__current_path = os.path.expanduser('~')
     # load the UI file
     ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                            'LaunchFilesDockWidget.ui')
     loadUi(ui_file, self)
     # initialize the view for the launch files
     self.launchlist_model = LaunchListModel()
     self.launchlist_proxyModel = QtGui.QSortFilterProxyModel(self)
     self.launchlist_proxyModel.setSourceModel(self.launchlist_model)
     self.xmlFileView.setModel(self.launchlist_proxyModel)
     self.xmlFileView.setAlternatingRowColors(True)
     self.xmlFileView.activated.connect(self.on_launch_selection_activated)
     self.xmlFileView.setDragDropMode(QtGui.QAbstractItemView.DragOnly)
     self.xmlFileView.setDragEnabled(True)
     sm = self.xmlFileView.selectionModel()
     sm.selectionChanged.connect(self.on_xmlFileView_selection_changed)
     #    self.searchPackageLine.setVisible(False)
     self.searchPackageLine.textChanged.connect(self.set_package_filter)
     self.searchPackageLine.focusInEvent = self._searchline_focusInEvent
     # connect to the button signals
     self.refreshXmlButton.clicked.connect(self.on_refresh_xml_clicked)
     self.editXmlButton.clicked.connect(self.on_edit_xml_clicked)
     self.newXmlButton.clicked.connect(self.on_new_xml_clicked)
     self.openXmlButton.clicked.connect(self.on_open_xml_clicked)
     self.transferButton.clicked.connect(self.on_transfer_file_clicked)
     self.loadXmlButton.clicked.connect(self.on_load_xml_clicked)
     self.loadXmlAsDefaultButton.clicked.connect(self.on_load_as_default)
     # creates a default config menu
     start_menu = QtGui.QMenu(self)
     self.loadDeafaultAtHostAct = QtGui.QAction(
         "&Load default config on host",
         self,
         statusTip="Loads the default config at given host",
         triggered=self.on_load_as_default_at_host)
     start_menu.addAction(self.loadDeafaultAtHostAct)
     self.loadXmlAsDefaultButton.setMenu(start_menu)
     #initialize the progress queue
     self.progress_queue = ProgressQueue(self.progressFrame_cfg,
                                         self.progressBar_cfg,
                                         self.progressCancelButton_cfg)
コード例 #4
0
def create_add_component_actions(parent, callback, prefix="", postfix=""):
    actions = {}
    compnames = [
        'Arctan', 'Bleasdale', 'DoubleOffset', 'DoublePowerLaw', 'Erf',
        'Exponential', 'Gaussian', 'GaussianHF', 'Logistic', 'Lorentzian',
        'Offset', 'PowerLaw', 'SEE', 'RC', 'Vignetting', 'Voigt', 'Polynomial',
        'PESCoreLineShape', 'Expression', 'VolumePlasmonDrude'
    ]
    for name in compnames:
        try:
            t = getattr(hyperspy.components1d, name)
        except AttributeError:
            continue
        ac_name = 'add_component_' + name
        f = partial(callback, t)
        ac = QtGui.QAction(prefix + name + postfix, parent)
        ac.setStatusTip(tr("Add a component of type ") + name)
        ac.connect(ac, QtCore.SIGNAL('triggered()'), f)
        actions[ac_name] = ac
    return actions
コード例 #5
0
ファイル: Gui.py プロジェクト: thesamprice/py-qt-propgrid
    def __init__(self, parent=None):
        super(QTreeView, self).__init__(parent)
        self.selected_index = None
        self.ConfigHeader = ConfigTreeModel(None)
        self.setModel(self.ConfigHeader)
        self.setEditTriggers(QtGui.QAbstractItemView.AllEditTriggers)
        self.delagate = ItemDelegate(self)
        self.setItemDelegate(self.delagate)
        self.setEditTriggers(QAbstractItemView.AllEditTriggers)
        self.setAlternatingRowColors(True)
        style = """
        QTreeView {
                background-color: #EAF5FF;
                alternate-background-color: #D5EAFF;
        }
        QTreeView::item {
              border: 1px solid #d9d9d9;
             border-top-color: transparent;
             border-bottom-color: transparent;
        }
        QTreeView::item:hover {
             background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);
             border: 1px solid #bfcde4;
         }
         QTreeView::item:selected {
             border: 1px solid #567dbc;
         }
         QTreeView::item:selected:active{
             background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6ea1f1, stop: 1 #567dbc);
         }
         QTreeView::item:selected:!active {
             background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6b9be8, stop: 1 #577fbf);
         }


        """
        self.setStyleSheet(style)
        #self.delagate.closeEditor.connect(self.param_changed)
        self.ConfigHeader.dataChanged.connect(self.param_changed)

        self.pressed.connect( self.presseda)
        
        self.data = None
        self.supported_types = loadItems()
        
        self.menu_Enabled = True
        self.convert_actions = []
        
        self.menuAddItem = QtGui.QMenu(self)
        self.menuAddItem.setTitle(QtGui.QApplication.translate("Right CLick", "Add Item..", None, QApplication.UnicodeUTF8))
        self.menuAddItem.setObjectName(_fromUtf8("menuAddItem"))
        
        self.menuConvertTo = QtGui.QMenu(self)
        self.menuConvertTo.setTitle(QtGui.QApplication.translate("Right CLick", "Convert To..", None, QApplication.UnicodeUTF8))
        self.menuConvertTo.setObjectName(_fromUtf8("menuConvertTo"))
        
        self.menuAddItem = QtGui.QMenu(self)
        self.menuAddItem.setTitle(QtGui.QApplication.translate("Right CLick", "Add Item..", None, QApplication.UnicodeUTF8))
        self.menuAddItem.setObjectName(_fromUtf8("menuAddItem"))
        
        
        #Set up drag and drop stuff...
        self.dragEnabled() 
        self.acceptDrops() 
        self.showDropIndicator() 
        self.setDragDropMode(QAbstractItemView.InternalMove) 
        
        #TODO add convert to / add item types
        #        types = loadItems()
#        for type, val in types.items():
#            name = val().json['gui_type']
#            
#            act = QtGui.QAction(self)
#            act.my_type = val
#            act.setText(QtGui.QApplication.translate("MainWindow", name, None, QtGui.QApplication.UnicodeUTF8))
#            act.setObjectName(_fromUtf8("actionConvertTo" + name))
#            act.triggered.connect(self.convert_to)
#            self.menuConvertTo.addAction(act)
#
#        self.type_names = []
#        self.type_definitions = {}
#        for type, val in types.items():
#            name = val().json['gui_type']
#            
#            self.type_names.append(name)
#            self.type_definitions[name] = val
#            act = QtGui.QAction(self)
#            act.my_type = type
#            act.setText(QtGui.QApplication.translate("MainWindow", name, None, QtGui.QApplication.UnicodeUTF8))
#            act.setObjectName(_fromUtf8("actionAddItem" + name))
#            act.triggered.connect(self.add_param)
#            self.menuAddItem.addAction(act)
            
        self.actionDelete_Item = QtGui.QAction(self)
        self.actionDelete_Item.setText('Delete Item')
        self.actionDelete_Item.triggered.connect(self.delete_item)
                
        self.actionEdit_Item = QtGui.QAction(self)
        self.actionEdit_Item.setText('Edit Item')
        self.actionEdit_Item.triggered.connect(self.edit_item)
コード例 #6
0
 def add_separator(self):
     self.sep_counter += 1
     ac = QtGui.QAction(self)
     ac.setSeparator(True)
     self.actions[self.sep_counter] = ac
コード例 #7
0
 def add_action(self, key, title, on_trig):
     ac = QtGui.QAction(title, self)  # TODO: tr()?
     self.connect(ac, QtCore.SIGNAL('triggered()'), on_trig)
     self.actions[key] = ac
コード例 #8
0
  def _create_tag_button(self, parent=None):
    btn = QtGui.QPushButton(parent)
    btn.setObjectName("tagButton")
    btn.setText(QtGui.QApplication.translate("XmlEditor", "Add tag", None, QtGui.QApplication.UnicodeUTF8))
    btn.setShortcut(QtGui.QApplication.translate("XmlEditor", "Ctrl+T", None, QtGui.QApplication.UnicodeUTF8))
    btn.setToolTip('Adds a ROS launch tag to launch file (Ctrl+T)')
    # creates a tag menu
    tag_menu = QtGui.QMenu(btn)
    # group tag
    add_group_tag_action = QtGui.QAction("<group>", self, statusTip="", triggered=self._on_add_group_tag)
    tag_menu.addAction(add_group_tag_action)
    # node tag
    add_node_tag_action = QtGui.QAction("<node>", self, statusTip="", triggered=self._on_add_node_tag)
    tag_menu.addAction(add_node_tag_action)
    # node tag with all attributes
    add_node_tag_all_action = QtGui.QAction("<node all>", self, statusTip="", triggered=self._on_add_node_tag_all)
    tag_menu.addAction(add_node_tag_all_action)
    # include tag with all attributes
    add_include_tag_all_action = QtGui.QAction("<include>", self, statusTip="", triggered=self._on_add_include_tag_all)
    tag_menu.addAction(add_include_tag_all_action)
    # remap
    add_remap_tag_action = QtGui.QAction("<remap>", self, statusTip="", triggered=self._on_add_remap_tag)
    tag_menu.addAction(add_remap_tag_action)
    # env tag
    add_env_tag_action = QtGui.QAction("<env>", self, statusTip="", triggered=self._on_add_env_tag)
    tag_menu.addAction(add_env_tag_action)
    # param tag
    add_param_tag_action = QtGui.QAction("<param>", self, statusTip="", triggered=self._on_add_param_tag)
    tag_menu.addAction(add_param_tag_action)
    # param tag with all attributes
    add_param_tag_all_action = QtGui.QAction("<param all>", self, statusTip="", triggered=self._on_add_param_tag_all)
    tag_menu.addAction(add_param_tag_all_action)
    # rosparam tag with all attributes
    add_rosparam_tag_all_action = QtGui.QAction("<rosparam>", self, statusTip="", triggered=self._on_add_rosparam_tag_all)
    tag_menu.addAction(add_rosparam_tag_all_action)
    # arg tag with default definition
    add_arg_tag_default_action = QtGui.QAction("<arg default>", self, statusTip="", triggered=self._on_add_arg_tag_default)
    tag_menu.addAction(add_arg_tag_default_action)
    # arg tag with value definition
    add_arg_tag_value_action = QtGui.QAction("<arg value>", self, statusTip="", triggered=self._on_add_arg_tag_value)
    tag_menu.addAction(add_arg_tag_value_action)

    # test tag
    add_test_tag_action = QtGui.QAction("<test>", self, statusTip="", triggered=self._on_add_test_tag)
    tag_menu.addAction(add_test_tag_action)
    # test tag with all attributes
    add_test_tag_all_action = QtGui.QAction("<test all>", self, statusTip="", triggered=self._on_add_test_tag_all)
    tag_menu.addAction(add_test_tag_all_action)


    btn.setMenu(tag_menu)
    return btn