python - Tkinter: How to make a button center itself? -
i'm making program in python , want go layout bunch of buttons in center. how make button center using pack()?
if can't resolve problem
button.pack(side=top) you'll need use method
button.grid(row=1,col=0) the values of row=1,col=0 depend of position of other widget in window
or can use .place(relx=0.5, rely=0.5, anchor=center)
button.place(relx=0.5, rely=0.5, anchor=center) example using .place():
from tkinter import * # use if use python 3.xx #from tkinter import * # use if use python 2.xx = button(text="center button") b = button(text="top left button") c = button(text="bottom right button") a.place(relx=0.5, rely=0.5, anchor=center) b.place(relx=0.0, rely=0.0, anchor=nw) c.place(relx=1.0, rely=1.0, anchor=se) mainloop 
Comments
Post a Comment