Reputation: 77
Before I press the equals button on my program, I get this:
But after, if my answer is smaller than 0 or greater than 9, this happens:
For this same reason I can't use
self.button.config(width=x, height=y)
Without messing up the entire code. Here's a small peice of my code:
import tkinter as tk
class Application(tk.Frame):
def __init__(self, master=None):
super().__init__(master)
self.master = master
self.grid()
self.create_widgets()
self.a = ''
self.math1 = 0
self.math2 = 0
def create_widgets(self):
self.c_button = tk.Button(self)
self.c_button['text'] = 'C'
self.c_button.command = self.clear_all
self.c_button.grid(row=6, column=1)
def clear_all(self):
self.a = '0'
self.math1 = 0
self.math2 = 0
Is there any way to stop it from moving the other buttons apart?
Upvotes: 1
Views: 549
Reputation: 33719
You need to configure the grid so that the widget for the result spans multiple columns, using columnspan
. You have not shown the part of the code which creates the result, but I suspect you need to do something like this:
self.result_button.grid(row=0, column=0, columnspan=4)
Upvotes: 3