PEATDB/Tables.py
def draw_cellentry(self, row, col, text=None):
        """When the user single/double clicks on a text/number cell, bring up entry window"""

        if self.editable == False:
            return
        absrow = self.get_AbsoluteRow(row)
        h=self.rowheight
        model=self.getModel()
        cellvalue = self.model.getCellRecord(absrow, col)
        if Formula.isFormula(cellvalue):
            return
        else:
            text = self.model.getValueAt(absrow, col)
        x1,y1,x2,y2 = self.getCellCoords(row,col)
        w=x2-x1
        #Draw an entry window
        txtvar = StringVar()
        txtvar.set(text)
        def callback(e):
            value = txtvar.get()
            if value == '=':

                #do a dialog that gets the formula into a text area
                #then they can click on the cells they want
                #when done the user presses ok and its entered into the cell
                self.cellentry.destroy()
                #its all done here..
                self.formula_Dialog(row, col)
                return

            coltype = self.model.getColumnType(col)
            if coltype == 'number':
                sta = self.check_data_entry(e)
                if sta == 1:
                    model.setValueAt(value,absrow,col)
            elif coltype == 'text':
                model.setValueAt(value,absrow,col)

            color = self.model.getColorAt(absrow,col,'fg')
            self.draw_Text(row, col, value, color)
            if e.keysym=='Return':
                self.delete('entry')
                #self.draw_rect(row, col)
                #self.gotonextCell(e)
            return
        
        self.cellentry=Entry(self.parentframe,width=20,
                        textvariable=txtvar,
                        bg=self.entrybackgr,
                        relief=FLAT,
                        takefocus=1,
                        font=self.thefont)
        self.cellentry.icursor(END)
        self.cellentry.bind('<Return>', callback)
        self.cellentry.bind('<KeyRelease>', callback)
        self.cellentry.focus_set()
        self.entrywin=self.create_window(x1+self.inset,y1+self.inset,
                                width=w-self.inset*2,height=h-self.inset*2,
                                window=self.cellentry,anchor='nw',
                                tag='entry')

        return
When the user single/double clicks on a text/number cell, bring up entry window
When the user single/double clicks on a text/number cell, bring up entry window
When the user single / double clicks on a text / number cell bring up entry window
def draw_cellentry(self, row, col, text=None):
        if self.editable == False:
            return
        absrow = self.get_AbsoluteRow(row)
        h=self.rowheight
        model=self.getModel()
        cellvalue = self.model.getCellRecord(absrow, col)
        if Formula.isFormula(cellvalue):
            return
        else:
            text = self.model.getValueAt(absrow, col)
        x1,y1,x2,y2 = self.getCellCoords(row,col)
        w=x2-x1
        txtvar = StringVar()
        txtvar.set(text)
        def callback(e):
            value = txtvar.get()
            if value == '=':
                self.cellentry.destroy()
                self.formula_Dialog(row, col)
                return
            coltype = self.model.getColumnType(col)
            if coltype == 'number':
                sta = self.check_data_entry(e)
                if sta == 1:
                    model.setValueAt(value,absrow,col)
            elif coltype == 'text':
                model.setValueAt(value,absrow,col)
            color = self.model.getColorAt(absrow,col,'fg')
            self.draw_Text(row, col, value, color)
            if e.keysym=='Return':
                self.delete('entry')
            return
        self.cellentry=Entry(self.parentframe,width=20,
                        textvariable=txtvar,
                        bg=self.entrybackgr,
                        relief=FLAT,
                        takefocus=1,
                        font=self.thefont)
        self.cellentry.icursor(END)
        self.cellentry.bind('<Return>', callback)
        self.cellentry.bind('<KeyRelease>', callback)
        self.cellentry.focus_set()
        self.entrywin=self.create_window(x1+self.inset,y1+self.inset,
                                width=w-self.inset*2,height=h-self.inset*2,
                                window=self.cellentry,anchor='nw',
                                tag='entry')
        return
def draw_cellentry ( self , row , col , text = None ) : if self . editable == False : return absrow = self . get_AbsoluteRow ( row ) h = self . rowheight model = self . getModel ( ) cellvalue = self . model . getCellRecord ( absrow , col ) if Formula . isFormula ( cellvalue ) : return else : text = self . model . getValueAt ( absrow , col ) x1 , y1 , x2 , y2 = self . getCellCoords ( row , col ) w = x2 - x1 txtvar = StringVar ( ) txtvar . set ( text ) def callback ( e ) : value = txtvar . get ( ) if value == '=' : self . cellentry . destroy ( ) self . formula_Dialog ( row , col ) return coltype = self . model . getColumnType ( col ) if coltype == 'number' : sta = self . check_data_entry ( e ) if sta == 1 : model . setValueAt ( value , absrow , col ) elif coltype == 'text' : model . setValueAt ( value , absrow , col ) color = self . model . getColorAt ( absrow , col , 'fg' ) self . draw_Text ( row , col , value , color ) if e . keysym == 'Return' : self . delete ( 'entry' ) return self . cellentry = Entry ( self . parentframe , width = 20 , textvariable = txtvar , bg = self . entrybackgr , relief = FLAT , takefocus = 1 , font = self . thefont ) self . cellentry . icursor ( END ) self . cellentry . bind ( '<Return>' , callback ) self . cellentry . bind ( '<KeyRelease>' , callback ) self . cellentry . focus_set ( ) self . entrywin = self . create_window ( x1 + self . inset , y1 + self . inset , width = w - self . inset * 2 , height = h - self . inset * 2 , window = self . cellentry , anchor = 'nw' , tag = 'entry' ) return
When the user single/double clicks on a text/number cell, bring up entry window
When the user single / double clicks on a text / number cell bring up entry window
"""When the user single/double clicks on a text/number cell, bring up entry window""" #Draw an entry window #do a dialog that gets the formula into a text area #then they can click on the cells they want #when done the user presses ok and its entered into the cell #its all done here.. #self.draw_rect(row, col) #self.gotonextCell(e)
self
row
col
text