当前位置: 首页>>代码示例>>Python>>正文


Python QMenu.exec_方法代码示例

本文整理汇总了Python中PySide.QtGui.QMenu.exec_方法的典型用法代码示例。如果您正苦于以下问题:Python QMenu.exec_方法的具体用法?Python QMenu.exec_怎么用?Python QMenu.exec_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide.QtGui.QMenu的用法示例。


在下文中一共展示了QMenu.exec_方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: tag_context_menu

# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import exec_ [as 别名]
 def tag_context_menu(self, pos):
     index = self.ui.tagsList.currentIndex()
     item = self.tagsModel.itemFromIndex(index)
     if hasattr(item, 'tag'):
         menu = QMenu(self.ui.tagsList)
         menu.addAction(QIcon.fromTheme('gtk-delete'), self.tr('Remove'), self.remove_tag)
         menu.exec_(self.ui.tagsList.mapToGlobal(pos))
开发者ID:AnderSilva,项目名称:everpad,代码行数:9,代码来源:list.py

示例2: showContextMenu

# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import exec_ [as 别名]
 def showContextMenu(self, point):
     'Show the Columns context menu'
     if self.model() is None:
         return
     
     # If we are viewing a proxy model, skip to the source model
     mdl = self.model()
     while isinstance(mdl, QAbstractProxyModel):
         mdl = mdl.sourceModel()
     
     if mdl is None or not hasattr(mdl, 'columns'):
         return
     
     # Generate and show the Menu
     m = QMenu()
     for i in range(len(mdl.columns)):
         c = mdl.columns[i]
         if c.internal:
             continue
         
         a = QAction(mdl.headerData(i, Qt.Horizontal, Qt.DisplayRole), m)
         a.setCheckable(True)
         a.setChecked(not self.isColumnHidden(i))
         a.triggered.connect(partial(self.showHideColumn, c=i, s=self.isColumnHidden(i)))
         m.addAction(a)
         
     m.exec_(self.header().mapToGlobal(point))
开发者ID:asymworks,项目名称:python-divelog,代码行数:29,代码来源:views.py

示例3: click

# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import exec_ [as 别名]
 def click(self, res, event):
     """Open resource"""
     button = event.button()
     if button == Qt.LeftButton:
         subprocess.Popen(['xdg-open', res.file_path])
     elif button == Qt.RightButton:
         menu = QMenu(self.parent)
         if res.mime.find('image') == 0:
             menu.addAction(
                 self.parent.tr('Put to Content'), Slot()(partial(
                     self.to_content, res=res,
                 )),
             )
         if not self.parent.note_edit.in_content(res):
             menu.addAction(
                 self.parent.tr('Remove Resource'), Slot()(partial(
                     self.remove, res=res,
                 ))
             )
         menu.addAction(
             self.parent.tr('Save As'), Slot()(partial(
                 self.save, res=res,
             ))
         )
         menu.exec_(event.globalPos())
开发者ID:altawu,项目名称:everpad,代码行数:27,代码来源:editor.py

示例4: notebook_context_menu

# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import exec_ [as 别名]
 def notebook_context_menu(self, pos):
     index = self.ui.notebooksList.currentIndex()
     item = self.notebooksModel.itemFromIndex(index)
     if hasattr(item, 'notebook'):
         menu = QMenu(self.ui.notebooksList)
         menu.addAction(QIcon.fromTheme('gtk-edit'), self.tr('Rename'), self.rename_notebook)
         menu.addAction(QIcon.fromTheme('gtk-delete'), self.tr('Remove'), self.remove_notebook)
         menu.exec_(self.ui.notebooksList.mapToGlobal(pos))
开发者ID:berzjackson,项目名称:everpad,代码行数:10,代码来源:list.py

示例5: HierarchyTreeView

# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import exec_ [as 别名]
class HierarchyTreeView(QTreeView):


    def __init__(self):
        super(HierarchyTreeView, self).__init__()
        
        #ukljucuje kontekstni meni
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.openMenu)
        
    
    def openMenu(self, position):
        self.contextMenu = QMenu()
        newMenu = QMenu("New") 
        self.contextMenu.addMenu(newMenu)
        
        actionNewProj = QAction("NewProject", None)
        actionNewProj.triggered.connect(self.addNode)
        
        actionRename = QAction("Rename", None)
        actionRename.triggered.connect(self.renameNode)
        
        actionRemProj = QAction("Delete", None)
        actionRemProj.triggered.connect(self.removeNode)
        
        newMenu.addAction(actionNewProj)
        self.contextMenu.addAction(actionRename)
        self.contextMenu.addAction(actionRemProj)
        
        #prikaz kontekstnog menija
        self.contextMenu.exec_(self.viewport().mapToGlobal(position))
        
    def addNode(self):
        model = self.model()
        
        node = Node("NoviCvor")
        
        
        
        if not self.currentIndex().isValid():
            model.insertRow(model.rowCount(self.currentIndex()), node)
        else:
            model.insertRow(model.rowCount(self.currentIndex()), node, self.currentIndex())
        self.expand(self.currentIndex())
    
    def removeNode(self):
        model = self.model()
        model.removeRow(self.currentIndex().internalPointer().getIndex(), self.currentIndex().parent())    
        
    def renameNode(self):
        self.currentIndex().internalPointer().setName("NOVO")
    
    
    def mousePressEvent(self, event):
        if(self.selectionMode() == QAbstractItemView.SingleSelection):
            self.clearSelection()
            self.setCurrentIndex(QModelIndex())
        super(HierarchyTreeView, self).mousePressEvent(event)
开发者ID:satishgoda,项目名称:SimulationZ,代码行数:60,代码来源:hierarchy_tree_view.py

示例6: __LobbyListMenu

# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import exec_ [as 别名]
    def __LobbyListMenu( self, position ):
        lobby_menu      = QMenu()

        rm_from_lobby   = QAction( self )
        rm_from_lobby.setText( "Remove player from lobby" )
        rm_from_lobby.triggered.connect( self._RemoveFromLobbyListAction )

        lobby_menu.addAction( rm_from_lobby )

        lobby_menu.exec_( self.window.lobby_lst.viewport().mapToGlobal( position ) )
开发者ID:montreal91,项目名称:workshop,代码行数:12,代码来源:main.py

示例7: _handle_context_menu

# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import exec_ [as 别名]
 def _handle_context_menu(self, pos):
     index = self.ui.tree_view.indexAt(pos)
     if index.isValid():
         pos = self.ui.tree_view.viewport().mapToGlobal(pos)
         menu = QMenu()
         menu.addAction(self.ui.action_mark_watched)
         menu.addAction(self.ui.action_mark_unwatched)
         menu.addSeparator()
         menu.addAction(self.ui.action_remove)
         menu.exec_(pos)
开发者ID:toroettg,项目名称:SeriesMarker,代码行数:12,代码来源:main_window.py

示例8: click

# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import exec_ [as 别名]
 def click(self, res, event):
     """Open resource"""
     button = event.button()
     if button == Qt.LeftButton:
         subprocess.Popen(["xdg-open", res.file_path])
     elif button == Qt.RightButton:
         menu = QMenu(self.parent)
         if not res.in_content:
             menu.addAction(self.parent.tr("Remove Resource"), Slot()(partial(self.remove, res=res)))
         menu.addAction(self.parent.tr("Save As"), Slot()(partial(self.save, res=res)))
         menu.exec_(event.globalPos())
开发者ID:fabianofranz,项目名称:everpad,代码行数:13,代码来源:editor.py

示例9: contextMenuEvent

# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import exec_ [as 别名]
    def contextMenuEvent(self, event):
        """
        Handles the ``contextMenuEvent`` event for :class:`CmdPromptInput`.

        :param `event`: a `QContextMenuEvent` event to be processed.
        """
        menu = QMenu(self)
        menu.addSeparator()
        # TODO: Extra stuff
        menu.addAction(QAction("TODO: Add Extra stuff", self))
        menu.exec_(event.globalPos())
开发者ID:JTrantow,项目名称:Embroidermodder,代码行数:13,代码来源:cmdprompt.py

示例10: send_to_popup

# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import exec_ [as 别名]
 def send_to_popup(self):
     drive_option=QMenu(self.parent())
     opts=config.SEND_TO[0:(len(config.SEND_TO)-1)]
     for cnf in opts:
         k=QAction(QIcon(appicon("explore")),cnf,self )
         k.triggered.connect(self.click_event)
         drive_option.addAction(k)
     drive_option.exec_(QtGui.QCursor.pos())
     
     
     
     
     
     
开发者ID:mkawserm,项目名称:iMovMan,代码行数:10,代码来源:moviemenu.py

示例11: __PlayersListMenu

# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import exec_ [as 别名]
    def __PlayersListMenu( self, position ):
        list_menu           = QMenu()

        add_player_to_lobby = QAction( self )
        add_player_to_lobby.setText( "Add player to lobby" )
        add_player_to_lobby.triggered.connect( self._AddToLobbyAction )

        rm_player           = QAction( self )
        rm_player.setText( "Remove player" )
        rm_player.triggered.connect( self._RemoveFromPlayersListAction )

        list_menu.addAction( rm_player )
        list_menu.addAction( add_player_to_lobby )

        list_menu.exec_( self.window.players_lst.viewport().mapToGlobal( position ) )
