(self, row, col, currformula=None)
return
Formula dialog
Formula dialog
Formula dialog
def formula_Dialog(self, row, col, currformula=None):
        """Formula dialog"""
        self.mode = 'formula'
        print (self.mode)
        x1,y1,x2,y2 = self.getCellCoords(row,col)
        w=300
        h=h=self.rowheight * 3
        def close():
            if hasattr(self,'formulaWin'):
                self.delete('formulabox')
            self.mode = 'normal'
        def calculate():
            #get text area contents and do formula
            f = self.formulaText.get(1.0, END)
            f = f.strip('\n')
            self.model.setFormulaAt(f,row,col)
            value = self.model.doFormula(f)
            color = self.model.getColorAt(row,col,'fg')
            self.drawText(row, col, value, color)
            close()
            self.mode = 'normal'
            return
        def clear():
            self.formulaText.delete(1.0, END)

        self.formulaFrame = Frame(width=w,height=h,bd=3)
        self.formulaText = Text(self.formulaFrame, width=30, height=8, bg='white',relief=GROOVE)
        self.formulaText.pack(side=LEFT,padx=2,pady=2)
        if currformula != None:
            self.formulaText.insert(END, Formula.getFormula(currformula))
        cancelbutton=Button(self.formulaFrame, text='Cancel',
                            bg='#99ccff',command=close)
        cancelbutton.pack(fill=BOTH,padx=2,pady=2)
        donebutton=Button(self.formulaFrame, text='Done',
                          bg='#99ccff',command=calculate)
        donebutton.pack(fill=BOTH,padx=2,pady=2)
        '''clrbutton=Button(self.formulaFrame, text='Clear',
                           bg='#99ccff',command=clear)
        clrbutton.pack(fill=BOTH,padx=2,pady=2) '''
        #add to canvas
        self.formulaWin = self.create_window(x1+self.inset,y1+self.inset,
                                width=w,height=h,
                                window=self.formulaFrame,anchor='nw',
                                tag='formulabox')
        self.formulaText.focus_set()
        return
def formula_Dialog ( self , row , col , currformula = None ) : self . mode = 'formula' print ( self . mode ) x1 , y1 , x2 , y2 = self . getCellCoords ( row , col ) w = 300 h = h = self . rowheight * 3 def close ( ) : if hasattr ( self , 'formulaWin' ) : self . delete ( 'formulabox' ) self . mode = 'normal' def calculate ( ) : #get text area contents and do formula f = self . formulaText . get ( 1.0 , END ) f = f . strip ( '\n' ) self . model . setFormulaAt ( f , row , col ) value = self . model . doFormula ( f ) color = self . model . getColorAt ( row , col , 'fg' ) self . drawText ( row , col , value , color ) close ( ) self . mode = 'normal' return def clear ( ) : self . formulaText . delete ( 1.0 , END ) self . formulaFrame = Frame ( width = w , height = h , bd = 3 ) self . formulaText = Text ( self . formulaFrame , width = 30 , height = 8 , bg = 'white' , relief = GROOVE ) self . formulaText . pack ( side = LEFT , padx = 2 , pady = 2 ) if currformula != None : self . formulaText . insert ( END , Formula . getFormula ( currformula ) ) cancelbutton = Button ( self . formulaFrame , text = 'Cancel' , bg = '#99ccff' , command = close ) cancelbutton . pack ( fill = BOTH , padx = 2 , pady = 2 ) donebutton = Button ( self . formulaFrame , text = 'Done' , bg = '#99ccff' , command = calculate ) donebutton . pack ( fill = BOTH , padx = 2 , pady = 2 ) '''clrbutton=Button(self.formulaFrame, text='Clear',
                           bg='#99ccff',command=clear)
        clrbutton.pack(fill=BOTH,padx=2,pady=2) ''' #add to canvas self . formulaWin = self . create_window ( x1 + self . inset , y1 + self . inset , width = w , height = h , window = self . formulaFrame , anchor = 'nw' , tag = 'formulabox' ) self . formulaText . focus_set ( ) return