本文整理汇总了Python中qtpy.QtWidgets.QToolButton.setText方法的典型用法代码示例。如果您正苦于以下问题:Python QToolButton.setText方法的具体用法?Python QToolButton.setText怎么用?Python QToolButton.setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QToolButton
的用法示例。
在下文中一共展示了QToolButton.setText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_toolbutton
# 需要导入模块: from qtpy.QtWidgets import QToolButton [as 别名]
# 或者: from qtpy.QtWidgets.QToolButton import setText [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
示例2: create_tabwidget
# 需要导入模块: from qtpy.QtWidgets import QToolButton [as 别名]
# 或者: from qtpy.QtWidgets.QToolButton import setText [as 别名]
def create_tabwidget(self):
"""Create a new QTabWidget with a button to add new tabs"""
tabs = QTabWidget(self)
tabs.setMovable(True)
tabs.setTabsClosable(True)
# create a button to add new tabs
plus_btn = QToolButton(tabs)
plus_btn.setText('+')
plus_btn.clicked.connect(self.plus_button_clicked)
tabs.setCornerWidget(plus_btn, Qt.TopLeftCorner)
tabs.tabCloseRequested.connect(self.close_tab)
return tabs
示例3: FadingTipBox
# 需要导入模块: from qtpy.QtWidgets import QToolButton [as 别名]
# 或者: from qtpy.QtWidgets.QToolButton import setText [as 别名]
#.........这里部分代码省略.........
self.setLayout(layout)
self.set_funcs_before_fade_in([self._disable_widgets])
self.set_funcs_after_fade_in([self._enable_widgets, self.setFocus])
self.set_funcs_before_fade_out([self._disable_widgets])
self.setContextMenuPolicy(Qt.CustomContextMenu)
# signals and slots
# These are defined every time by the AnimatedTour Class
def _disable_widgets(self):
""" """
for widget in self.widgets:
widget.setDisabled(True)
def _enable_widgets(self):
""" """
self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint |
Qt.WindowStaysOnTopHint)
for widget in self.widgets:
widget.setDisabled(False)
if self.button_disable == 'previous':
self.button_previous.setDisabled(True)
self.button_home.setDisabled(True)
elif self.button_disable == 'next':
self.button_next.setDisabled(True)
self.button_end.setDisabled(True)
def set_data(self, title, content, current, image, run, frames=None,
step=None):
""" """
self.label_title.setText(title)
self.combo_title.clear()
self.combo_title.addItems(frames)
self.combo_title.setCurrentIndex(step)
# min_content_len = max([len(f) for f in frames])
# self.combo_title.setMinimumContentsLength(min_content_len)
# Fix and try to see how it looks with a combo box
self.label_current.setText(current)
self.button_current.setText(current)
self.label_content.setText(content)
self.image = image
if image is None:
self.label_image.setFixedHeight(1)
self.label_image.setFixedWidth(1)
else:
extension = image.split('.')[-1]
self.image = QPixmap(get_image_path(image), extension)
self.label_image.setPixmap(self.image)
self.label_image.setFixedSize(self.image.size())
if run is None:
self.button_run.setVisible(False)
else:
self.button_run.setDisabled(False)
self.button_run.setVisible(True)
# Refresh layout
self.layout().activate()
def set_pos(self, x, y):
""" """
示例4: __init__
# 需要导入模块: from qtpy.QtWidgets import QToolButton [as 别名]
# 或者: from qtpy.QtWidgets.QToolButton import setText [as 别名]
def __init__(self, *args, **kwargs):
super(MOSViewerToolbar, self).__init__(*args, **kwargs)
# self.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
# Define icon path
icon_path = os.path.join(os.path.dirname(__file__),
'ui', 'icons')
# Define the toolbar actions
self.cycle_previous_action = QAction(
QIcon(os.path.join(icon_path, "Previous-96.png")),
"Previous", self)
self.cycle_next_action = QAction(
QIcon(os.path.join(icon_path, "Next-96.png")),
"Next", self)
# Include the dropdown widget
self.source_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)
# Include a button to open spectrum in specviz
self.open_specviz = QAction(
QIcon(os.path.join(icon_path, "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_path, "Settings-96.png")))
tool_button.setPopupMode(QToolButton.MenuButtonPopup)
# 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 X Axis",
self.settings_menu)
self.lock_x_action.setCheckable(True)
# Add lock y axis action
self.lock_y_action = QAction("Lock Y 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)