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


Python QMenu.parent方法代码示例

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


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

示例1: tree_context_menu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import parent [as 别名]
    def tree_context_menu(self, point):
        mapped = self.view.splitter.mapFromParent(point)
        index = self.view.tree_view.indexAt(mapped)
        raw_data = self.view.tree_view.model().data(index, GenericTreeModel.ROLE_RAW_DATA)
        if raw_data:
            menu = QMenu(self.view)
            if raw_data['misc']['connection'].uid:
                action_view_in_wot = QAction(self.tr("View in Web of Trust"), menu)
                menu.addAction(action_view_in_wot)
                action_view_in_wot.triggered.connect(lambda c:
                                                        self.model.view_in_wot(raw_data['misc']['connection']))

                action_gen_revokation = QAction(self.tr("Save revokation document"), menu)
                menu.addAction(action_gen_revokation)
                action_gen_revokation.triggered.connect(lambda c:
                                                        self.action_save_revokation(raw_data['misc']['connection']))

                action_publish_uid = QAction(self.tr("Publish UID"), menu)
                menu.addAction(action_publish_uid)
                action_publish_uid.triggered.connect(lambda c:
                                                        self.publish_uid(raw_data['misc']['connection']))
                identity_published = self.model.identity_published(raw_data['misc']['connection'])
                action_publish_uid.setEnabled(not identity_published)

                action_export_identity = QAction(self.tr("Export identity document"), menu)
                menu.addAction(action_export_identity)
                action_export_identity.triggered.connect(lambda c:
                                                        self.export_identity_document(raw_data['misc']['connection']))

                action_leave = QAction(self.tr("Leave the currency"), menu)
                menu.addAction(action_leave)
                action_leave.triggered.connect(lambda c: self.send_leave(raw_data['misc']['connection']))
                action_leave.setEnabled(self.model.identity_is_member(raw_data['misc']['connection']))

            copy_pubkey = QAction(menu.tr("Copy pubkey to clipboard"), menu.parent())
            copy_pubkey.triggered.connect(lambda checked,
                                                 c=raw_data['misc']['connection']: \
                                                 NavigationModel.copy_pubkey_to_clipboard(c))
            menu.addAction(copy_pubkey)

            copy_pubkey_crc = QAction(menu.tr("Copy pubkey to clipboard (with CRC)"), menu.parent())
            copy_pubkey_crc.triggered.connect(lambda checked,
                                                     c=raw_data['misc']['connection']: \
                                              NavigationModel.copy_pubkey_to_clipboard_with_crc(c))
            menu.addAction(copy_pubkey_crc)

            action_remove = QAction(self.tr("Remove the connection"), menu)
            menu.addAction(action_remove)
            action_remove.triggered.connect(lambda c: self.remove_connection(raw_data['misc']['connection']))
            # Show the context menu.

            menu.popup(QCursor.pos())
开发者ID:duniter,项目名称:sakia,代码行数:54,代码来源:controller.py


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