本文整理汇总了Python中PyQt5.QtWidgets.QToolButton方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QToolButton方法的具体用法?Python QtWidgets.QToolButton怎么用?Python QtWidgets.QToolButton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets
的用法示例。
在下文中一共展示了QtWidgets.QToolButton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolButton [as 别名]
def __init__(self, items, parent=None):
super(ButtonLineEdit, self).__init__(parent)
self.menu = QtWidgets.QMenu()
for i in items:
self.menu.addAction(i)
self.button = QtWidgets.QToolButton(self)
self.button.setStyleSheet('border: 0px; padding: 0px;')
self.button.setCursor(QtCore.Qt.ArrowCursor)
self.button.triggered.connect(self.menu_action_triggered)
self.button.setPopupMode(QtWidgets.QToolButton.InstantPopup)
self.button.setMenu(self.menu)
frameWidth = self.style().pixelMetric(QtWidgets.QStyle.PM_DefaultFrameWidth)
buttonSize = self.button.sizeHint()
self.setAlignment(QtCore.Qt.Alignment(QtCore.Qt.AlignHCenter))
self.setStyleSheet('QLineEdit {padding-right: %dpx; }' % (buttonSize.width() + frameWidth + 1))
self.setMinimumSize(max(self.minimumSizeHint().width(), buttonSize.width() + frameWidth*2 + 2),
max(self.minimumSizeHint().height(), buttonSize.height() + frameWidth*2 + 2))
self.setMaximumWidth(100)
示例2: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolButton [as 别名]
def __init__(self, parent):
self.parent = parent
self.parentTab = self.parent.parent
self.searchThread = BackGroundTextSearch()
self.searchOptionsLayout = QtWidgets.QHBoxLayout()
self.searchTabLayout = QtWidgets.QVBoxLayout()
self.searchTimer = QtCore.QTimer(self.parent)
self.searchLineEdit = QtWidgets.QLineEdit(self.parent)
self.searchBookButton = QtWidgets.QToolButton(self.parent)
self.caseSensitiveSearchButton = QtWidgets.QToolButton(self.parent)
self.matchWholeWordButton = QtWidgets.QToolButton(self.parent)
self.searchResultsTreeView = QtWidgets.QTreeView(self.parent)
self._translate = QtCore.QCoreApplication.translate
self.search_string = self._translate('SideDock', 'Search')
self.search_book_string = self._translate('SideDock', 'Search entire book')
self.case_sensitive_string = self._translate('SideDock', 'Match case')
self.match_word_string = self._translate('SideDock', 'Match word')
self.create_widgets()
示例3: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolButton [as 别名]
def __init__(self, parent=None):
super(DragButton, self).__init__(parent)
# def mouseMoveEvent(self, event):
# self.startDrag()
# QtWidgets.QToolButton.mouseMoveEvent(self, event)
# def startDrag(self):
# if self.icon().isNull():
# return
# data = QtCore.QByteArray()
# stream = QtCore.QDataStream(data, QtCore.QIODevice.WriteOnly)
# stream << self.icon()
# mimeData = QtCore.QMimeData()
# mimeData.setData("application/x-equipment", data)
# drag = QtGui.QDrag(self)
# drag.setMimeData(mimeData)
# pixmap = self.icon().pixmap(24, 24)
# drag.setHotSpot(QtCore.QPoint(12, 12))
# drag.setPixmap(pixmap)
# drag.exec_(QtCore.Qt.CopyAction)
示例4: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolButton [as 别名]
def __init__(self, default_directory='', parent=None):
super().__init__(parent)
button = QtWidgets.QToolButton()
button.setText('...')
button.clicked.connect(self.set_folder)
if not default_directory:
default_directory = os.getcwd()
self.lineEdit = QtWidgets.QToolButton()
self.lineEdit.setText(default_directory)
layout = QtWidgets.QHBoxLayout()
layout.addWidget(self.lineEdit, 85)
layout.addWidget(button, 15)
self.setLayout(layout)
示例5: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolButton [as 别名]
def __init__(self, *args, **kwargs):
QWidget.__init__(self, *args, **kwargs)
self.setLayout(QVBoxLayout())
self.taglist = TagList()
self.taglist.tagsUpdated.connect(self.tagsUpdated)
self.layout().addWidget(self.taglist)
self.taginput = QLineEdit()
self.taginput.returnPressed.connect(self.add_tag)
self.addbutton = QToolButton()
self.addbutton.setText("+")
self.removebutton = QToolButton()
self.removebutton.setText("-")
editbar = QHBoxLayout()
editbar.addWidget(self.addbutton)
editbar.addWidget(self.removebutton)
editbar.addWidget(self.taginput)
self.removebutton.clicked.connect(self.taglist.delete_selected)
self.addbutton.clicked.connect(self.add_tag)
self.layout().addLayout(editbar)
示例6: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolButton [as 别名]
def __init__(self, *args, **kwargs):
QWidget.__init__(self, *args, **kwargs)
self.str2_shown = False
self.str1 = StringCmpWidget()
self.str2 = StringCmpWidget()
self.str1.returnPressed.connect(self.returnPressed)
self.str2.returnPressed.connect(self.returnPressed)
self.toggle_button = QToolButton()
self.toggle_button.setText("+")
self.toggle_button.clicked.connect(self._show_hide_str2)
layout = QHBoxLayout()
layout.addWidget(self.str1)
layout.addWidget(self.str2)
layout.addWidget(self.toggle_button)
self.str2.setVisible(self.str2_shown)
self.setLayout(layout)
self.layout().setContentsMargins(0, 0, 0, 0)
示例7: add_button
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolButton [as 别名]
def add_button(self, button):
'''
Adds a button to the right side of the QLineEdit.
Args:
button: Type QtWidgets.QPushButton or QtWidgets.QToolButton
'''
self.buttons.append(button)
# makes sure text doesn't type behind the buttons
totalWidth = sum([b.sizeHint().width() for b in self.buttons])
frameWidth = self.style().pixelMetric(QtWidgets.QStyle.PM_DefaultFrameWidth)
right_padding = int(totalWidth + frameWidth + 1)
self.setStyleSheet(f'QLineEdit {{padding-right: {right_padding}px; }}')
# makes sure the typing area doesn't get too small if toolbar is shrunk.
maxHeight = max([b.sizeHint().height() for b in self.buttons])
self.setMinimumSize(max(self.minimumSizeHint().width(), totalWidth + frameWidth * 2 + 2),
max(self.minimumSizeHint().height(), maxHeight + frameWidth * 2 + 2))
示例8: _set_cancel_button
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolButton [as 别名]
def _set_cancel_button(self):
self.cancel_button = QToolButton(self)
self.cancel_button.setIcon(QIcon(ICON_PATH_CANCEL))
self.cancel_button.setVisible(False)
示例9: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolButton [as 别名]
def __init__(self, sandbox, parent=None):
QtWidgets.QToolButton.__init__(self, parent)
menu = self.SourcesAddMenu(sandbox, self, 'Availables sources')
self.setText('Add Source')
self.setMenu(menu)
self.setIcon(self.style().standardIcon(
QtGui.QStyle.SP_FileDialogDetailedView))
self.setPopupMode(QtGui.QToolButton.InstantPopup)
self.setToolButtonStyle(QtCore.Qt.ToolButtonTextOnly)
示例10: init_ui
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolButton [as 别名]
def init_ui(self):
layout = QHBoxLayout(self)
self.first_page_btn = QToolButton(self)
self.first_page_btn.clicked.connect(self._on_first_page_btn_clicked)
self.first_page_btn.setArrowType(Qt.LeftArrow)
self.first_page_btn.setToolTip("First page")
layout.addWidget(self.first_page_btn)
self.prev_page_btn = QToolButton(self)
self.prev_page_btn.clicked.connect(self._on_prev_page_btn_clicked)
self.prev_page_btn.setArrowType(Qt.LeftArrow)
self.prev_page_btn.setToolTip("Previous page")
layout.addWidget(self.prev_page_btn)
self.page_edit = QLineEdit("1")
self.page_edit.setMaximumSize(45, 24)
self.page_edit.returnPressed.connect(
lambda: self.set_current_page(self.page_edit.text())
)
layout.addWidget(self.page_edit)
self.next_page_btn = QToolButton(self)
self.next_page_btn.clicked.connect(self._on_next_page_btn_clicked)
self.next_page_btn.setArrowType(Qt.RightArrow)
self.next_page_btn.setToolTip("Next page")
layout.addWidget(self.next_page_btn)
self.last_page_btn = QToolButton(self)
self.last_page_btn.clicked.connect(self._on_last_page_btn_clicked)
self.last_page_btn.setArrowType(Qt.RightArrow)
self.last_page_btn.setToolTip("Last page")
layout.addWidget(self.last_page_btn)
self.status_label = QLabel("")
layout.addWidget(self.status_label)
示例11: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolButton [as 别名]
def __init__(self, equipment, parent=None):
"""constructor
equipment: equipment class where the widget have to be put, define
indiceCostos as a index in costIndex"""
super(CostData, self).__init__(parent)
self.indice = equipment.indiceCostos
factor = equipment.kwargs["f_install"]
gridLayout = QtWidgets.QGridLayout(self)
gridLayout.addItem(QtWidgets.QSpacerItem(
20, 20, QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Expanding), 1, 0, 1, 7)
gridLayout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
"pychemqt", "Instalation factor:")), 2, 0, 1, 1)
self.factorInstalacion = Entrada_con_unidades(
float, spinbox=True, decimales=1, step=0.1, width=50, value=factor)
self.factorInstalacion.valueChanged.connect(partial(
self.valueChanged.emit, "f_install"))
gridLayout.addWidget(self.factorInstalacion, 2, 1, 1, 1)
gridLayout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
"pychemqt", "Base index:")), 2, 4, 1, 1)
self.indiceBase = Entrada_con_unidades(
float, readOnly=True, value=indiceBase[self.indice], decimales=1)
gridLayout.addWidget(self.indiceBase, 2, 5, 1, 1)
gridLayout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
"pychemqt", "Current index:")), 3, 4, 1, 1)
self.indiceActual = Entrada_con_unidades(
float, readOnly=True, colorReadOnly="white",
value=indiceActual[self.indice], decimales=1)
gridLayout.addWidget(self.indiceActual, 3, 5, 1, 1)
self.costIndex = QtWidgets.QToolButton()
self.costIndex.setFixedSize(QtCore.QSize(24, 24))
self.costIndex.clicked.connect(self.on_costIndex_clicked)
self.costIndex.setText("...")
self.costIndex.setVisible(False)
gridLayout.addWidget(self.costIndex, 3, 5, 1, 1)
gridLayout.addItem(QtWidgets.QSpacerItem(
20, 20, QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Expanding), 4, 0, 1, 7)
示例12: initWidgets
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolButton [as 别名]
def initWidgets(self):
"""
Configure application built-in widgets.
"""
button = QtWidgets.QToolButton(objectName='button_set_brush')
button.setIcon(QtGui.QIcon(':/icons/24/ic_format_color_fill_black'))
button.setMenu(self.menu('brush'))
button.setPopupMode(QtWidgets.QToolButton.InstantPopup)
button.setStatusTip('Change the background color of the selected predicate nodes')
button.setEnabled(False)
self.addWidget(button)
combobox = ComboBox(objectName='profile_switch')
combobox.setEditable(False)
combobox.setFont(Font('Roboto', 12))
combobox.setFocusPolicy(QtCore.Qt.StrongFocus)
combobox.setScrollEnabled(False)
combobox.setStatusTip('Change the profile of the active project')
combobox.addItems(self.profileNames())
connect(combobox.activated, self.doSetProfile)
self.addWidget(combobox)
progressBar = QtWidgets.QProgressBar(objectName='progress_bar')
progressBar.setContentsMargins(0, 0, 0, 0)
progressBar.setFixedSize(222, 14)
progressBar.setRange(0, 0)
progressBar.setVisible(False)
self.addWidget(progressBar)
#############################################
# SLOTS
#################################
示例13: start
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolButton [as 别名]
def start(self):
"""
Perform initialization tasks for the plugin.
"""
# INITIALIZE THE WIDGETS
self.debug('Creating zoom control widgets')
self.addWidget(QtWidgets.QToolButton(
icon=QtGui.QIcon(':/icons/24/ic_zoom_in_black'),
enabled=False, checkable=False, clicked=self.doZoomIn,
objectName='button_zoom_in'))
self.addWidget(QtWidgets.QToolButton(
icon=QtGui.QIcon(':/icons/24/ic_zoom_out_black'),
enabled=False, checkable=False, clicked=self.doZoomOut,
objectName='button_zoom_out'))
self.addWidget(QtWidgets.QToolButton(
icon=QtGui.QIcon(':/icons/24/ic_zoom_reset_black'),
enabled=False, checkable=False, clicked=self.doZoomReset,
objectName='button_zoom_reset'))
# CONFIGURE SIGNALS/SLOTS
self.debug('Configuring session and MDI area specific signals/slots')
connect(self.session.mdi.subWindowActivated, self.onSubWindowActivated)
connect(self.session.sgnUpdateState, self.doUpdateState)
# CREATE VIEW TOOLBAR BUTTONS
self.debug('Installing zoom controls in "view" toolbar')
self.afwset.add(self.session.widget('view_toolbar').addSeparator())
self.afwset.add(self.session.widget('view_toolbar').addWidget(self.widget('button_zoom_out')))
self.afwset.add(self.session.widget('view_toolbar').addWidget(self.widget('button_zoom_in')))
self.afwset.add(self.session.widget('view_toolbar').addWidget(self.widget('button_zoom_reset')))
示例14: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolButton [as 别名]
def __init__(self, *args, **kwargs):
QWidget.__init__(self, *args, **kwargs)
self.setLayout(QVBoxLayout())
self.layout().setContentsMargins(0, 0, 0, 0)
self.listenerlist = ListenerList()
self.listenerlist.listenersUpdated.connect(self.listenersUpdated)
self.layout().addWidget(self.listenerlist)
self.hostinput = QLineEdit()
self.hostinput.setText("127.0.0.1")
self.hostinput.returnPressed.connect(self.add_listener)
self.portinput = QLineEdit()
self.portinput.setMaxLength(5)
self.portinput.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
self.portinput.returnPressed.connect(self.add_listener)
self.addbutton = QToolButton()
self.addbutton.setText("+")
self.removebutton = QToolButton()
self.removebutton.setText("-")
editbar = QHBoxLayout()
editbar.addWidget(self.addbutton)
editbar.addWidget(self.removebutton)
editbar.addWidget(QLabel("Interface:"))
editbar.addWidget(self.hostinput)
editbar.addWidget(QLabel("Port:"))
editbar.addWidget(self.portinput)
self.removebutton.clicked.connect(self.listenerlist.delete_selected)
self.addbutton.clicked.connect(self.add_listener)
self.layout().addLayout(editbar)
示例15: setupUi
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolButton [as 别名]
def setupUi(self, pop):
pop.setObjectName("pop")
pop.resize(442, 379)
self.gridLayout = QtWidgets.QGridLayout(pop)
self.gridLayout.setObjectName("gridLayout")
self.textEdit = QtWidgets.QTextEdit(pop)
self.textEdit.setObjectName("textEdit")
self.gridLayout.addWidget(self.textEdit, 1, 0, 1, 2)
self.pushButton = QtWidgets.QPushButton(pop)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/picture/resourses/btn_ok.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton.setIcon(icon)
self.pushButton.setObjectName("pushButton")
self.gridLayout.addWidget(self.pushButton, 2, 0, 1, 1)
self.pushButton_2 = QtWidgets.QPushButton(pop)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/picture/resourses/if_Delete_1493279.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton_2.setIcon(icon1)
self.pushButton_2.setObjectName("pushButton_2")
self.gridLayout.addWidget(self.pushButton_2, 2, 1, 1, 1)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.label = QtWidgets.QLabel(pop)
self.label.setObjectName("label")
self.horizontalLayout_2.addWidget(self.label)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem)
self.toolButton = QtWidgets.QToolButton(pop)
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(":/picture/resourses/interface-controls-text-wrap-512.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.toolButton.setIcon(icon2)
self.toolButton.setCheckable(True)
self.toolButton.setObjectName("toolButton")
self.horizontalLayout_2.addWidget(self.toolButton)
self.gridLayout.addLayout(self.horizontalLayout_2, 0, 0, 1, 2)
self.retranslateUi(pop)
QtCore.QMetaObject.connectSlotsByName(pop)