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


Python QMenu.popup方法代码示例

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


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

示例1: show_context_menu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import popup [as 别名]
 def show_context_menu(self, event):
     index = self.renters_QTableView.indexAt(event)
     if index.isValid():
         menu = QMenu(self)
         menu.addAction('Edit Renter', lambda: self.edit_renter(index))
         menu.addAction('Remove Renter', lambda: self.remove_renter(index))
         menu.popup(QCursor.pos())
开发者ID:sztosz,项目名称:BookRenatal,代码行数:9,代码来源:UiRenters.py

示例2: build_tree_context_menu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import popup [as 别名]
 def build_tree_context_menu(self, point):
     # print(point)
     self.itemClicked = self.itemAt(point)
     if self.itemClicked is None:
         return
     # parent = self.itemClicked.parent()
     # if not parent:
     #     print(1)
     #     return
     # if parent.parent():
     #     print(2)
     #     return
     # print(self.itemClicked.get_res_data(), "()()()", self.itemClicked)
     menu = QMenu(self)
     action = QAction("查看C++类", self)
     action.triggered.connect(self.build_cpp_class)
     menu.addAction(action)
     action = QAction("查看C#类", self)
     action.triggered.connect(self.build_csharp_class)
     menu.addAction(action)
     menu.addSeparator()
     action = QAction("转换成二进制数据", self)
     action.triggered.connect(self.build_binrary_data)
     menu.addAction(action)
     action = QAction("转换成xml数据", self)
     action.triggered.connect(self.build_xml_data)
     menu.addAction(action)
     menu.popup(self.viewport().mapToGlobal(point))
     pass
开发者ID:tylerzhu,项目名称:ExcelConvert,代码行数:31,代码来源:convertlistUi.py

示例3: show_context_menu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import popup [as 别名]
    def show_context_menu(self, point):
        context_menu = QMenu(self)

        if self.indexAt(point):
            context_menu.addAction(self.delete_action)

        point = self.mapToGlobal(point)
        context_menu.popup(point)
开发者ID:mbarbon,项目名称:pugdebug,代码行数:10,代码来源:projects.py

示例4: contextMenuEvent

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import popup [as 别名]
 def contextMenuEvent(self, e):
     """ Event handler.
     """
     menu = QMenu(self)
     menu.addActions([self.load, self.remove, self.clearList])
     # show the menu only if the mouse is pointing a list item
     if self.itemAt(e.pos()):
         menu.popup(e.globalPos())
开发者ID:m-pilia,项目名称:wikied,代码行数:10,代码来源:VoiceList.py

示例5: history_context_menu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import popup [as 别名]
    def history_context_menu(self, point):
        index = self.table_history.indexAt(point)
        model = self.table_history.model()
        if index.isValid() and index.row() < model.rowCount(QModelIndex()):
            menu = QMenu(self.tr("Actions"), self)
            source_index = model.mapToSource(index)
            state_col = model.sourceModel().columns_types.index('state')
            state_index = model.sourceModel().index(source_index.row(),
                                                   state_col)
            state_data = model.sourceModel().data(state_index, Qt.DisplayRole)

            pubkey_col = model.sourceModel().columns_types.index('pubkey')
            pubkey_index = model.sourceModel().index(source_index.row(),
                                                    pubkey_col)
            pubkey = model.sourceModel().data(pubkey_index, Qt.DisplayRole)
            identity = yield from self.app.identities_registry.future_find(pubkey, self.community)

            transfer = model.sourceModel().transfers()[source_index.row()]
            if state_data == TransferState.REFUSED or state_data == TransferState.TO_SEND:
                send_back = QAction(self.tr("Send again"), self)
                send_back.triggered.connect(lambda checked, tr=transfer: self.send_again(checked, tr))
                send_back.setData(transfer)
                menu.addAction(send_back)

                cancel = QAction(self.tr("Cancel"), self)
                cancel.triggered.connect(self.cancel_transfer)
                cancel.setData(transfer)
                menu.addAction(cancel)
            else:
                if isinstance(identity, Identity):
                    informations = QAction(self.tr("Informations"), self)
                    informations.triggered.connect(self.menu_informations)
                    informations.setData(identity)
                    menu.addAction(informations)

                    add_as_contact = QAction(self.tr("Add as contact"), self)
                    add_as_contact.triggered.connect(self.menu_add_as_contact)
                    add_as_contact.setData(identity)
                    menu.addAction(add_as_contact)

                send_money = QAction(self.tr("Send money"), self)
                send_money.triggered.connect(self.menu_send_money)
                send_money.setData(identity)
                menu.addAction(send_money)

                if isinstance(identity, Identity):
                    view_wot = QAction(self.tr("View in Web of Trust"), self)
                    view_wot.triggered.connect(self.view_wot)
                    view_wot.setData(identity)
                    menu.addAction(view_wot)

            copy_pubkey = QAction(self.tr("Copy pubkey to clipboard"), self)
            copy_pubkey.triggered.connect(self.copy_pubkey_to_clipboard)
            copy_pubkey.setData(identity)
            menu.addAction(copy_pubkey)

            # Show the context menu.
            menu.popup(QCursor.pos())
