Skip to content
Advertisement

How to stop a GUI from being automatically resized?

I wrote a calculator app by using Tkinter. The problem is when I click numbers or operators etc, the whole GUI resized automatically. Actually, I think the width of the label must fix in some way. I tried to use a frame as the parent for the label but it didn’t work. Should I use a different layout manager?

Here is my code:

JavaScript

Advertisement

Answer

The widget is resizing because you don’t give the widget an explicit size, so it grows to fit its contents. That is its defined behavior. Instead, you should specify the size that you want it to be. When you do that, it won’t grow when you add more characters to it than will fit.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement