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


Python QAction.recent方法代码示例

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


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

示例1: add

# 需要导入模块: from qtpy.QtWidgets import QAction [as 别名]
# 或者: from qtpy.QtWidgets.QAction import recent [as 别名]
    def add(self, recent):
        remove_action = None
        for a in self.qactions:
            if a.recent == recent:
                remove_action = a
                break

        a = QAction("1: " + recent, self.filemenu, triggered=(lambda r=recent : lambda :self.open_wrapper(r))())
        a.recent = recent
        self.filemenu.insertAction (self.next_element, a)
        self.qactions.insert(0, a)
        self.next_element = a
        if remove_action:
            self.qactions.remove(remove_action)
            self.filemenu.removeAction(remove_action)

        for i, a in enumerate(self.qactions, 1):
            a.setText("%d: %s" % (i, a.recent))

        recent_lst = self.parent.load_setting('recent_lst', "").split(";")
        recent_lst.insert(0, recent)
        self.parent.save_setting('recent_lst', ";".join(recent_lst[:3]))
        if len(self.qactions) > self.max:
            a = self.qactions.pop()
            self.filemenu.removeAction(a)
开发者ID:madsmpedersen,项目名称:MMPE,代码行数:27,代码来源:recent_menu.py

示例2: __init__

# 需要导入模块: from qtpy.QtWidgets import QAction [as 别名]
# 或者: from qtpy.QtWidgets.QAction import recent [as 别名]
 def __init__(self, parent, filemenu, open_func, next_element, max=10):
     self.parent = parent
     self.filemenu = filemenu
     self.open_func = open_func
     self.next_element = next_element
     self.max = max
     self.qactions = []
     for i, recent in enumerate([r for r in self.parent.load_setting('recent_lst', "").split(";") if r], 1):
         a = QAction("%d: %s" % (i, recent), self.filemenu, triggered=(lambda r=recent : lambda :self.open_wrapper(r))())
         a.recent = recent
         self.qactions.append(a)
         self.filemenu.insertAction (self.next_element, a)
     if self.qactions:
         self.next_element = self.qactions[0]
开发者ID:madsmpedersen,项目名称:MMPE,代码行数:16,代码来源:recent_menu.py


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