Answer the question
In order to leave comments, you need to log in
How to align button in width?
Good day, I'm trying to align the button to the center of the parent block using pos_hint: (0.5, 0.5)
But the button is only aligned vertically, horizontally nailed to the left.
Please tell me, is it possible to align the button in kivy to the center of the widget?
Answer the question
In order to leave comments, you need to log in
I set the ID for the parent element, pulled out size[0] through it, that is, the width of the parent element, and with further simple manipulations I set the button to equal indents through pos
from tkinter import * # Use this if use python 3.xx
#from Tkinter import * # Use this if use python 2.xx
a = 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()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question