Home > Mobile >  Why do tkinter buttons get pushed apart when they are under an Entry?
Why do tkinter buttons get pushed apart when they are under an Entry?

Time:10-26

I am trying to make a calculator with Tkinter GUI. However, when I make buttons under an entry, they get pushed apart. Also, instead of the buttons being in their corresponding columns, they are way out of line. What is making this happen?

Code:

from tkinter import *

# Configure the window
gui = Tk()
gui.title("Calculator")
gui.geometry("400x500")

# Variables for displaying input and output
expression = StringVar()
input_ = ""

# Make the Entry
expression_entry = Entry(gui, textvariable=expression, 
width=49).grid(column=0, row=0)

# Make the Buttons
number_1 = Button(gui, width=3, height=2)
number_1.grid(column=0, row=1)
number_2 = Button(gui, width=3, height=2)
number_2.grid(column=1, row=1)



gui.mainloop()

screenshot

  • Related