def getRecordAttributeAtColumn(self, rowIndex=None, columnIndex=None,
                                        recName=None, columnName=None):
         """Get the attribute of the record at the specified column index.
            This determines what will be displayed in the cell"""

         value = None
         if columnName != None and recName != None:
             if not self.data[recName].has_key(columnName):
                 return ''
             cell = self.data[recName][columnName]
         else:
             cell = self.getCellRecord(rowIndex, columnIndex)
             columnName = self.getColumnName(columnIndex)
         if cell == None:
             cell=''
         # Set the value based on the data record field
         coltype = self.columntypes[columnName]
         if Formula.isFormula(cell) == True:
             value = self.doFormula(cell)
             return value

         if not type(cell) is DictType:
             if coltype == 'text' or coltype == 'Text':
                 value = cell
             elif coltype == 'number':
                 value = str(cell)
             else:
                 value = 'other'
         if value==None:
             value=''
         return value
示例#2
0
    def getRecordAttributeAtColumn(self,
                                   rowIndex=None,
                                   columnIndex=None,
                                   recName=None,
                                   columnName=None):
        """Get the attribute of the record at the specified column index.
            This determines what will be displayed in the cell"""

        value = None
        if columnName != None and recName != None:
            if not self.data[recName].has_key(columnName):
                return ''
            cell = self.data[recName][columnName]
        else:
            cell = self.getCellRecord(rowIndex, columnIndex)
            columnName = self.getColumnName(columnIndex)
        if cell == None:
            cell = ''
        # Set the value based on the data record field
        coltype = self.columntypes[columnName]
        if Formula.isFormula(cell) == True:
            value = self.doFormula(cell)
            return value

        if not type(cell) is DictType:
            if coltype == 'text' or coltype == 'Text':
                value = cell
            elif coltype == 'number':
                value = str(cell)
            else:
                value = 'other'
        if value == None:
            value = ''

        return value
示例#3
0
    def getRecordAttributeAtColumn(self,
                                   rowIndex=None,
                                   columnIndex=None,
                                   recName=None,
                                   columnName=None):
        """Get the attribute of the record at the specified column index.
            This determines what will be displayed in the cell"""

        value = None  # Holds the value we are going to return
        if columnName != None and recName != None:
            if not self.data[recName].has_key(columnName):
                return ''
            cell = self.data[recName][columnName]
        else:
            cell = self.getCellRecord(rowIndex, columnIndex)
            columnName = self.getColumnName(columnIndex)

        if cell == None:
            return ''
        # Set the value based on the data record field

        coltype = self.columntypes[columnName]
        if Formula.isFormula(
                cell) == True:  #change this to e.g. cell.isFormula() ?
            value = self.doFormula(cell)
            return value
        #if not type(cell) is DictType:
        if coltype == 'text' or coltype == 'Text':
            value = cell
        elif coltype == 'number':
            value = str(cell)
        elif coltype == 'File':
            value = cell['text']
        elif coltype == 'Table':
            value = str(len(cell.keys())) + ' sheets'
        elif coltype == 'Ekin':
            value = self.ekin_show_length(cell)
        else:
            value = ''
        if value == None:
            value = ''

        return value
示例#4
0
    def getRecordAttributeAtColumn(self,
                                   rowIndex=None,
                                   columnIndex=None,
                                   recName=None,
                                   columnName=None):
        """Get the attribute of the record at the specified column index.
           This determines what will be displayed in the cell"""

        value = None
        if columnName is not None and recName is not None:
            if columnName not in self.data[recName]:
                return ''
            cell = self.data[recName][columnName]
        else:
            cell = self.getCellRecord(rowIndex, columnIndex)
            columnName = self.getColumnName(columnIndex)
        if cell is None:
            cell = ''
        # Set the value based on the data record field
        try:
            coltype = self.columntypes[columnName]
        except KeyError:
            coltype = 'text'
        if Formula.isFormula(cell):
            value = self.doFormula(cell)
            return value

        # if not type(cell) == dict:
        if not isinstance(cell, dict):
            if coltype == 'text' or coltype == 'Text':
                value = cell
            elif coltype == 'number':
                value = str(cell)
            else:
                value = 'other'
        if value is None:
            value = ''
        return value
示例#5
0
    def handle_double_click(self, event):
        """Do double click stuff. Selected row/cols will already have
           been set with single click binding"""
        row = self.get_row_clicked(event)
        col = self.get_col_clicked(event)
        absrow = self.get_AbsoluteRow(row)
        if col == None:
            return
        model = self.getModel()
        cellvalue = model.getCellRecord(absrow, col)
        coltype = model.getColumnType(col)
        colname = model.getColumnName(col)
        protein = model.getRecName(absrow)

        def do_peatcommand(fieldtype):
            functions = self.peatactions[fieldtype]
            kys = functions.keys()
            default = kys[0]
            func = getattr(self.parentapp, functions[default])
            if fieldtype == 'Ekintype':
                ekinmode = self.ekin_actions[coltype]
                func(protein=protein, field_name=colname, mode=ekinmode)
            else:
                func(protein=protein, field_name=colname)
            return
        if Formula.isFormula(cellvalue):
            self.formula_Dialog(row, col, cellvalue)
        elif coltype in self.model.ekintypes:
            do_peatcommand('Ekintype')
        elif coltype.lower() == 'text':
            self.draw_cellentry(row, col)
        elif self.peatactions.has_key(coltype):
            do_peatcommand(coltype)
        else:
            raise Exception('Unknown field')
        return