开发者ID:zero-code,项目名称:sakia,代码行数:60,代码来源:transactions_tab.py

示例6: showMenu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import popup [as 别名]
 def showMenu(self,point):
         menu = QMenu(self)
         if self.locked:
             menu.addAction(QAction(QIcon(':icons/unlock.png'),"&Unlock", self, triggered=self.Unlock))
         else:
             menu.addAction(QAction(QIcon(':icons/lock.png'),"&Lock", self, triggered=self.Lock))
         menu.addAction(QAction(QIcon(':icons/settings.png'),"&Settings", self, triggered=self.dummy))
         menu.addAction(QAction(QIcon(':icons/quit.png'),"&Quit", self, triggered=QApplication.instance().quit))
         menu.popup(self.mapToGlobal(point))
开发者ID:rinaldus,项目名称:desktop-widget,代码行数:11,代码来源:desktop-widget.py

示例7: _context_menu_requested

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

        row_index = self._log_widget.table.rowAt(pos.y())
        if row_index >= 0:
            action_show_definition = QAction(get_icon('file-code-o'), 'Open data type &definition', self)
            action_show_definition.triggered.connect(lambda: self._show_data_type_definition(row_index))
            menu.addAction(action_show_definition)
            menu.popup(self._log_widget.table.mapToGlobal(pos))
开发者ID:UAVCAN,项目名称:gui_tool,代码行数:11,代码来源:window.py

示例8: DownloadTableWidget

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import popup [as 别名]
class DownloadTableWidget(QTableWidget):
    def __init__(self, parent):
        super().__init__()
# creating context menu
        self.tablewidget_menu = QMenu(self)
        self.sendMenu = self.tablewidget_menu.addMenu('')

    def contextMenuEvent(self, event):
        self.tablewidget_menu.popup(QtGui.QCursor.pos())
开发者ID:alireza-amirsamimi,项目名称:persepolis,代码行数:11,代码来源:mainwindow_ui.py

示例9: customMenuRequested

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import popup [as 别名]
 def customMenuRequested(self, pos):
     menu = QMenu(self)
     row = self.currentWidget().indexAt(pos).row()
     song = self.currentWidget().model().getDataAtRow(row)
     self.editAct.setData(song)
     self.removeAct.setData((self.currentWidget().model().getUuid(), row))
     menu.addAction(self.editAct)
     menu.addAction(self.removeAct)
     menu.popup(self.mapToGlobal(pos))
开发者ID:gdankov,项目名称:sonance-music-player,代码行数:11,代码来源:widgets.py

示例10: on_treeWidget_node_customContextMenuRequested

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import popup [as 别名]
 def on_treeWidget_node_customContextMenuRequested(self, pos):
     if self.conn and self.ui.treeWidget_node.selectedItems():
         popMenu =QMenu(self)
         popMenu.addAction(self.ui.actionRdSnCfg)
         popMenu.addAction(self.ui.actionRdVerInfo)
         if self.__whosyourdaddy:
             popMenu.addAction(self.ui.actionRdbgPoolType)
             popMenu.addSeparator()
             popMenu.addAction(self.ui.actionEraseParam)
         popMenu.popup(QCursor.pos())
