Try to search your question here, if you can't find : Ask Any Question Now ?

Why are my buttons and frame in Python Tkinter not arrange in the proper geometric coordinates despite giving the right dimensions

HomeCategory: stackoverflowWhy are my buttons and frame in Python Tkinter not arrange in the proper geometric coordinates despite giving the right dimensions
Avatarrupesh asked 4 months ago

I am trying to create a window for my Tic Tac Toe game . In the main root window(dimensions->height =700 , width=600) I have created two frames .

1:The top frame is called ActionArea and has dimensions-> Height=600 and width=600

2:The bottom frame is called StatArea and has dimensions-> Height=100 and width=600

In the top frame , I have placed 9 buttons ,each having an equal size of 200 * 200

This was my expectations :
My expectations on how the Window would look

This is the reality I am getting on running the code:
this is the output I am getting on running my code

This is the relevant part of the code:

root=tk.Tk()
root.title("TIC TAC TOE")
root.geometry("600x700")


#creating two frames
ActionArea=tk.Frame(root,height=600,width=600,bg="AliceBlue")
StatArea=tk.Frame(root,height=100,width=600,bg="RoyalBlue")

#placing the frames onto root window
ActionArea.grid(row=0,column=0)
StatArea.grid(row=1,column=0)

#creating the buttons
b1=tk.Button(ActionArea,text="", height=200,width=200,bg="AliceBlue")
b2=tk.Button(ActionArea,text="", height=200,width=200,bg="AliceBlue")
b3=tk.Button(ActionArea,text="", height=200,width=200,bg="AliceBlue")
b4=tk.Button(ActionArea,text="", height=200,width=200,bg="AliceBlue")
b5=tk.Button(ActionArea,text="", height=200,width=200,bg="AliceBlue")
b6=tk.Button(ActionArea,text="", height=200,width=200,bg="AliceBlue")
b7=tk.Button(ActionArea,text="", height=200,width=200,bg="AliceBlue")
b8=tk.Button(ActionArea,text="", height=200,width=200,bg="AliceBlue")
b9=tk.Button(ActionArea,text="", height=200,width=200,bg="AliceBlue")

#packing the buttons
b1.grid(row=0,column=0)
b2.grid(row=0,column=1)
b3.grid(row=0,column=2)
b4.grid(row=1,column=0)
b5.grid(row=1,column=1)
b6.grid(row=1,column=2)
b7.grid(row=2,column=0)
b8.grid(row=2,column=1)
b9.grid(row=2,column=2)

So.many doubts .
I accurate sized every button to 200 * 200 to fit my top frame which is of dimensions 600 * 600 . However , as you can see , the button is becoming ridiculously large . Why is this happening?

1 Answers
Best Answer
AvatarFernando answered 4 months ago
Your Answer

6 + 6 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com