Prevent GUI layout from changing?

Gabriel Genellina gagsl-py2 at
Sun Apr 6 22:15:49 CEST 2008

En Sun, 06 Apr 2008 15:12:55 -0300, <skanemupp at> escribió:

I can't help with your sizing problem, I don't know grids. But don't do  

>     def Display(self, number):
>         self.expr = self.expr + number
>         self.lbText = Label(self, text=self.expr)
>         self.lbText.grid(row=0, column=0)
>     def Calculate(self):
>         self.expr = str(eval(self.expr))#try catch tex 3+6+
>         self.lbText = Label(self, text=self.expr)
>         self.lbText.grid(row=1, column=1)
>         self.expr = ""

You're creating a *new* Label object for each keystroke (they stack on the  
same place and only the newest is visible, I presume).
Instead, you should change the text inside the existing widget:


(there is no need to reposition the widget)
Label is described here
and you may want to learn to use Tkinter variables:

Gabriel Genellina

More information about the Python-list mailing list