本文整理汇总了Python中spyderlib.qt.compat.to_qvariant函数的典型用法代码示例。如果您正苦于以下问题:Python to_qvariant函数的具体用法?Python to_qvariant怎么用?Python to_qvariant使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了to_qvariant函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: headerData
def headerData(self, section, orientation, role=Qt.DisplayRole):
"""Set header data"""
if role != Qt.DisplayRole:
return to_qvariant()
labels = self.xlabels if orientation == Qt.Horizontal else self.ylabels
if labels is None:
return to_qvariant(int(section))
else:
return to_qvariant(labels[section])
开发者ID:da-woods,项目名称:spyder,代码行数:9,代码来源:arrayeditor.py
示例2: headerData
def headerData(self, section, orientation, role=Qt.DisplayRole):
"""Overriding method headerData"""
if role != Qt.DisplayRole:
return to_qvariant()
i_column = int(section)
if orientation == Qt.Horizontal:
headers = (_("File"), _("Line"), _("Condition"), "")
return to_qvariant( headers[i_column] )
else:
return to_qvariant()
开发者ID:AminJamalzadeh,项目名称:spyder,代码行数:10,代码来源:breakpointsgui.py
示例3: headerData
def headerData(self, section, orientation, role=Qt.DisplayRole):
"""Overriding method headerData"""
if role != Qt.DisplayRole:
return to_qvariant()
i_column = int(section)
if orientation == Qt.Horizontal:
headers = (_("Module"), _(" Required "), _(" Installed "), _("Provided features"))
return to_qvariant(headers[i_column])
else:
return to_qvariant()
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:10,代码来源:dependencies.py
示例4: data
def data(self, index, role=Qt.DisplayRole):
"""Return a model data element"""
if not index.isValid():
return to_qvariant()
if role == Qt.DisplayRole:
return self._display_data(index)
elif role == Qt.BackgroundColorRole:
return to_qvariant(get_color(self._data[index.row()][index.column()], 0.2))
elif role == Qt.TextAlignmentRole:
return to_qvariant(int(Qt.AlignRight | Qt.AlignVCenter))
return to_qvariant()
开发者ID:gyenney,项目名称:Tools,代码行数:11,代码来源:importwizard.py
示例5: headerData
def headerData(self, section, orientation, role=Qt.DisplayRole):
"""Set header data"""
if role != Qt.DisplayRole:
return to_qvariant()
if orientation == Qt.Horizontal:
if section == 0:
return 'Index'
else:
return to_qvariant(to_text_string(self.df_header[section-1]))
else:
return to_qvariant()
开发者ID:ImadBouirmane,项目名称:spyder,代码行数:12,代码来源:dataframeeditor.py
示例6: create_action
def create_action(parent, text, shortcut=None, icon=None, tip=None,
toggled=None, triggered=None, data=None, menurole=None,
context=Qt.WindowShortcut):
"""Create a QAction"""
action = QAction(text, parent)
if triggered is not None:
parent.connect(action, SIGNAL("triggered()"), triggered)
if toggled is not None:
parent.connect(action, SIGNAL("toggled(bool)"), toggled)
action.setCheckable(True)
if icon is not None:
if is_text_string(icon):
icon = get_icon(icon)
action.setIcon(icon)
if shortcut is not None:
action.setShortcut(shortcut)
if tip is not None:
action.setToolTip(tip)
action.setStatusTip(tip)
if data is not None:
action.setData(to_qvariant(data))
if menurole is not None:
action.setMenuRole(menurole)
#TODO: Hard-code all shortcuts and choose context=Qt.WidgetShortcut
# (this will avoid calling shortcuts from another dockwidget
# since the context thing doesn't work quite well with these widgets)
action.setShortcutContext(context)
return action
开发者ID:jromang,项目名称:spyderlib,代码行数:28,代码来源:qthelpers.py
示例7: data
def data(self, index, role=Qt.DisplayRole):
"""Qt Override."""
row = index.row()
if not index.isValid() or not (0 <= row < len(self.shortcuts)):
return to_qvariant()
shortcut = self.shortcuts[row]
key = shortcut.key
column = index.column()
if role == Qt.DisplayRole:
if column == CONTEXT:
return to_qvariant(shortcut.context)
elif column == NAME:
color = self.text_color
if self._parent == QApplication.focusWidget():
if self.current_index().row() == row:
color = self.text_color_highlight
else:
color = self.text_color
text = self.rich_text[row]
text = '<p style="color:{0}">{1}</p>'.format(color, text)
return to_qvariant(text)
elif column == SEQUENCE:
text = QKeySequence(key).toString(QKeySequence.NativeText)
return to_qvariant(text)
elif column == SEARCH_SCORE:
# Treating search scores as a table column simplifies the
# sorting once a score for a specific string in the finder
# has been defined. This column however should always remain
# hidden.
return to_qvariant(self.scores[row])
elif role == Qt.TextAlignmentRole:
return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
return to_qvariant()
开发者ID:AminJamalzadeh,项目名称:spyder,代码行数:35,代码来源:shortcuts.py
示例8: highlight_current_line
def highlight_current_line(self):
"""Highlight current line"""
selection = QTextEdit.ExtraSelection()
selection.format.setProperty(QTextFormat.FullWidthSelection, to_qvariant(True))
selection.format.setBackground(self.currentline_color)
selection.cursor = self.textCursor()
selection.cursor.clearSelection()
self.set_extra_selections("current_line", [selection])
self.update_extra_selections()
开发者ID:sys-bio,项目名称:Spyderplugin_ratelaws,代码行数:9,代码来源:base.py
示例9: data
def data(self, index, role=Qt.DisplayRole):
"""Return data at table index"""
if not index.isValid():
return to_qvariant()
dep = self.dependencies[index.row()]
if role == Qt.DisplayRole:
if index.column() == 0:
value = self.get_value(index)
return to_qvariant(value)
else:
value = self.get_value(index)
return to_qvariant(value)
elif role == Qt.TextAlignmentRole:
return to_qvariant(int(Qt.AlignLeft|Qt.AlignVCenter))
elif role == Qt.BackgroundColorRole:
from spyderlib.dependencies import Dependency
status = dep.get_status()
if status == Dependency.NOK:
color = QColor(Qt.red)
color.setAlphaF(.25)
return to_qvariant(color)
开发者ID:rthouvenin,项目名称:spyder,代码行数:21,代码来源:dependencies.py
示例10: headerData
def headerData(self, section, orientation, role=Qt.DisplayRole):
if role == Qt.TextAlignmentRole:
if orientation == Qt.Horizontal:
return to_qvariant(int(Qt.AlignHCenter|Qt.AlignVCenter))
return to_qvariant(int(Qt.AlignRight|Qt.AlignVCenter))
if role != Qt.DisplayRole:
return to_qvariant()
if orientation == Qt.Horizontal:
if section == CONTEXT:
return to_qvariant(_("Context"))
elif section == NAME:
return to_qvariant(_("Name"))
elif section == MOD1:
return to_qvariant(_("Mod1"))
elif section == MOD2:
return to_qvariant(_("Mod2"))
elif section == MOD3:
return to_qvariant(_("Mod3"))
elif section == KEY:
return to_qvariant(_("Key"))
return to_qvariant()
开发者ID:jromang,项目名称:spyderlib,代码行数:21,代码来源:shortcuts.py
示例11: data
def data(self, index, role=Qt.DisplayRole):
"""Override Qt method"""
if not index.isValid() or not 0 <= index.row() < len(self._rows):
return to_qvariant()
row = index.row()
column = index.column()
name, state = self.row(row)
if role == Qt.DisplayRole or role == Qt.EditRole:
if column == 0:
return to_qvariant(name)
elif role == Qt.CheckStateRole:
if column == 0:
if state:
return Qt.Checked
else:
return Qt.Unchecked
if column == 1:
return to_qvariant(state)
return to_qvariant()
开发者ID:ming-hai,项目名称:spyder,代码行数:21,代码来源:layoutdialog.py
示例12: data
def data(self, index, role=Qt.DisplayRole):
"""Cell content"""
if not index.isValid():
return to_qvariant()
value = self.get_value(index)
if is_binary_string(value):
try:
value = to_text_string(value, 'utf8')
except:
pass
if role == Qt.DisplayRole:
if value is np.ma.masked:
return ''
else:
return to_qvariant(self._format % value)
elif role == Qt.TextAlignmentRole:
return to_qvariant(int(Qt.AlignCenter|Qt.AlignVCenter))
elif role == Qt.BackgroundColorRole and self.bgcolor_enabled \
and value is not np.ma.masked:
hue = self.hue0+\
self.dhue*(self.vmax-self.color_func(value)) \
/(self.vmax-self.vmin)
hue = float(np.abs(hue))
color = QColor.fromHsvF(hue, self.sat, self.val, self.alp)
return to_qvariant(color)
elif role == Qt.FontRole:
return to_qvariant(get_font('arrayeditor'))
return to_qvariant()
开发者ID:wellsoftware,项目名称:spyder,代码行数:28,代码来源:arrayeditor.py
示例13: data
def data(self, index, role=Qt.DisplayRole):
"""Qt Override"""
if not index.isValid() or \
not (0 <= index.row() < len(self.shortcuts)):
return to_qvariant()
shortcut = self.shortcuts[index.row()]
key = shortcut.key
column = index.column()
if role == Qt.DisplayRole:
if column == CONTEXT:
return to_qvariant(shortcut.context)
elif column == NAME:
color = self.text_color
if self._parent == QApplication.focusWidget():
if self.current_index().row() == index.row():
color = self.text_color_highlight
else:
color = self.text_color
return to_qvariant(self._enrich_text(shortcut.name, color))
elif column == SEQUENCE:
text = QKeySequence(key).toString(QKeySequence.NativeText)
return to_qvariant(text)
elif role == Qt.TextAlignmentRole:
return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
return to_qvariant()
开发者ID:ptocca,项目名称:spyder,代码行数:27,代码来源:shortcuts.py
示例14: headerData
def headerData(self, section, orientation, role=Qt.DisplayRole):
"""Set header data"""
if role != Qt.DisplayRole:
return to_qvariant()
if orientation == Qt.Horizontal:
if section == 0:
return "Index"
elif section == 1 and PY2:
# Get rid of possible BOM utf-8 data present at the
# beginning of a file, which gets attached to the first
# column header when headers are present in the first
# row.
# Fixes Issue 2514
try:
header = to_text_string(self.df_header[0], encoding="utf-8-sig")
except:
header = to_text_string(self.df_header[0])
return to_qvariant(header)
else:
return to_qvariant(to_text_string(self.df_header[section - 1]))
else:
return to_qvariant()
开发者ID:fjparada,项目名称:spyder,代码行数:23,代码来源:dataframeeditor.py
示例15: createEditor
def createEditor(self, parent, option, index):
"""Create editor widget"""
model = index.model()
value = model.get_value(index)
if model._data.dtype.name == "bool":
value = not value
model.setData(index, to_qvariant(value))
return
elif value is not np.ma.masked:
editor = QLineEdit(parent)
editor.setFont(get_font('arrayeditor'))
editor.setAlignment(Qt.AlignCenter)
if is_number(self.dtype):
editor.setValidator(QDoubleValidator(editor))
editor.returnPressed.connect(self.commitAndCloseEditor)
return editor
开发者ID:da-woods,项目名称:spyder,代码行数:16,代码来源:arrayeditor.py
示例16: headerData
def headerData(self, section, orientation, role=Qt.DisplayRole):
"""Qt Override."""
if role == Qt.TextAlignmentRole:
if orientation == Qt.Horizontal:
return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
return to_qvariant(int(Qt.AlignRight | Qt.AlignVCenter))
if role != Qt.DisplayRole:
return to_qvariant()
if orientation == Qt.Horizontal:
if section == CONTEXT:
return to_qvariant(_("Context"))
elif section == NAME:
return to_qvariant(_("Name"))
elif section == SEQUENCE:
return to_qvariant(_("Shortcut"))
elif section == SEARCH_SCORE:
return to_qvariant(_("Score"))
return to_qvariant()
开发者ID:AminJamalzadeh,项目名称:spyder,代码行数:18,代码来源:shortcuts.py
示例17: data
def data(self, index, role=Qt.DisplayRole):
if not index.isValid() or not (0 <= index.row() < len(self.shortcuts)):
return to_qvariant()
shortcut = self.shortcuts[index.row()]
key = shortcut.key
column = index.column()
if role == Qt.DisplayRole:
if column == CONTEXT:
return to_qvariant(shortcut.context)
elif column == NAME:
return to_qvariant(shortcut.name)
elif column == MOD1:
return to_qvariant(Key.MODIFIERNAMES[key.modifiers[0]])
elif column == MOD2:
return to_qvariant(Key.MODIFIERNAMES[key.modifiers[1]])
elif column == MOD3:
return to_qvariant(Key.MODIFIERNAMES[key.modifiers[2]])
elif column == KEY:
return to_qvariant(Key.KEYS[key.key])
elif role == Qt.TextAlignmentRole:
return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
return to_qvariant()
开发者ID:ftsiadimos,项目名称:spyder,代码行数:22,代码来源:shortcuts.py
示例18: create_combobox
def create_combobox(self, text, choices, option, default=NoDefault,
tip=None):
"""choices: couples (name, key)"""
label = QLabel(text)
combobox = QComboBox()
if tip is not None:
combobox.setToolTip(tip)
for name, key in choices:
combobox.addItem(name, to_qvariant(key))
self.comboboxes[combobox] = (option, default)
layout = QHBoxLayout()
for subwidget in (label, combobox):
layout.addWidget(subwidget)
layout.addStretch(1)
layout.setContentsMargins(0, 0, 0, 0)
widget = QWidget(self)
widget.setLayout(layout)
return widget
开发者ID:jromang,项目名称:spyderlib,代码行数:18,代码来源:configdialog.py
示例19: highlight_current_cell
def highlight_current_cell(self):
"""Highlight current cell"""
selection = QTextEdit.ExtraSelection()
selection.format.setProperty(QTextFormat.FullWidthSelection,
to_qvariant(True))
selection.format.setBackground(self.currentcell_color)
selection.cursor, whole_file_selected, whole_screen_selected =\
self.select_current_cell_in_visible_portion()
if whole_file_selected:
self.clear_extra_selections('current_cell')
elif whole_screen_selected:
if self.has_cell_separators:
self.set_extra_selections('current_cell', [selection])
self.update_extra_selections()
else:
self.clear_extra_selections('current_cell')
else:
self.set_extra_selections('current_cell', [selection])
self.update_extra_selections()
开发者ID:jromang,项目名称:spyderlib,代码行数:19,代码来源:base.py
示例20: data
def data(self, index, role=Qt.DisplayRole):
"""Cell content"""
if not index.isValid():
return to_qvariant()
if role == Qt.DisplayRole or role == Qt.EditRole:
column = index.column()
row = index.row()
if column == 0:
return to_qvariant(to_text_string(self.df_index[row]))
else:
value = self.get_value(row, column-1)
if isinstance(value, float):
return to_qvariant(self._format % value)
else:
try:
return to_qvariant(to_text_string(value))
except UnicodeDecodeError:
return to_qvariant(encoding.to_unicode(value))
elif role == Qt.BackgroundColorRole:
return to_qvariant(self.get_bgcolor(index))
elif role == Qt.FontRole:
return to_qvariant(get_font('arrayeditor'))
return to_qvariant()
开发者ID:gyenney,项目名称:Tools,代码行数:23,代码来源:dataframeeditor.py
注:本文中的spyderlib.qt.compat.to_qvariant函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论