开发者ID:zaazbb,项目名称:YM001NetworkAnalyzer,代码行数:12,代码来源:mainwindow.py

示例11: mouseReleaseEvent

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import popup [as 别名]
    def mouseReleaseEvent(self, QMouseEvent):
        if QMouseEvent.button() == Qt.RightButton:
            menu = QMenu(self)

            action = QAction('Desactivate', self) if self.isEffective else QAction('Activate', self)
            activate = not self.isEffective
            action.triggered.connect(partial(self.updateAlarmState, activate))

            menu.addAction(action)
            menu.popup(QCursor.pos())
开发者ID:Subaru-PFS,项目名称:ics_sps_engineering_monitorData,代码行数:12,代码来源:alarmgb.py

示例12: popupMenu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import popup [as 别名]
    def popupMenu(self, pos):
        i = self.list.itemAt(pos)
        m = QMenu(self)
        if i:
            m.addAction(self.tr("Restore")).triggered.connect(self.restore)
            m.addAction(self.tr("Delete")).triggered.connect(self.delete)
            m.addSeparator()
        if self.list.count():
            m.addAction(self.tr("Clear all")).triggered.connect(self.clearAll)

        m.popup(self.list.mapToGlobal(pos))
开发者ID:olivierkes,项目名称:manuskript,代码行数:13,代码来源:revisions.py

示例13: mouseReleaseEvent

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import popup [as 别名]
    def mouseReleaseEvent(self, QMouseEvent):
        if QMouseEvent.button() == Qt.RightButton:
            menu = QMenu(self)

            all_modes = [f[:-4] for f in next(os.walk(self.mainWindow.alarmPath))[-1] if '.cfg' in f]
            for mode in all_modes:
                action = QAction(mode, self)
                action.triggered.connect(partial(self.updateMode, mode))
                menu.addAction(action)

            menu.popup(QCursor.pos())
开发者ID:Subaru-PFS,项目名称:ics_sps_engineering_monitorData,代码行数:13,代码来源:module.py

示例14: CategoryTreeView

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import popup [as 别名]
class CategoryTreeView(QTreeView):
    def __init__(self, parent):
        super().__init__()
# creating context menu
        self.category_tree_menu = QMenu(self)

# connecting actication  event
        self.activated.connect(parent.categoryTreeSelected)
        self.pressed.connect(parent.categoryTreeSelected)

    def contextMenuEvent(self, event):
        self.category_tree_menu.popup(QtGui.QCursor.pos())
开发者ID:alireza-amirsamimi,项目名称:persepolis,代码行数:14,代码来源:mainwindow_ui.py

示例15: SEToolsTreeWidget

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import popup [as 别名]
class SEToolsTreeWidget(QTreeWidget):

    """QTreeWidget class extended for SETools use."""

    def __init__(self, parent):
        super(SEToolsTreeWidget, self).__init__(parent)

        # set up right-click context menu
        self.copy_tree_action = QAction("Copy Tree...", self)
        self.menu = QMenu(self)
        self.menu.addAction(self.copy_tree_action)

        # connect signals
        self.copy_tree_action.triggered.connect(self.copy_tree)

    def contextMenuEvent(self, event):
        self.menu.popup(QCursor.pos())

    def copy_tree(self):
        """Copy the tree to the clipboard."""

        items = []
        inval_index = QModelIndex()
        it = QTreeWidgetItemIterator(self)
        prev_depth = 0
        while it.value():
            depth = 0
            item = it.value()
            parent = item.parent()
            while parent:
                depth += 1
                parent = parent.parent()

            if depth < prev_depth:
                items.extend(["  |"*depth, "\n"])

            if depth:
                items.extend(["  |"*depth, "--", item.text(0), "\n"])
            else:
                items.extend([item.text(0), "\n"])

            prev_depth = depth
            it += 1

        QApplication.clipboard().setText("".join(items))

    def event(self, e):
        if e == QKeySequence.Copy or e == QKeySequence.Cut:
            self.copy_tree()
            return True
        else:
            return super(SEToolsTreeWidget, self).event(e)
开发者ID:TresysTechnology,项目名称:setools,代码行数:54,代码来源:treeview.py


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