本文整理汇总了Python中spyderlib.qt.compat.to_qvariant函数的典型用法代码示例。如果您正苦于以下问题:Python to_qvariant函数的具体用法?Python to_qvariant怎么用?Python to_qvariant使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了to_qvariant函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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])
示例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()
示例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()
示例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()
示例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()
示例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
示例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()
示例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()
示例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)
示例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()
示例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()
示例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()
示例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()
示例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()
示例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