Reputation: 207
Hey i am new to tkinter gui please help i want to add four buttons , one on each corner and this is what i tried please hjelp
from tkinter import *
root=Tk()
labelsub2i = Label(root, bg="red")
labelsub2i.place(relwidth=0.8, relheight=0.7, relx=0.1, rely=0.15)
#BUTTONS FOR OPTIONS
button1 = Button(labelsub2i, text="Aasdddddddddddddddddd").grid(row=1,column=1,sticky=W)
button2 = Button(labelsub2i, text="Bsdaaaaaaaaaaaaaaaasad").grid(row=1,column=6,sticky=E)
button3 = Button(labelsub2i, text="Cdsaaaaaaaaaaaaaaqsdaa").grid(row=3,column=1,sticky=W)
button4 = Button(labelsub2i, text="Dadsssssssssssssssssssss").grid(row=3,column=6,sticky=E)
root.mainloop()
so This is how it looks like right now
wanted to add buttons on those corners
Upvotes: 0
Views: 808
Reputation: 46687
For your case, you can use place(...)
instead of grid(...)
:
button1 = Button(labelsub2i, text="Aasdddddddddddddddddd")
button1.place(relx=0, rely=0, anchor='nw')
button2 = Button(labelsub2i, text="Bsdaaaaaaaaaaaaaaaasad")
button2.place(relx=1.0, rely=0, anchor='ne')
button3 = Button(labelsub2i, text="Cdsaaaaaaaaaaaaaaqsdaa")
button3.place(relx=0, rely=1.0, anchor='sw')
button4 = Button(labelsub2i, text="Dadsssssssssssssssssssss")
button4.place(relx=1.0, rely=1.0, anchor='se')
Upvotes: 2