本文整理汇总了Python中spyderlib.qt.QtGui.QComboBox.addItems方法的典型用法代码示例。如果您正苦于以下问题:Python QComboBox.addItems方法的具体用法?Python QComboBox.addItems怎么用?Python QComboBox.addItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyderlib.qt.QtGui.QComboBox
的用法示例。
在下文中一共展示了QComboBox.addItems方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createEditor
# 需要导入模块: from spyderlib.qt.QtGui import QComboBox [as 别名]
# 或者: from spyderlib.qt.QtGui.QComboBox import addItems [as 别名]
def createEditor(self, parent, option, index):
if index.column() in (MOD1, MOD2, MOD3):
combobox = QComboBox(parent)
combobox.addItems(self.modifiers)
return combobox
elif index.column() == KEY:
combobox = QComboBox(parent)
combobox.addItems(self.keys)
return combobox
else:
return QItemDelegate.createEditor(self, parent, option, index)
示例2: LayoutSaveDialog
# 需要导入模块: from spyderlib.qt.QtGui import QComboBox [as 别名]
# 或者: from spyderlib.qt.QtGui.QComboBox import addItems [as 别名]
class LayoutSaveDialog(QDialog):
""" """
def __init__(self, parent, order):
super(LayoutSaveDialog, self).__init__(parent)
# variables
self._parent = parent
# widgets
self.combo_box = QComboBox(self)
self.combo_box.addItems(order)
self.combo_box.setEditable(True)
self.combo_box.clearEditText()
self.button_box = QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel,
Qt.Horizontal, self)
self.button_ok = self.button_box.button(QDialogButtonBox.Ok)
self.button_cancel = self.button_box.button(QDialogButtonBox.Cancel)
# widget setup
self.button_ok.setEnabled(False)
self.dialog_size = QSize(300, 100)
self.setWindowTitle('Save layout as')
self.setModal(True)
self.setMinimumSize(self.dialog_size)
self.setFixedSize(self.dialog_size)
# layouts
self.layout = QVBoxLayout()
self.layout.addWidget(self.combo_box)
self.layout.addWidget(self.button_box)
self.setLayout(self.layout)
# signals and slots
self.button_box.accepted.connect(self.accept)
self.button_box.rejected.connect(self.close)
self.combo_box.editTextChanged.connect(self.check_text)
def check_text(self, text):
"""Disable empty layout name possibility"""
if to_text_string(text) == u'':
self.button_ok.setEnabled(False)
else:
self.button_ok.setEnabled(True)
示例3: FontLayout
# 需要导入模块: from spyderlib.qt.QtGui import QComboBox [as 别名]
# 或者: from spyderlib.qt.QtGui.QComboBox import addItems [as 别名]
class FontLayout(QGridLayout):
"""Font selection"""
def __init__(self, value, parent=None):
QGridLayout.__init__(self)
font = tuple_to_qfont(value)
assert font is not None
# Font family
self.family = QFontComboBox(parent)
self.family.setCurrentFont(font)
self.addWidget(self.family, 0, 0, 1, -1)
# Font size
self.size = QComboBox(parent)
self.size.setEditable(True)
sizelist = list(range(6, 12)) + list(range(12, 30, 2)) + [36, 48, 72]
size = font.pointSize()
if size not in sizelist:
sizelist.append(size)
sizelist.sort()
self.size.addItems([str(s) for s in sizelist])
self.size.setCurrentIndex(sizelist.index(size))
self.addWidget(self.size, 1, 0)
# Italic or not
self.italic = QCheckBox(_("Italic"), parent)
self.italic.setChecked(font.italic())
self.addWidget(self.italic, 1, 1)
# Bold or not
self.bold = QCheckBox(_("Bold"), parent)
self.bold.setChecked(font.bold())
self.addWidget(self.bold, 1, 2)
def get_font(self):
font = self.family.currentFont()
font.setItalic(self.italic.isChecked())
font.setBold(self.bold.isChecked())
font.setPointSize(int(self.size.currentText()))
return qfont_to_tuple(font)
示例4: setup_and_check
# 需要导入模块: from spyderlib.qt.QtGui import QComboBox [as 别名]
# 或者: from spyderlib.qt.QtGui.QComboBox import addItems [as 别名]
def setup_and_check(self, data, title='', readonly=False,
xlabels=None, ylabels=None):
"""
Setup ArrayEditor:
return False if data is not supported, True otherwise
"""
self.data = data
is_record_array = data.dtype.names is not None
is_masked_array = isinstance(data, np.ma.MaskedArray)
if data.size == 0:
self.error(_("Array is empty"))
return False
if data.ndim > 3:
self.error(_("Arrays with more than 3 dimensions are not supported"))
return False
if xlabels is not None and len(xlabels) != self.data.shape[1]:
self.error(_("The 'xlabels' argument length do no match array "
"column number"))
return False
if ylabels is not None and len(ylabels) != self.data.shape[0]:
self.error(_("The 'ylabels' argument length do no match array row "
"number"))
return False
if not is_record_array:
dtn = data.dtype.name
if dtn not in SUPPORTED_FORMATS and not dtn.startswith('str') \
and not dtn.startswith('unicode'):
arr = _("%s arrays") % data.dtype.name
self.error(_("%s are currently not supported") % arr)
return False
self.layout = QGridLayout()
self.setLayout(self.layout)
self.setWindowIcon(ima.icon('arredit'))
if title:
title = to_text_string(title) + " - " + _("NumPy array")
else:
title = _("Array editor")
if readonly:
title += ' (' + _('read only') + ')'
self.setWindowTitle(title)
self.resize(600, 500)
# Stack widget
self.stack = QStackedWidget(self)
if is_record_array:
for name in data.dtype.names:
self.stack.addWidget(ArrayEditorWidget(self, data[name],
readonly, xlabels, ylabels))
elif is_masked_array:
self.stack.addWidget(ArrayEditorWidget(self, data, readonly,
xlabels, ylabels))
self.stack.addWidget(ArrayEditorWidget(self, data.data, readonly,
xlabels, ylabels))
self.stack.addWidget(ArrayEditorWidget(self, data.mask, readonly,
xlabels, ylabels))
elif data.ndim == 3:
pass
else:
self.stack.addWidget(ArrayEditorWidget(self, data, readonly,
xlabels, ylabels))
self.arraywidget = self.stack.currentWidget()
self.stack.currentChanged.connect(self.current_widget_changed)
self.layout.addWidget(self.stack, 1, 0)
# Buttons configuration
btn_layout = QHBoxLayout()
if is_record_array or is_masked_array or data.ndim == 3:
if is_record_array:
btn_layout.addWidget(QLabel(_("Record array fields:")))
names = []
for name in data.dtype.names:
field = data.dtype.fields[name]
text = name
if len(field) >= 3:
title = field[2]
if not is_text_string(title):
title = repr(title)
text += ' - '+title
names.append(text)
else:
names = [_('Masked data'), _('Data'), _('Mask')]
if data.ndim == 3:
# QSpinBox
self.index_spin = QSpinBox(self, keyboardTracking=False)
self.index_spin.valueChanged.connect(self.change_active_widget)
# QComboBox
names = [str(i) for i in range(3)]
ra_combo = QComboBox(self)
ra_combo.addItems(names)
ra_combo.currentIndexChanged.connect(self.current_dim_changed)
# Adding the widgets to layout
label = QLabel(_("Axis:"))
btn_layout.addWidget(label)
btn_layout.addWidget(ra_combo)
self.shape_label = QLabel()
btn_layout.addWidget(self.shape_label)
label = QLabel(_("Index:"))
btn_layout.addWidget(label)
btn_layout.addWidget(self.index_spin)
#.........这里部分代码省略.........
示例5: FadingTipBox
# 需要导入模块: from spyderlib.qt.QtGui import QComboBox [as 别名]
# 或者: from spyderlib.qt.QtGui.QComboBox import addItems [as 别名]
#.........这里部分代码省略.........
self.set_funcs_before_fade_in([self._disable_widgets])
self.set_funcs_after_fade_in([self._enable_widgets])
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):
""" """
self.x = x
self.y = y
示例6: Help
# 需要导入模块: from spyderlib.qt.QtGui import QComboBox [as 别名]
# 或者: from spyderlib.qt.QtGui.QComboBox import addItems [as 别名]
class Help(SpyderPluginWidget):
"""
Docstrings viewer widget
"""
CONF_SECTION = 'help'
CONFIGWIDGET_CLASS = HelpConfigPage
LOG_PATH = get_conf_path(CONF_SECTION)
focus_changed = Signal()
def __init__(self, parent):
if PYQT5:
SpyderPluginWidget.__init__(self, parent, main = parent)
else:
SpyderPluginWidget.__init__(self, parent)
self.internal_shell = None
# Initialize plugin
self.initialize_plugin()
self.no_doc_string = _("No further documentation available")
self._last_console_cb = None
self._last_editor_cb = None
self.set_default_color_scheme()
self.plain_text = PlainText(self)
self.rich_text = RichText(self)
color_scheme = get_color_scheme(self.get_option('color_scheme_name'))
self.set_plain_text_font(self.get_plugin_font(), color_scheme)
self.plain_text.editor.toggle_wrap_mode(self.get_option('wrap'))
# Add entries to read-only editor context-menu
font_action = create_action(self, _("&Font..."), None,
ima.icon('font'), _("Set font style"),
triggered=self.change_font)
self.wrap_action = create_action(self, _("Wrap lines"),
toggled=self.toggle_wrap_mode)
self.wrap_action.setChecked(self.get_option('wrap'))
self.plain_text.editor.readonly_menu.addSeparator()
add_actions(self.plain_text.editor.readonly_menu,
(font_action, self.wrap_action))
self.set_rich_text_font(self.get_plugin_font('rich_text'))
self.shell = None
self.external_console = None
# locked = disable link with Console
self.locked = False
self._last_texts = [None, None]
self._last_editor_doc = None
# Object name
layout_edit = QHBoxLayout()
layout_edit.setContentsMargins(0, 0, 0, 0)
txt = _("Source")
if sys.platform == 'darwin':
source_label = QLabel(" " + txt)
else:
source_label = QLabel(txt)
layout_edit.addWidget(source_label)
self.source_combo = QComboBox(self)
self.source_combo.addItems([_("Console"), _("Editor")])
self.source_combo.currentIndexChanged.connect(self.source_changed)
if (not programs.is_module_installed('rope') and
not programs.is_module_installed('jedi', '>=0.8.1')):
self.source_combo.hide()
source_label.hide()
layout_edit.addWidget(self.source_combo)
layout_edit.addSpacing(10)
layout_edit.addWidget(QLabel(_("Object")))
self.combo = ObjectComboBox(self)
layout_edit.addWidget(self.combo)
self.object_edit = QLineEdit(self)
self.object_edit.setReadOnly(True)
layout_edit.addWidget(self.object_edit)
self.combo.setMaxCount(self.get_option('max_history_entries'))
self.combo.addItems( self.load_history() )
self.combo.setItemText(0, '')
self.combo.valid.connect(lambda valid: self.force_refresh())
# Plain text docstring option
self.docstring = True
self.rich_help = sphinxify is not None \
and self.get_option('rich_mode', True)
self.plain_text_action = create_action(self, _("Plain Text"),
toggled=self.toggle_plain_text)
# Source code option
self.show_source_action = create_action(self, _("Show Source"),
toggled=self.toggle_show_source)
# Rich text option
self.rich_text_action = create_action(self, _("Rich Text"),
toggled=self.toggle_rich_text)
#.........这里部分代码省略.........
示例7: setup_and_check
# 需要导入模块: from spyderlib.qt.QtGui import QComboBox [as 别名]
# 或者: from spyderlib.qt.QtGui.QComboBox import addItems [as 别名]
def setup_and_check(self, data, title='', readonly=False,
xlabels=None, ylabels=None):
"""
Setup ArrayEditor:
return False if data is not supported, True otherwise
"""
self.data = data
is_record_array = data.dtype.names is not None
is_masked_array = isinstance(data, np.ma.MaskedArray)
if data.size == 0:
self.error(_("Array is empty"))
return False
if data.ndim > 2:
self.error(_("Arrays with more than 2 dimensions "
"are not supported"))
return False
if xlabels is not None and len(xlabels) != self.data.shape[1]:
self.error(_("The 'xlabels' argument length "
"do no match array column number"))
return False
if ylabels is not None and len(ylabels) != self.data.shape[0]:
self.error(_("The 'ylabels' argument length "
"do no match array row number"))
return False
if not is_record_array:
dtn = data.dtype.name
if dtn not in SUPPORTED_FORMATS and not dtn.startswith('string') \
and not dtn.startswith('unicode'):
arr = _("%s arrays") % data.dtype.name
self.error(_("%s are currently not supported") % arr)
return False
self.layout = QGridLayout()
self.setLayout(self.layout)
self.setWindowIcon(get_icon('arredit.png'))
if title:
title = to_text_string(title) # in case title is not a string
else:
title = _("Array editor")
if readonly:
title += ' (' + _('read only') + ')'
self.setWindowTitle(title)
self.resize(600, 500)
# Stack widget
self.stack = QStackedWidget(self)
if is_record_array:
for name in data.dtype.names:
self.stack.addWidget(ArrayEditorWidget(self, data[name],
readonly, xlabels, ylabels))
elif is_masked_array:
self.stack.addWidget(ArrayEditorWidget(self, data, readonly,
xlabels, ylabels))
self.stack.addWidget(ArrayEditorWidget(self, data.data, readonly,
xlabels, ylabels))
self.stack.addWidget(ArrayEditorWidget(self, data.mask, readonly,
xlabels, ylabels))
else:
self.stack.addWidget(ArrayEditorWidget(self, data, readonly,
xlabels, ylabels))
self.arraywidget = self.stack.currentWidget()
self.connect(self.stack, SIGNAL('currentChanged(int)'),
self.current_widget_changed)
self.layout.addWidget(self.stack, 1, 0)
# Buttons configuration
btn_layout = QHBoxLayout()
if is_record_array or is_masked_array:
if is_record_array:
btn_layout.addWidget(QLabel(_("Record array fields:")))
names = []
for name in data.dtype.names:
field = data.dtype.fields[name]
text = name
if len(field) >= 3:
title = field[2]
if not is_text_string(title):
title = repr(title)
text += ' - '+title
names.append(text)
else:
names = [_('Masked data'), _('Data'), _('Mask')]
ra_combo = QComboBox(self)
self.connect(ra_combo, SIGNAL('currentIndexChanged(int)'),
self.stack.setCurrentIndex)
ra_combo.addItems(names)
btn_layout.addWidget(ra_combo)
if is_masked_array:
label = QLabel(_("<u>Warning</u>: changes are applied separately"))
label.setToolTip(_("For performance reasons, changes applied "\
"to masked array won't be reflected in "\
"array's data (and vice-versa)."))
btn_layout.addWidget(label)
btn_layout.addStretch()
bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()"))
self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()"))
btn_layout.addWidget(bbox)
self.layout.addLayout(btn_layout, 2, 0)
#.........这里部分代码省略.........
示例8: ObjectInspector
# 需要导入模块: from spyderlib.qt.QtGui import QComboBox [as 别名]
# 或者: from spyderlib.qt.QtGui.QComboBox import addItems [as 别名]
class ObjectInspector(SpyderPluginWidget):
"""
Docstrings viewer widget
"""
CONF_SECTION = 'inspector'
CONFIGWIDGET_CLASS = ObjectInspectorConfigPage
LOG_PATH = get_conf_path('.inspector')
def __init__(self, parent):
SpyderPluginWidget.__init__(self, parent)
# Initialize plugin
self.initialize_plugin()
self.no_doc_string = _("No documentation available")
self._last_console_cb = None
self._last_editor_cb = None
self.set_default_color_scheme()
self.plain_text = PlainText(self)
self.rich_text = RichText(self)
color_scheme = get_color_scheme(self.get_option('color_scheme_name'))
self.set_plain_text_font(self.get_plugin_font(), color_scheme)
self.plain_text.editor.toggle_wrap_mode(self.get_option('wrap'))
# Add entries to read-only editor context-menu
font_action = create_action(self, _("&Font..."), None,
'font.png', _("Set font style"),
triggered=self.change_font)
self.wrap_action = create_action(self, _("Wrap lines"),
toggled=self.toggle_wrap_mode)
self.wrap_action.setChecked(self.get_option('wrap'))
self.plain_text.editor.readonly_menu.addSeparator()
add_actions(self.plain_text.editor.readonly_menu,
(font_action, self.wrap_action))
self.set_rich_text_font(self.get_plugin_font('rich_text'))
self.shell = None
self.external_console = None
# locked = disable link with Console
self.locked = False
self._last_texts = [None, None]
self._last_rope_data = None
# Object name
layout_edit = QHBoxLayout()
layout_edit.setContentsMargins(0, 0, 0, 0)
source_label = QLabel(_("Source"))
layout_edit.addWidget(source_label)
self.source_combo = QComboBox(self)
self.source_combo.addItems([_("Console"), _("Editor")])
self.connect(self.source_combo, SIGNAL('currentIndexChanged(int)'),
self.source_changed)
if not programs.is_module_installed('rope'):
self.source_combo.hide()
source_label.hide()
layout_edit.addWidget(self.source_combo)
layout_edit.addSpacing(10)
layout_edit.addWidget(QLabel(_("Object")))
self.combo = ObjectComboBox(self)
layout_edit.addWidget(self.combo)
self.object_edit = QLineEdit(self)
self.object_edit.setReadOnly(True)
layout_edit.addWidget(self.object_edit)
self.combo.setMaxCount(self.get_option('max_history_entries'))
self.combo.addItems( self.load_history() )
self.connect(self.combo, SIGNAL("valid(bool)"),
lambda valid: self.force_refresh())
# Plain text docstring option
self.docstring = True
self.rich_help = sphinxify is not None \
and self.get_option('rich_mode', True)
self.plain_text_action = create_action(self, _("Plain Text"),
toggled=self.toggle_plain_text)
# Source code option
self.show_source_action = create_action(self, _("Show Source"),
toggled=self.toggle_show_source)
# Rich text option
self.rich_text_action = create_action(self, _("Rich Text"),
toggled=self.toggle_rich_text)
# Add the help actions to an exclusive QActionGroup
help_actions = QActionGroup(self)
help_actions.setExclusive(True)
help_actions.addAction(self.plain_text_action)
help_actions.addAction(self.rich_text_action)
# Automatic import option
self.auto_import_action = create_action(self, _("Automatic import"),
toggled=self.toggle_auto_import)
auto_import_state = self.get_option('automatic_import')
self.auto_import_action.setChecked(auto_import_state)
#.........这里部分代码省略.........