本文整理汇总了Python中qtpy.QtWidgets.QGridLayout.addItem方法的典型用法代码示例。如果您正苦于以下问题:Python QGridLayout.addItem方法的具体用法?Python QGridLayout.addItem怎么用?Python QGridLayout.addItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QGridLayout
的用法示例。
在下文中一共展示了QGridLayout.addItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PyDMScaleIndicator
# 需要导入模块: from qtpy.QtWidgets import QGridLayout [as 别名]
# 或者: from qtpy.QtWidgets.QGridLayout import addItem [as 别名]
#.........这里部分代码省略.........
self.scale_indicator.set_lower_limit(new_limit)
self.update_labels()
def setup_widgets_for_orientation(self, new_orientation, flipped, inverted,
value_position):
"""
Reconstruct the widget given the orientation.
Parameters
----------
new_orientation : int
Qt.Horizontal or Qt.Vertical
flipped : bool
Indicates if scale tick marks are flipped to the other side
inverted : bool
Indicates if scale appearance is inverted
"""
self.limits_layout = None
self.widget_layout = None
if new_orientation == Qt.Horizontal:
self.limits_layout = QHBoxLayout()
if not inverted:
self.limits_layout.addWidget(self.lower_label)
self.limits_layout.addWidget(self.upper_label)
else:
self.limits_layout.addWidget(self.upper_label)
self.limits_layout.addWidget(self.lower_label)
self.widget_layout = QGridLayout()
if not flipped:
if value_position == Qt.LeftEdge:
self.widget_layout.addWidget(self.value_label, 0, 0)
self.widget_layout.addWidget(self.scale_indicator, 0, 1)
self.widget_layout.addItem(self.limits_layout, 1, 1)
elif value_position == Qt.RightEdge:
self.widget_layout.addWidget(self.value_label, 0, 1)
self.widget_layout.addWidget(self.scale_indicator, 0, 0)
self.widget_layout.addItem(self.limits_layout, 1, 0)
elif value_position == Qt.TopEdge:
self.widget_layout.addWidget(self.value_label, 0, 0)
self.widget_layout.addWidget(self.scale_indicator, 1, 0)
self.widget_layout.addItem(self.limits_layout, 2, 0)
elif value_position == Qt.BottomEdge:
self.widget_layout.addWidget(self.scale_indicator, 0, 0)
self.widget_layout.addItem(self.limits_layout, 1, 0)
self.widget_layout.addWidget(self.value_label, 2, 0)
if not inverted:
self.lower_label.setAlignment(Qt.AlignTop | Qt.AlignLeft)
self.upper_label.setAlignment(Qt.AlignTop | Qt.AlignRight)
elif inverted:
self.lower_label.setAlignment(Qt.AlignTop | Qt.AlignRight)
self.upper_label.setAlignment(Qt.AlignTop | Qt.AlignLeft)
else:
if value_position == Qt.LeftEdge:
self.widget_layout.addItem(self.limits_layout, 0, 1)
self.widget_layout.addWidget(self.scale_indicator, 1, 1)
self.widget_layout.addWidget(self.value_label, 1, 0)
elif value_position == Qt.RightEdge:
self.widget_layout.addItem(self.limits_layout, 0, 0)
self.widget_layout.addWidget(self.scale_indicator, 1, 0)
self.widget_layout.addWidget(self.value_label, 1, 1)
elif value_position == Qt.TopEdge:
self.widget_layout.addWidget(self.value_label, 0, 0)
self.widget_layout.addItem(self.limits_layout, 1, 0)
self.widget_layout.addWidget(self.scale_indicator, 2, 0)
示例2: __init__
# 需要导入模块: from qtpy.QtWidgets import QGridLayout [as 别名]
# 或者: from qtpy.QtWidgets.QGridLayout import addItem [as 别名]
def __init__(self, parent, context, name, sequence, shortcuts):
super(ShortcutEditor, self).__init__(parent)
self._parent = parent
self.context = context
self.npressed = 0
self.keys = set()
self.key_modifiers = set()
self.key_non_modifiers = list()
self.key_text = list()
self.sequence = sequence
self.new_sequence = None
self.edit_state = True
self.shortcuts = shortcuts
# Widgets
self.label_info = QLabel()
self.label_info.setText(_("Press the new shortcut and select 'Ok': \n"
"(Press 'Tab' once to switch focus between the shortcut entry \n"
"and the buttons below it)"))
self.label_current_sequence = QLabel(_("Current shortcut:"))
self.text_current_sequence = QLabel(sequence)
self.label_new_sequence = QLabel(_("New shortcut:"))
self.text_new_sequence = CustomLineEdit(self)
self.text_new_sequence.setPlaceholderText(sequence)
self.helper_button = HelperToolButton()
self.helper_button.hide()
self.label_warning = QLabel()
self.label_warning.hide()
bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.button_ok = bbox.button(QDialogButtonBox.Ok)
self.button_cancel = bbox.button(QDialogButtonBox.Cancel)
# Setup widgets
self.setWindowTitle(_('Shortcut: {0}').format(name))
self.button_ok.setFocusPolicy(Qt.NoFocus)
self.button_ok.setEnabled(False)
self.button_cancel.setFocusPolicy(Qt.NoFocus)
self.helper_button.setToolTip('')
self.helper_button.setFocusPolicy(Qt.NoFocus)
style = """
QToolButton {
margin:1px;
border: 0px solid grey;
padding:0px;
border-radius: 0px;
}"""
self.helper_button.setStyleSheet(style)
self.text_new_sequence.setFocusPolicy(Qt.NoFocus)
self.label_warning.setFocusPolicy(Qt.NoFocus)
# Layout
spacing = 5
layout_sequence = QGridLayout()
layout_sequence.addWidget(self.label_info, 0, 0, 1, 3)
layout_sequence.addItem(QSpacerItem(spacing, spacing), 1, 0, 1, 2)
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.addWidget(self.label_warning, 4, 2, 1, 2)
layout = QVBoxLayout()
layout.addLayout(layout_sequence)
layout.addSpacing(spacing)
layout.addWidget(bbox)
self.setLayout(layout)
# Signals
bbox.accepted.connect(self.accept)
bbox.rejected.connect(self.reject)
示例3: CondaPackageActionDialog
# 需要导入模块: from qtpy.QtWidgets import QGridLayout [as 别名]
# 或者: from qtpy.QtWidgets.QGridLayout import addItem [as 别名]
class CondaPackageActionDialog(QDialog):
""" """
def __init__(self, parent, env, name, action, version, versions):
super(CondaPackageActionDialog, self).__init__(parent)
self._parent = parent
self._env = env
self._version_text = None
self._name = name
self._dependencies_dic = {}
self._conda_process = \
conda_api_q.CondaProcess(self, self._on_process_finished)
# widgets
self.label = QLabel(self)
self.combobox_version = QComboBox()
self.label_version = QLabel(self)
self.widget_version = None
self.table_dependencies = None
self.checkbox = QCheckBox(_('Install dependencies (recommended)'))
self.bbox = QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel, Qt.Horizontal,
self)
self.button_ok = self.bbox.button(QDialogButtonBox.Ok)
self.button_cancel = self.bbox.button(QDialogButtonBox.Cancel)
self.button_cancel.setDefault(True)
self.button_cancel.setAutoDefault(True)
dialog_size = QSize(300, 90)
# helper variable values
action_title = {const.UPGRADE: _("Upgrade package"),
const.DOWNGRADE: _("Downgrade package"),
const.REMOVE: _("Remove package"),
const.INSTALL: _("Install package")}
# Versions might have duplicates from different builds
versions = sort_versions(list(set(versions)), reverse=True)
# FIXME: There is a bug, a package installed by anaconda has version
# astropy 0.4 and the linked list 0.4 but the available versions
# in the json file do not include 0.4 but 0.4rc1... so...
# temporal fix is to check if inside list otherwise show full list
if action == const.UPGRADE:
if version in versions:
index = versions.index(version)
versions = versions[:index]
else:
versions = versions
elif action == const.DOWNGRADE:
if version in versions:
index = versions.index(version)
versions = versions[index+1:]
else:
versions = versions
elif action == const.REMOVE:
versions = [version]
self.combobox_version.setEnabled(False)
if len(versions) == 1:
if action == const.REMOVE:
labeltext = _('Package version to remove:')
else:
labeltext = _('Package version available:')
self.label_version.setText(versions[0])
self.widget_version = self.label_version
else:
labeltext = _("Select package version:")
self.combobox_version.addItems(versions)
self.widget_version = self.combobox_version
self.label.setText(labeltext)
self.label_version.setAlignment(Qt.AlignLeft)
self.table_dependencies = QWidget(self)
self._layout = QGridLayout()
self._layout.addWidget(self.label, 0, 0, Qt.AlignVCenter |
Qt.AlignLeft)
self._layout.addWidget(self.widget_version, 0, 1, Qt.AlignVCenter |
Qt.AlignRight)
self.widgets = [self.checkbox, self.button_ok, self.widget_version,
self.table_dependencies]
row_index = 1
# Create a Table
if action in [const.INSTALL, const.UPGRADE, const.DOWNGRADE]:
table = QTableView(self)
dialog_size = QSize(dialog_size.width() + 40, 300)
self.table_dependencies = table
row_index = 1
self._layout.addItem(QSpacerItem(10, 5), row_index, 0)
self._layout.addWidget(self.checkbox, row_index + 1, 0, 1, 2)
self.checkbox.setChecked(True)
self._changed_version(versions[0])
table.setSelectionBehavior(QAbstractItemView.SelectRows)
table.verticalHeader().hide()
#.........这里部分代码省略.........
示例4: setup
# 需要导入模块: from qtpy.QtWidgets import QGridLayout [as 别名]
# 或者: from qtpy.QtWidgets.QGridLayout import addItem [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)
#.........这里部分代码省略.........