Prevent GUI layout from changing?

skanemupp at yahoo.se skanemupp at yahoo.se
Sun Apr 6 19:11:47 EDT 2008


On 6 Apr, 22:15, "Gabriel Genellina" <gagsl-... at yahoo.com.ar> wrote:
> En Sun, 06 Apr 2008 15:12:55 -0300, <skanem... at yahoo.se> escribió:
>
> I can't help with your sizing problem, I don't know grids. But don't do
> this:
>
> >     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:
>
>      self.lbText.config(text=self.expr)
>
> (there is no need to reposition the widget)
> Label is described herehttp://effbot.org/tkinterbook/label.htm
> and you may want to learn to use Tkinter variables:  http://effbot.org/tkinterbook/variable.htm
>
> --
> Gabriel Genellina


the problem is that when i start writing long numbers the window grows
bigger which is really annoying. is that ebcause of what u said?

as of now i can see exactly the expression i typed and the answer it
is just annoing that it doesnt stay the same size.



More information about the Python-list mailing list