Python Forum
tkinter python button position problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter python button position problem
#3
You might do better using place rather than grid for this.

from tkinter import *
  
root = Tk()
root.geometry("345x380")
root.title("Calculator")
root.resizable (False, False)
window = Entry(root, width = 40).place (x = 8, y = 10)   
  
button_7 = Button(root, text = "7" , padx = 50, pady = 30).place (x = 0, y = 40)
button_8 = Button(root, text = "8" , padx = 50, pady = 30).place (x = 115, y = 40)
button_9 = Button(root, text = "9" , padx = 50, pady = 30).place (x = 230, y = 40)

button_4 = Button(root, text = "4" , padx = 50, pady = 30).place (x = 0, y = 125)
button_5 = Button(root, text = "5" , padx = 50, pady = 30).place (x = 115, y = 125)
button_6 = Button(root, text = "6" , padx = 50, pady = 30).place (x = 230, y = 125)

button_1 = Button(root, text = "1" , padx = 50, pady = 30).place (x = 0, y = 210)
button_2 = Button(root, text = "2" , padx = 50, pady = 30).place (x = 115, y = 210)
button_3 = Button(root, text = "3" , padx = 50, pady = 30).place (x = 230, y = 210)

button_0 = Button(root, text = "0" , padx = 35, pady = 30).place (x = 0, y = 295)
button_minus = Button(root, text = "-" , padx = 35, pady = 30).place (x = 85, y = 295)
button_add =   Button(root, text = "+" , padx = 35, pady = 30).place (x = 166, y = 295)
button_equal = Button(root, text = "=" , padx = 35, pady = 30).place (x = 257, y = 295)
 
root.mainloop()
Reply


Messages In This Thread
RE: tkinter python button position problem - by BashBedlam - Jan-30-2021, 12:15 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  tkinter Radio button group not setting default selection simonc88 3 1,072 Mar-20-2025, 06:53 PM
Last Post: buran
  Using place for a button, many examples but AttributeError, tkinter Edward_ 3 1,035 Dec-17-2024, 09:06 PM
Last Post: deanhystad
  [Tkinter] TKinter Remove Button Frame Nu2Python 8 4,881 Jan-16-2024, 06:44 PM
Last Post: rob101
  tkinter - touchscreen, push the button like click the mouse John64 5 2,588 Jan-06-2024, 03:45 PM
Last Post: deanhystad
  Problems trying to position images with Tkinter emont 3 3,094 Dec-12-2023, 07:20 AM
Last Post: menator01
  Centering and adding a push button to a grid window, TKinter Edward_ 15 14,804 May-25-2023, 07:37 PM
Last Post: deanhystad
  Can't get tkinter button to change color based on changes in data dford 4 4,938 Feb-13-2022, 01:57 PM
Last Post: dford
  Creating a function interrupt button tkinter AnotherSam 2 8,456 Oct-07-2021, 02:56 PM
Last Post: AnotherSam
  [Tkinter] Have tkinter button toggle on and off a continuously running function AnotherSam 5 7,695 Oct-01-2021, 05:00 PM
Last Post: Yoriz
  problem with radio button crook79 3 5,534 Aug-12-2021, 02:30 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020