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


Python QToolButton.setToolButtonStyle方法代码示例

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


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

示例1: create_toolbutton

# 需要导入模块: from qtpy.QtWidgets import QToolButton [as 别名]
# 或者: from qtpy.QtWidgets.QToolButton import setToolButtonStyle [as 别名]
def create_toolbutton(parent,
                      text=None,
                      shortcut=None,
                      icon=None,
                      tip=None,
                      toggled=None,
                      triggered=None,
                      autoraise=True,
                      text_beside_icon=False):
    """Create a QToolButton"""
    button = QToolButton(parent)
    if text is not None:
        button.setText(text)
    if icon is not None:
        if is_text_string(icon):
            icon = get_icon(icon)
        button.setIcon(icon)
    if text is not None or tip is not None:
        button.setToolTip(text if tip is None else tip)
    if text_beside_icon:
        button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
    button.setAutoRaise(autoraise)
    if triggered is not None:
        button.clicked.connect(triggered)
    if toggled is not None:
        button.toggled.connect(toggled)
        button.setCheckable(True)
    if shortcut is not None:
        button.setShortcut(shortcut)
    return button
开发者ID:yoyobbs,项目名称:spyder,代码行数:32,代码来源:qthelpers.py

示例2: action2button

# 需要导入模块: from qtpy.QtWidgets import QToolButton [as 别名]
# 或者: from qtpy.QtWidgets.QToolButton import setToolButtonStyle [as 别名]
def action2button(action, autoraise=True, text_beside_icon=False, parent=None):
    """Create a QToolButton directly from a QAction object"""
    if parent is None:
        parent = action.parent()
    button = QToolButton(parent)
    button.setDefaultAction(action)
    button.setAutoRaise(autoraise)
    if text_beside_icon:
        button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
    return button
开发者ID:DLlearn,项目名称:spyder,代码行数:12,代码来源:qthelpers.py

示例3: __init__

# 需要导入模块: from qtpy.QtWidgets import QToolButton [as 别名]
# 或者: from qtpy.QtWidgets.QToolButton import setToolButtonStyle [as 别名]
    def __init__(self, *args, **kwargs):
        super(MOSViewerToolbar, self).__init__(*args, **kwargs)
        self.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)

        # Define the toolbar actions
        self.cycle_previous_action = QAction(
            QIcon(os.path.join(ICON_DIR, "Previous-96.png")),
            "Previous", self)
        self.cycle_next_action = QAction(
            QIcon(os.path.join(ICON_DIR, "Next-96.png")),
            "Next", self)

        self.exposure_previous_action = QAction(
            QIcon(os.path.join(ICON_DIR, "Previous-96.png")),
            "Previous exp.", self)
        self.exposure_next_action = QAction(
            QIcon(os.path.join(ICON_DIR, "Next-96.png")),
            "Next exp.", self)

        # Include the dropdown widgets
        self.source_select = QComboBox()
        self.exposure_select = QComboBox()

        # Add the items to the toolbar
        self.addAction(self.cycle_previous_action)
        self.addAction(self.cycle_next_action)
        self.addWidget(self.source_select)
        self.addAction(self.exposure_previous_action)
        self.addAction(self.exposure_next_action)
        self.addWidget(self.exposure_select)

        # Include a button to open spectrum in specviz
        self.open_specviz = QAction(
            QIcon(os.path.join(ICON_DIR, "External-96.png")),
            "Open in SpecViz", self)

        # Create a tool button to hold the lock axes menu object
        tool_button = QToolButton(self)
        tool_button.setText("Axes Settings")
        tool_button.setIcon(QIcon(os.path.join(ICON_DIR, "Settings-96.png")))
        tool_button.setPopupMode(QToolButton.InstantPopup)
        tool_button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)

        # Create a menu for the axes settings drop down
        self.settings_menu = QMenu(self)

        # Add lock x axis action
        self.lock_x_action = QAction("Lock spectral axis",
                                     self.settings_menu)
        self.lock_x_action.setCheckable(True)

        # Add lock y axis action
        self.lock_y_action = QAction("Lock vertical displacement axis",
                                     self.settings_menu)
        self.lock_y_action.setCheckable(True)

        # Add the actions to the menu
        self.settings_menu.addAction(self.lock_x_action)
        self.settings_menu.addAction(self.lock_y_action)

        # Set the menu object on the tool button
        tool_button.setMenu(self.settings_menu)

        # Create a widget action object to hold the tool button, this way the
        # toolbar behaves the way it's expected to
        tool_button_action = QWidgetAction(self)
        tool_button_action.setDefaultWidget(tool_button)

        self.addAction(tool_button_action)
        self.addSeparator()
        self.addAction(self.open_specviz)
开发者ID:spacetelescope,项目名称:mosviz,代码行数:73,代码来源:toolbars.py


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