开发者ID:montreal91,项目名称:workshop,代码行数:17,代码来源:main.py

示例12: mousePressEvent

# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import exec_ [as 别名]
    def mousePressEvent(self, mouse_event):
        if mouse_event.button() == Qt.RightButton:
            if self._spec_index is None:
                print("spec_index is None")
                print(self)
                print(self._running_providers)
                return
            pos = mouse_event.pos()
            items = [item for item in self.items(pos) if isinstance(item, NodeItem) and item._label.text()]
            if len(items) != 1:
                print("wrong number of things", [x._label.text() for x in items])
                return

            name = items[0]._label.text().rstrip('(default)').strip()
            if name not in self._spec_index.provider_names:
                print(name, "Not in list of providers")
                return
            provider = self._spec_index.providers[name]

            def start_trigger():
                # TODO: replace 'capability_server' with user provided server name
                service_name = '/{0}/start_capability'.format('capability_server')
                rospy.wait_for_service(service_name)
                start_capability = rospy.ServiceProxy(service_name, StartCapability)
                start_capability(provider.implements, name)

            def stop_trigger():
                # TODO: replace 'capability_server' with user provided server name
                service_name = '/{0}/stop_capability'.format('capability_server')
                rospy.wait_for_service(service_name)
                stop_capability = rospy.ServiceProxy(service_name, StopCapability)
                stop_capability(provider.implements)

            if name not in self._running_providers:
                trigger = start_trigger
                msg = "start => "
            else:
                trigger = stop_trigger
                msg = "stop => "

            menu = QMenu()
            action = menu.addAction(msg + name)
            action.triggered.connect(trigger)
            pos = mouse_event.globalPos()
            pos = QPoint(pos.x(), pos.y())
            menu.exec_(pos)
        else:
            InteractiveGraphicsView.mousePressEvent(self, mouse_event)
开发者ID:jihoonl,项目名称:rqt_capabilities,代码行数:50,代码来源:graphics_view.py

示例13: contextMenuEvent

# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import exec_ [as 别名]
 def contextMenuEvent(self, event):
     ''' When user right-clicks: display context menu '''
     png_action = 'Export branch to PNG, SVG or PDF'
     hl_action = 'Hyperlink'
     my_menu = QMenu(png_action)
     if not hasattr(self, '_no_hyperlink'):
         my_menu.addAction(hl_action)
     my_menu.addAction(png_action)
     action = my_menu.exec_(event.screenPos())
     if action:
         if action.text() == png_action:
             # Save a picture of the selected symbol and all its children
             filename = QFileDialog.getSaveFileName(self.window(),
                     'Export picture', '.',
                     'Picture (*.png, *.svg, *.pdf)')[0]
             if not filename:
                 return
             save_fmt = filename.split(os.extsep)[-1]
             if save_fmt not in ('png', 'svg', 'pdf'):
                 return
             self.scene().export_branch_to_picture(self, filename, save_fmt)
         elif action.text() == hl_action:
             if self.text:
                 self.hyperlink_dialog.setParent(
                         self.scene().views()[0], Qt.Dialog)
                 self.hlink_field.setText(self.text.hyperlink)
                 self.hyperlink_dialog.show()
开发者ID:blipvert,项目名称:opengeode,代码行数:29,代码来源:genericSymbols.py

示例14: popup

# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import exec_ [as 别名]
    def popup(self,pos):
        menu = QMenu()

        saveRepAction = QAction(self)
        saveRepAction.setText('Save representation...')
        saveRepAction.triggered.connect(lambda: self.saveRep(self.indexAt(pos)))
        menu.addAction(saveRepAction)
        action = menu.exec_(self.mapToGlobal(pos))
开发者ID:mmcauliffe,项目名称:exemplar-network-explorer,代码行数:10,代码来源:views.py

示例15: contextMenuEvent

# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import exec_ [as 别名]
 def contextMenuEvent(self, e):
     ''' calls context menu if right click:
      - set server
      - trigger server (storts or stops the server)
     in case of righ click on point, a plot is added
     '''
     i = 0
     for pp in self.points:
         i += 1
         if (e.pos()-pp).manhattanLength() > 5:
             continue
         else:
             self.addPlot(str(i))
             return
     menu = QMenu()
     menu.addAction("Set Server", self.setServer)
     menu.addAction("Trigger Server", self.stream)
     menu.exec_(e.globalPos())
开发者ID:Yakisoba007,项目名称:PyTrigno,代码行数:20,代码来源:plotter.py


注:本文中的PySide.QtGui.QMenu.exec_方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。