本文整理汇总了Python中qtpy.QtWidgets.QHBoxLayout.setSpacing方法的典型用法代码示例。如果您正苦于以下问题:Python QHBoxLayout.setSpacing方法的具体用法?Python QHBoxLayout.setSpacing怎么用?Python QHBoxLayout.setSpacing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QHBoxLayout
的用法示例。
在下文中一共展示了QHBoxLayout.setSpacing方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import setSpacing [as 别名]
def __init__(self, editor):
Panel.__init__(self, editor)
self._editor = editor
self._editor.sig_cursor_position_changed.connect(
self._handle_cursor_position_change_event
)
# The layout
hbox = QHBoxLayout()
self.class_cb = QComboBox()
self.method_cb = QComboBox()
hbox.addWidget(self.class_cb)
hbox.addWidget(self.method_cb)
hbox.setSpacing(0)
hbox.setContentsMargins(0, 0, 0, 0)
self.setLayout(hbox)
# Internal data
self.folds = None
self.parents = None
self.classes = None
self.funcs = None
# Initial data for the dropdowns.
self.class_cb.addItem("<None>", 0)
self.method_cb.addItem("<None>", 0)
# Attach some events.
self.class_cb.activated.connect(self.combobox_activated)
self.method_cb.activated.connect(self.combobox_activated)
示例2: SearchLineEdit
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import setSpacing [as 别名]
class SearchLineEdit(QLineEdit):
"""Line edit search widget with icon and remove all button"""
def __init__(self, parent=None, icon=True):
super(SearchLineEdit, self).__init__(parent)
self.setTextMargins(1, 0, 20, 0)
if icon:
self.setTextMargins(18, 0, 20, 0)
self._label = QLabel(self)
self._pixmap_icon = QPixmap(get_image_path('conda_search.png'))
self._label.setPixmap(self._pixmap_icon)
self._label.setStyleSheet('''border: 0px; padding-bottom: 0px;
padding-left: 2px;''')
self._pixmap = QPixmap(get_image_path('conda_del.png'))
self.button_clear = QToolButton(self)
self.button_clear.setIcon(QIcon(self._pixmap))
self.button_clear.setIconSize(QSize(18, 18))
self.button_clear.setCursor(Qt.ArrowCursor)
self.button_clear.setStyleSheet("""QToolButton
{background: transparent;
padding-right: 2px; border: none; margin:0px; }""")
self.button_clear.setVisible(False)
# Layout
self._layout = QHBoxLayout(self)
self._layout.addWidget(self.button_clear, 0, Qt.AlignRight)
self._layout.setSpacing(0)
self._layout.setContentsMargins(0, 2, 2, 0)
# Signals and slots
self.button_clear.clicked.connect(self.clear_text)
self.textChanged.connect(self._toggle_visibility)
self.textEdited.connect(self._toggle_visibility)
def _toggle_visibility(self):
""" """
if len(self.text()) == 0:
self.button_clear.setVisible(False)
else:
self.button_clear.setVisible(True)
def sizeHint(self):
return QSize(200, self._pixmap_icon.height())
# Public api
# ----------
def clear_text(self):
""" """
self.setText('')
self.setFocus()
示例3: __init__
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import setSpacing [as 别名]
def __init__(self, *args, **kwargs):
super(LineEditSearch, self).__init__(*args, **kwargs)
self._empty = True
self._show_icons = False
self.button_icon = ButtonSearch()
self.button_icon.setDefault(True)
self.button_icon.setFocusPolicy(Qt.NoFocus)
layout = QHBoxLayout()
layout.addWidget(self.button_icon, 0, Qt.AlignRight)
layout.setSpacing(0)
layout.addSpacing(2)
layout.setContentsMargins(0, 0, 0, 0)
self.setLayout(layout)
# Signals
self.textEdited.connect(self.update_box)
self.button_icon.clicked.connect(self.clear_text)
self.update_box(None)
self.set_icon_size(16, 16)
self.setTabOrder(self, self.button_icon)
示例4: setup_toolbar
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import setSpacing [as 别名]
def setup_toolbar(self):
"""Setup the toolbar"""
savefig_btn = create_toolbutton(
self, icon=ima.icon('filesave'),
tip=_("Save Image As..."),
triggered=self.save_figure)
saveall_btn = create_toolbutton(
self, icon=ima.icon('save_all'),
tip=_("Save All Images..."),
triggered=self.save_all_figures)
copyfig_btn = create_toolbutton(
self, icon=ima.icon('editcopy'),
tip=_("Copy plot to clipboard as image (%s)" %
get_shortcut('plots', 'copy')),
triggered=self.copy_figure)
closefig_btn = create_toolbutton(
self, icon=ima.icon('editclear'),
tip=_("Remove image"),
triggered=self.close_figure)
closeall_btn = create_toolbutton(
self, icon=ima.icon('filecloseall'),
tip=_("Remove all images from the explorer"),
triggered=self.close_all_figures)
vsep1 = QFrame()
vsep1.setFrameStyle(53)
goback_btn = create_toolbutton(
self, icon=ima.icon('ArrowBack'),
tip=_("Previous Figure ({})".format(
get_shortcut('plots', 'previous figure'))),
triggered=self.go_previous_thumbnail)
gonext_btn = create_toolbutton(
self, icon=ima.icon('ArrowForward'),
tip=_("Next Figure ({})".format(
get_shortcut('plots', 'next figure'))),
triggered=self.go_next_thumbnail)
vsep2 = QFrame()
vsep2.setFrameStyle(53)
zoom_out_btn = create_toolbutton(
self, icon=ima.icon('zoom_out'),
tip=_("Zoom out (Ctrl + mouse-wheel-down)"),
triggered=self.zoom_out)
zoom_in_btn = create_toolbutton(
self, icon=ima.icon('zoom_in'),
tip=_("Zoom in (Ctrl + mouse-wheel-up)"),
triggered=self.zoom_in)
self.zoom_disp = QSpinBox()
self.zoom_disp.setAlignment(Qt.AlignCenter)
self.zoom_disp.setButtonSymbols(QSpinBox.NoButtons)
self.zoom_disp.setReadOnly(True)
self.zoom_disp.setSuffix(' %')
self.zoom_disp.setRange(0, 9999)
self.zoom_disp.setValue(100)
self.figviewer.sig_zoom_changed.connect(self.zoom_disp.setValue)
zoom_pan = QWidget()
layout = QHBoxLayout(zoom_pan)
layout.setSpacing(0)
layout.setContentsMargins(0, 0, 0, 0)
layout.addWidget(zoom_out_btn)
layout.addWidget(zoom_in_btn)
layout.addWidget(self.zoom_disp)
return [savefig_btn, saveall_btn, copyfig_btn, closefig_btn,
closeall_btn, vsep1, goback_btn, gonext_btn, vsep2, zoom_pan]
示例5: PlotNameWidget
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import setSpacing [as 别名]
class PlotNameWidget(QWidget):
"""A widget to display the plot name, and edit and close buttons
This widget is added to the table widget to support the renaming
and close buttons, as well as the direct renaming functionality.
"""
def __init__(self, presenter, plot_number, parent=None):
super(PlotNameWidget, self).__init__(parent)
self.presenter = presenter
self.plot_number = plot_number
self.mutex = QMutex()
self.line_edit = QLineEdit(self.presenter.get_plot_name_from_number(plot_number))
self.line_edit.setReadOnly(True)
self.line_edit.setFrame(False)
self.line_edit.setStyleSheet("* { background-color: rgba(0, 0, 0, 0); }")
self.line_edit.setAttribute(Qt.WA_TransparentForMouseEvents, True)
self.line_edit.editingFinished.connect(self.rename_plot)
shown_icon = get_icon('mdi.eye')
self.hide_button = QPushButton(shown_icon, "")
self.hide_button.setToolTip('Hide')
self.hide_button.setFlat(True)
self.hide_button.setMaximumWidth(self.hide_button.iconSize().width() * 5 / 3)
self.hide_button.clicked.connect(self.toggle_visibility)
rename_icon = get_icon('mdi.square-edit-outline')
self.rename_button = QPushButton(rename_icon, "")
self.rename_button.setToolTip('Rename')
self.rename_button.setFlat(True)
self.rename_button.setMaximumWidth(self.rename_button.iconSize().width() * 5 / 3)
self.rename_button.setCheckable(True)
self.rename_button.toggled.connect(self.rename_button_toggled)
close_icon = get_icon('mdi.close')
self.close_button = QPushButton(close_icon, "")
self.close_button.setToolTip('Delete')
self.close_button.setFlat(True)
self.close_button.setMaximumWidth(self.close_button.iconSize().width() * 5 / 3)
self.close_button.clicked.connect(lambda: self.close_pressed(self.plot_number))
self.layout = QHBoxLayout()
# Get rid of the top and bottom margins - the button provides
# some natural margin anyway. Get rid of right margin and
# reduce spacing to get buttons closer together.
self.layout.setContentsMargins(5, 0, 0, 0)
self.layout.setSpacing(0)
self.layout.addWidget(self.line_edit)
self.layout.addWidget(self.hide_button)
self.layout.addWidget(self.rename_button)
self.layout.addWidget(self.close_button)
self.layout.sizeHint()
self.setLayout(self.layout)
def set_plot_name(self, new_name):
"""
Sets the internally stored and displayed plot name
:param new_name: The name to set
"""
self.line_edit.setText(new_name)
def close_pressed(self, plot_number):
"""
Close the plot with the given name
:param plot_number: The unique number in GlobalFigureManager
"""
self.presenter.close_single_plot(plot_number)
def rename_button_toggled(self, checked):
"""
If the rename button is pressed from being unchecked then
make the line edit item editable
:param checked: True if the rename toggle is now pressed
"""
if checked:
self.toggle_plot_name_editable(True, toggle_rename_button=False)
def toggle_plot_name_editable(self, editable, toggle_rename_button=True):
"""
Set the line edit item to be editable or not editable. If
editable move the cursor focus to the editable name and
highlight it all.
:param editable: If true make the plot name editable, else
make it read only
:param toggle_rename_button: If true also toggle the rename
button state
"""
self.line_edit.setReadOnly(not editable)
self.line_edit.setAttribute(Qt.WA_TransparentForMouseEvents, not editable)
# This is a sneaky way to avoid the issue of two calls to
# this toggle method, by effectively disabling the button
# press in edit mode.
self.rename_button.setAttribute(Qt.WA_TransparentForMouseEvents, editable)
#.........这里部分代码省略.........
示例6: setup
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import setSpacing [as 别名]
def setup(self):
"""Setup the ShortcutEditor with the provided arguments."""
# Widgets
icon_info = HelperToolButton()
icon_info.setIcon(get_std_icon('MessageBoxInformation'))
layout_icon_info = QVBoxLayout()
layout_icon_info.setContentsMargins(0, 0, 0, 0)
layout_icon_info.setSpacing(0)
layout_icon_info.addWidget(icon_info)
layout_icon_info.addStretch(100)
self.label_info = QLabel()
self.label_info.setText(
_("Press the new shortcut and select 'Ok' to confirm, "
"click 'Cancel' to revert to the previous state, "
"or use 'Clear' to unbind the command from a shortcut."))
self.label_info.setAlignment(Qt.AlignTop | Qt.AlignLeft)
self.label_info.setWordWrap(True)
layout_info = QHBoxLayout()
layout_info.setContentsMargins(0, 0, 0, 0)
layout_info.addLayout(layout_icon_info)
layout_info.addWidget(self.label_info)
layout_info.setStretch(1, 100)
self.label_current_sequence = QLabel(_("Current shortcut:"))
self.text_current_sequence = QLabel(self.current_sequence)
self.label_new_sequence = QLabel(_("New shortcut:"))
self.text_new_sequence = ShortcutLineEdit(self)
self.text_new_sequence.setPlaceholderText(_("Press shortcut."))
self.helper_button = HelperToolButton()
self.helper_button.setIcon(QIcon())
self.label_warning = QLabel()
self.label_warning.setWordWrap(True)
self.label_warning.setAlignment(Qt.AlignTop | Qt.AlignLeft)
self.button_default = QPushButton(_('Default'))
self.button_ok = QPushButton(_('Ok'))
self.button_ok.setEnabled(False)
self.button_clear = QPushButton(_('Clear'))
self.button_cancel = QPushButton(_('Cancel'))
button_box = QHBoxLayout()
button_box.addWidget(self.button_default)
button_box.addStretch(100)
button_box.addWidget(self.button_ok)
button_box.addWidget(self.button_clear)
button_box.addWidget(self.button_cancel)
# New Sequence button box
self.btn_clear_sequence = create_toolbutton(
self, icon=ima.icon('editclear'),
tip=_("Clear all entered key sequences"),
triggered=self.clear_new_sequence)
self.button_back_sequence = create_toolbutton(
self, icon=ima.icon('ArrowBack'),
tip=_("Remove last key sequence entered"),
triggered=self.back_new_sequence)
newseq_btnbar = QHBoxLayout()
newseq_btnbar.setSpacing(0)
newseq_btnbar.setContentsMargins(0, 0, 0, 0)
newseq_btnbar.addWidget(self.button_back_sequence)
newseq_btnbar.addWidget(self.btn_clear_sequence)
# Setup widgets
self.setWindowTitle(_('Shortcut: {0}').format(self.name))
self.helper_button.setToolTip('')
style = """
QToolButton {
margin:1px;
border: 0px solid grey;
padding:0px;
border-radius: 0px;
}"""
self.helper_button.setStyleSheet(style)
icon_info.setToolTip('')
icon_info.setStyleSheet(style)
# Layout
layout_sequence = QGridLayout()
layout_sequence.setContentsMargins(0, 0, 0, 0)
layout_sequence.addLayout(layout_info, 0, 0, 1, 4)
layout_sequence.addItem(QSpacerItem(15, 15), 1, 0, 1, 4)
layout_sequence.addWidget(self.label_current_sequence, 2, 0)
layout_sequence.addWidget(self.text_current_sequence, 2, 2)
layout_sequence.addWidget(self.label_new_sequence, 3, 0)
layout_sequence.addWidget(self.helper_button, 3, 1)
layout_sequence.addWidget(self.text_new_sequence, 3, 2)
layout_sequence.addLayout(newseq_btnbar, 3, 3)
layout_sequence.addWidget(self.label_warning, 4, 2, 1, 2)
layout_sequence.setColumnStretch(2, 100)
layout_sequence.setRowStretch(4, 100)
layout = QVBoxLayout()
layout.addLayout(layout_sequence)
layout.addSpacing(5)
layout.addLayout(button_box)
self.setLayout(layout)
#.........这里部分代码省略.........