def __init__(self, data, format="%.6g", 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, ValueError): 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
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
def __init__(self, parent, data, *args): QAbstractTableModel.__init__(self, parent, *args) self.fullList = data self.list = data self.header = header = ['Action', 'Keys'] self.col = 0 self.order = None
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
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 # Use paging when the total size, number of rows or number of # columns is too large if size > LARGE_SIZE: self.rows_loaded = ROWS_TO_LOAD self.cols_loaded = COLS_TO_LOAD else: if self.total_rows > LARGE_NROWS: self.rows_loaded = ROWS_TO_LOAD else: self.rows_loaded = self.total_rows if self.total_cols > LARGE_COLS: self.cols_loaded = COLS_TO_LOAD else: self.cols_loaded = self.total_cols
def __init__(self, parent, data): QAbstractTableModel.__init__(self, parent) if data is None: data = {} self._data = None self.breakpoints = None self.set_data(data)
def __init__(self, sweepCollection, parent=None, *args): QAbstractTableModel.__init__(self, parent, *args) self.sc = sweepCollection n = self.sc.nSweeps self.bad = np.zeros((n, ), dtype=bool) self.plot = np.zeros((n, ), dtype=bool) self.header = ['Plot', 'Bad', 'Tbase', 'Ic+', 'Ic-']
def __init__(self, parent, text_color=None, text_color_highlight=None): QAbstractTableModel.__init__(self) self._parent = parent self.shortcuts = [] self.scores = [] self.rich_text = [] self.normal_text = [] self.context_rich_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
def flags(self, index): """Override to make cells editable.""" if not index.isValid(): return Qt.ItemIsEnabled if index.column() in (2, ): return Qt.ItemFlags( QAbstractTableModel.flags(self, index) | Qt.ItemIsEditable) return QAbstractTableModel.flags(self, index)
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
def __init__(self, parent, data, toolTips, *args): QAbstractTableModel.__init__(self, parent, *args) self.fullList = data self.list = data self.fullToolTips = toolTips self.toolTips = toolTips self.header = ['key', Languages.decode(parent.language)] self.col = 0 self.order = None
def __init__(self, parent=None, readonly=False, font=None): QAbstractTableModel.__init__(self) self.dialog = parent self.readonly = readonly if font is None: font = get_font("arreditor") self.font = font self._data = None self.rows_loaded = 0 self.cols_loaded = 0 self.total_rows = 0 self.total_cols = 0
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()
def flags(self, index): """Set editable flag""" if not index.isValid(): return Qt.ItemIsEnabled flags = QAbstractTableModel.flags(self, index) if not self.readonly: flags |= Qt.ItemIsEditable return Qt.ItemFlags(flags)
def __init__(self, parent): 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() self.text_color = palette.text().color().name() self.text_color_highlight = palette.highlightedText().color().name()
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
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
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.format_type = 'f' self.precision = 5 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
def __init__(self, data=None, format="%.3f", readonly=False, font=None, parent=None, bg_gradient=None, bg_value=None, minvalue=None, maxvalue=None): QAbstractTableModel.__init__(self) self.dialog = parent self.readonly = readonly self._format = format # Backgroundcolor settings # TODO: use LinearGradient # self.bgfunc = bgfunc 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.bgcolor_enabled = True # hue = self.hue0 # color = QColor.fromHsvF(hue, self.sat, self.val, self.alp) # self.color = to_qvariant(color) if font is None: font = get_font("arreditor") self.font = font bold_font = get_font("arreditor") bold_font.setBold(True) self.bold_font = bold_font self.minvalue = minvalue self.maxvalue = maxvalue # TODO: check that data respects minvalue/maxvalue self.set_data(data, bg_gradient=bg_gradient, bg_value=bg_value)
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
def headerData(self, section, orientation, role=Qt.DisplayRole): 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)
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)
def __init__(self, data=[], parent=None): QAbstractTableModel.__init__(self, parent) self._data = data
def __init__(self, parent, dependencies): QAbstractTableModel.__init__(self, parent) self.dependencies = None self.set_data(dependencies)
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])
def __init__(self, data): QAbstractTableModel.__init__(self) self._data = data
def __init__(self, data, format="%.6g", 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 if not self._data.dtype.name == 'object': 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 (AttributeError, TypeError, ValueError): self.vmin = None self.vmax = None self.hue0 = None self.dhue = None self.bgcolor_enabled = False # Array with infinite values cannot display background colors and # crashes. See: spyder-ide/spyder#8093 self.has_inf = False if data.dtype.kind in ['f', 'c']: self.has_inf = np.any(np.isinf(data)) # Deactivate coloring for object arrays or arrays with inf values if self._data.dtype.name == 'object' or self.has_inf: 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
def __init__(self): QAbstractTableModel.__init__(self) self.composition = OrderedDict()
def __init__(self, table, parent=None, *args): QAbstractTableModel.__init__(self, parent, *args) self._table = table
def headerData(self, section, orientation, role=Qt.DisplayRole): if role == Qt.DisplayRole and orientation == Qt.Horizontal: return self._table.colnames[section] return QAbstractTableModel.headerData(self, section, orientation, role)
def flags(self, index): """Set flags""" return Qt.ItemFlags(QAbstractTableModel.flags(self, index))
def __init__(self, datum): QAbstractTableModel.__init__(self) self._datum = datum
def __init__(self, parent=None, *args): QAbstractTableModel.__init__(self, parent, *args) self.colLabels = ['Col%02d' % i for i in range(1, 21)] self.dataCached = [['cell%02d,%02d' % (i, j) for i in range(1, 21)] for j in range(1, 51)]
def flags(self, index): """Set editable flag""" if not index.isValid(): return Qt.ItemIsEnabled return Qt.ItemFlags( QAbstractTableModel.flags(self, index) | Qt.ItemIsEditable)
def flags(self, index): """Qt Override.""" if not index.isValid(): return Qt.ItemIsEnabled return Qt.ItemFlags(QAbstractTableModel.flags(self, index))
def flags(self, index): """Set flags""" if index.column() == 0: return Qt.ItemIsEnabled | Qt.ItemIsSelectable return Qt.ItemFlags( QAbstractTableModel.flags(self, index) | Qt.ItemIsEditable)
def flags(self, index): if not index.isValid(): return Qt.ItemIsEnabled return Qt.ItemFlags(QAbstractTableModel.flags(self, index) | Qt.ItemIsEditable)
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 it 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])
def flags(self, index): """Set flags""" if index.column() == 0: return Qt.ItemIsEnabled | Qt.ItemIsSelectable return Qt.ItemFlags(QAbstractTableModel.flags(self, index) | Qt.ItemIsEditable)
def __init__(self): QAbstractTableModel.__init__(self) self.positions = []
def __init__(self): QAbstractTableModel.__init__(self) self.layers = []