本文整理汇总了Python中qtpy.QtCore.QAbstractTableModel类的典型用法代码示例。如果您正苦于以下问题:Python QAbstractTableModel类的具体用法?Python QAbstractTableModel怎么用?Python QAbstractTableModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QAbstractTableModel类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, data, format="%.3f", xlabels=None, ylabels=None,
readonly=False, parent=None):
QAbstractTableModel.__init__(self)
self.dialog = parent
self.changes = {}
self.xlabels = xlabels
self.ylabels = ylabels
self.readonly = readonly
self.test_array = np.array([0], dtype=data.dtype)
# for complex numbers, shading will be based on absolute value
# but for all other types it will be the real part
if data.dtype in (np.complex64, np.complex128):
self.color_func = np.abs
else:
self.color_func = np.real
# Backgroundcolor settings
huerange = [.66, .99] # Hue
self.sat = .7 # Saturation
self.val = 1. # Value
self.alp = .6 # Alpha-channel
self._data = data
self._format = format
self.total_rows = self._data.shape[0]
self.total_cols = self._data.shape[1]
size = self.total_rows * self.total_cols
try:
self.vmin = np.nanmin(self.color_func(data))
self.vmax = np.nanmax(self.color_func(data))
if self.vmax == self.vmin:
self.vmin -= 1
self.hue0 = huerange[0]
self.dhue = huerange[1]-huerange[0]
self.bgcolor_enabled = True
except TypeError:
self.vmin = None
self.vmax = None
self.hue0 = None
self.dhue = None
self.bgcolor_enabled = False
# Use paging when the total size, number of rows or number of
# columns is too large
if size > LARGE_SIZE:
self.rows_loaded = self.ROWS_TO_LOAD
self.cols_loaded = self.COLS_TO_LOAD
else:
if self.total_rows > LARGE_NROWS:
self.rows_loaded = self.ROWS_TO_LOAD
else:
self.rows_loaded = self.total_rows
if self.total_cols > LARGE_COLS:
self.cols_loaded = self.COLS_TO_LOAD
else:
self.cols_loaded = self.total_cols
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:60,代码来源:arrayeditor.py
示例2: __init__
def __init__(self, parent, data):
QAbstractTableModel.__init__(self, parent)
if data is None:
data = {}
self._data = None
self.breakpoints = None
self.set_data(data)
开发者ID:0xBADCA7,项目名称:spyder,代码行数:7,代码来源:breakpointsgui.py
示例3: __init__
def __init__(self, parent, text_color=None, text_color_highlight=None):
QAbstractTableModel.__init__(self)
self._parent = parent
self.servers = []
self.server_map = {}
# self.scores = []
self.rich_text = []
self.normal_text = []
self.letters = ''
self.label = QLabel()
self.widths = []
# Needed to compensate for the HTMLDelegate color selection unawarness
palette = parent.palette()
if text_color is None:
self.text_color = palette.text().color().name()
else:
self.text_color = text_color
if text_color_highlight is None:
self.text_color_highlight = \
palette.highlightedText().color().name()
else:
self.text_color_highlight = text_color_highlight
开发者ID:cfanpc,项目名称:spyder,代码行数:25,代码来源:lspmanager.py
示例4: __init__
def __init__(self, datum):
QAbstractTableModel.__init__(self)
self._datum = datum
conditions = datum.conditions.findvalues(DetectorSpectrometer)
if conditions:
self._calibration = next(iter(conditions)).calibration
else:
self._calibration = None
开发者ID:pyhmsa,项目名称:pyhmsa-gui,代码行数:9,代码来源:analysis.py
示例5: __init__
def __init__(self, parent):
QAbstractTableModel.__init__(self)
self._parent = parent
self.shortcuts = []
self.scores = []
self.rich_text = []
self.normal_text = []
self.letters = ''
self.label = QLabel()
self.widths = []
# Needed to compensate for the HTMLDelegate color selection unawarness
palette = parent.palette()
self.text_color = palette.text().color().name()
self.text_color_highlight = palette.highlightedText().color().name()
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:16,代码来源:shortcuts.py
示例6: __init__
def __init__(self, dataFrame, format="%.3g", parent=None):
QAbstractTableModel.__init__(self)
self.dialog = parent
self.df = dataFrame
self.df_index = dataFrame.index.tolist()
self.df_header = dataFrame.columns.tolist()
self._format = format
self.complex_intran = None
self.total_rows = self.df.shape[0]
self.total_cols = self.df.shape[1]
size = self.total_rows * self.total_cols
huerange = [.66, .99] # Hue
self.sat = .7 # Saturation
self.val = 1. # Value
self.alp = .6 # Alpha-channel
self.hue0 = huerange[0]
self.dhue = huerange[1]-huerange[0]
self.max_min_col = None
if size < LARGE_SIZE:
self.max_min_col_update()
self.colum_avg_enabled = True
self.bgcolor_enabled = True
self.colum_avg(1)
else:
self.colum_avg_enabled = False
self.bgcolor_enabled = False
self.colum_avg(0)
# Use paging when the total size, number of rows or number of
# columns is too large
if size > LARGE_SIZE:
self.rows_loaded = self.ROWS_TO_LOAD
self.cols_loaded = self.COLS_TO_LOAD
else:
if self.total_rows > LARGE_NROWS:
self.rows_loaded = self.ROWS_TO_LOAD
else:
self.rows_loaded = self.total_rows
if self.total_cols > LARGE_COLS:
self.cols_loaded = self.COLS_TO_LOAD
else:
self.cols_loaded = self.total_cols
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:44,代码来源:dataframeeditor.py
示例7: __init__
def __init__(self, dataFrame, format=DEFAULT_FORMAT, parent=None):
QAbstractTableModel.__init__(self)
self.dialog = parent
self.df = dataFrame
self.df_index = dataFrame.index.tolist()
self.df_header = dataFrame.columns.tolist()
self._format = format
self.complex_intran = None
self.total_rows = self.df.shape[0]
self.total_cols = self.df.shape[1]
size = self.total_rows * self.total_cols
self.max_min_col = None
if size < LARGE_SIZE:
self.max_min_col_update()
self.colum_avg_enabled = True
self.bgcolor_enabled = True
self.colum_avg(1)
else:
self.colum_avg_enabled = False
self.bgcolor_enabled = False
self.colum_avg(0)
# Use paging when the total size, number of rows or number of
# columns is too large
if size > LARGE_SIZE:
self.rows_loaded = self.ROWS_TO_LOAD
self.cols_loaded = self.COLS_TO_LOAD
else:
if self.total_rows > LARGE_NROWS:
self.rows_loaded = self.ROWS_TO_LOAD
else:
self.rows_loaded = self.total_rows
if self.total_cols > LARGE_COLS:
self.cols_loaded = self.COLS_TO_LOAD
else:
self.cols_loaded = self.total_cols
开发者ID:rlaverde,项目名称:spyder,代码行数:38,代码来源:dataframeeditor.py
示例8: headerData
def headerData(self, section, orientation, role=Qt.DisplayRole):
"""
Overrides the base class
"""
if role == Qt.DisplayRole and orientation == Qt.Horizontal:
return self._linelist.colnames[section]
# This generates tooltips for header cells
if role == Qt.ToolTipRole and orientation == Qt.Horizontal:
if self._linelist.colnames[section] in [WAVELENGTH_COLUMN, ERROR_COLUMN]:
result = self._linelist.columns[section].unit
else:
# this captures glitches that generate None tooltips
if self._linelist.tooltips:
result = self._linelist.tooltips[section]
else:
result = ''
return str(result)
return QAbstractTableModel.headerData(self, section, orientation, role)
开发者ID:nmearl,项目名称:specviz,代码行数:20,代码来源:linelists_window.py
示例9: __init__
def __init__(self, parent, dependencies):
QAbstractTableModel.__init__(self, parent)
self.dependencies = None
self.set_data(dependencies)
开发者ID:silentquasar,项目名称:spyder,代码行数:4,代码来源:dependencies.py
示例10: flags
def flags(self, index):
"""Qt Override."""
if not index.isValid():
return Qt.ItemIsEnabled
return Qt.ItemFlags(QAbstractTableModel.flags(self, index))
开发者ID:cfanpc,项目名称:spyder,代码行数:5,代码来源:lspmanager.py
示例11: __init__
def __init__(self, data=[], parent=None):
QAbstractTableModel.__init__(self, parent)
self._data = data
开发者ID:ShenggaoZhu,项目名称:spyder,代码行数:3,代码来源:importwizard.py
示例12: __init__
def __init__(self, datum):
QAbstractTableModel.__init__(self)
self._datum = datum
开发者ID:pyhmsa,项目名称:pyhmsa-gui,代码行数:3,代码来源:imageraster.py
示例13: __init__
def __init__(self, linelist, parent=None, *args):
QAbstractTableModel.__init__(self, parent, *args)
self._linelist = linelist
#TODO move entire table contents to an array of QVector
# instances that will store the columns. This should
# speed up the sorting (as far as some indications in
# the net suggest:
# http://www.qtforum.org/article/30638/qsortfilterproxymodel-qtreeview-sort-performance.html).
# Bummer... this is C++ only; PyQt never went to the trouble
# of converting QVector to python.
#
# get rid entirely of astropy table and store its contents in
# a 2-D list of lists. By using python lists instead of an
# astropy table, and storing the QVariant instances instead
# of the raw content, we can speed up sorting by a factor > 10X.
# we have to do this here because some lists may
# have no lines at all.
self._nrows = 0
self._ncols = 0
self._row_cells = []
for row in self._linelist:
cells = []
for rindex in range(len(row)):
cell = row[rindex]
# handling of a color object can be tricky. Color names
# returned by QColor.colorNames() are inconsistent with
# color names in Qt.GlobalColor. We just go to the basics
# and compare color equality (or closeness) using a distance
# criterion in r,g,b coordinates.
# Although costly, this would be a CPU burden only when
# sorting columns with color information. For now, only
# the Plotted Lines line list has such information, and
# the number of actually plotted lines tends to be small
# anyway.
if isinstance(cell, QColor):
r = cell.red()
g = cell.green()
b = cell.blue()
min_dist = 100000
result = cell
for color_name, orig_color in ID_COLORS.items():
orig_rgb = QColor(orig_color)
dist = abs(orig_rgb.red() - r) + abs(orig_rgb.green() - g) + abs(orig_rgb.blue() - b)
if dist < min_dist:
min_dist = dist
result = orig_color
key = [k for k,value in ID_COLORS.items() if value == result][0]
cells.append(QVariant(key))
else:
cells.append(QVariant(str(cell)))
self._row_cells.append(cells)
self._nrows = len(self._row_cells)
self._ncols = len(self._row_cells[0])
开发者ID:nmearl,项目名称:specviz,代码行数:65,代码来源:linelists_window.py
示例14: flags
def flags(self, index):
"""Set flags"""
if index.column() == 0:
return Qt.ItemIsEnabled | Qt.ItemIsSelectable
return Qt.ItemFlags(QAbstractTableModel.flags(self, index) |
Qt.ItemIsEditable)
开发者ID:rlaverde,项目名称:spyder,代码行数:6,代码来源:dataframeeditor.py
示例15: __init__
def __init__(self):
QAbstractTableModel.__init__(self)
self.composition = OrderedDict()
开发者ID:pyhmsa,项目名称:pyhmsa-gui,代码行数:3,代码来源:composition.py
示例16: flags
def flags(self, index):
if not index.isValid():
return Qt.ItemIsEnabled
return Qt.ItemFlags(QAbstractTableModel.flags(self, index) |
Qt.ItemIsEditable)
开发者ID:pyhmsa,项目名称:pyhmsa-gui,代码行数:6,代码来源:specimenposition.py
示例17: __init__
def __init__(self):
QAbstractTableModel.__init__(self)
self.positions = []
开发者ID:pyhmsa,项目名称:pyhmsa-gui,代码行数:3,代码来源:specimenposition.py
示例18: __init__
def __init__(self):
QAbstractTableModel.__init__(self)
self.layers = []
开发者ID:pyhmsa,项目名称:pyhmsa-gui,代码行数:3,代码来源:detector.py
注:本文中的qtpy.QtCore.QAbstractTableModel类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论