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


Python QPushButton.setMenu方法代码示例

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


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

示例1: _make_export_button

# 需要导入模块: from qtpy.QtWidgets import QPushButton [as 别名]
# 或者: from qtpy.QtWidgets.QPushButton import setMenu [as 别名]
 def _make_export_button(self):
     """
     Makes the export button menu, containing a list of export
     types
     :return: The export button menu
     """
     export_button = QPushButton("Export")
     export_menu = QMenu()
     for text, extension in EXPORT_TYPES:
         export_menu.addAction(text, lambda ext=extension: self.presenter.export_plots_called(ext))
     export_button.setMenu(export_menu)
     return export_button
开发者ID:mantidproject,项目名称:mantid,代码行数:14,代码来源:view.py

示例2: _make_sort_button

# 需要导入模块: from qtpy.QtWidgets import QPushButton [as 别名]
# 或者: from qtpy.QtWidgets.QPushButton import setMenu [as 别名]
    def _make_sort_button(self):
        """
        Make the sort button, with separate groups for ascending and
        descending, sorting by name or last shown
        :return: The sort menu button
        """
        sort_button = QPushButton("Sort")
        sort_menu = QMenu()

        ascending_action = QAction("Ascending", sort_menu, checkable=True)
        ascending_action.setChecked(True)
        ascending_action.toggled.connect(self.presenter.set_sort_order)
        descending_action = QAction("Descending", sort_menu, checkable=True)

        order_group = QActionGroup(sort_menu)
        order_group.addAction(ascending_action)
        order_group.addAction(descending_action)

        number_action = QAction("Number", sort_menu, checkable=True)
        number_action.setChecked(True)
        number_action.toggled.connect(lambda: self.presenter.set_sort_type(Column.Number))
        name_action = QAction("Name", sort_menu, checkable=True)
        name_action.toggled.connect(lambda: self.presenter.set_sort_type(Column.Name))
        last_active_action = QAction("Last Active", sort_menu, checkable=True)
        last_active_action.toggled.connect(lambda: self.presenter.set_sort_type(Column.LastActive))

        sort_type_group = QActionGroup(sort_menu)
        sort_type_group.addAction(number_action)
        sort_type_group.addAction(name_action)
        sort_type_group.addAction(last_active_action)

        sort_menu.addAction(ascending_action)
        sort_menu.addAction(descending_action)
        sort_menu.addSeparator()
        sort_menu.addAction(number_action)
        sort_menu.addAction(name_action)
        sort_menu.addAction(last_active_action)

        sort_button.setMenu(sort_menu)
        return sort_button
开发者ID:mantidproject,项目名称:mantid,代码行数:42,代码来源:view.py


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