Why don’t my texts center with tkinter in python?

I am currently coding a "chess randomizer" in python but I have a problem. When I open the new window, the texts and the buttons are not in the center of the window. Can someone help me please ? Thank you very much.

Here is my code :

    new_window = Tk()
    new_window.geometry("400x300")
    new_window.minsize(400, 300)
    new_window.title("Déplacement aléatoire")
    new_window.config(background='#9999FF')

    text_frame = Frame(new_window, background='#9999FF', width=400, height=150)
    buttons_frame = Frame(new_window, background='#9999FF', width=400, height=150)
    button1_frame = Frame(buttons_frame, background='#9999FF', width=200, height=150)
    button2_frame = Frame(buttons_frame, background='#9999FF', width=200, height=150)


    text = Label(text_frame, text=f"Bougez la pièce en {switch_to_conventional(number)}, ({piece.name})", font=("Arial", 15), bg='#9999FF', fg='#000000')
    text.pack(expand='YES')
    text = Label(text_frame, text="La pièce peut-elle bouger ? ", font=("Arial", 10), bg='#9999FF', fg='#000000')
    text.pack(expand='YES')
    button1 = Button(button1_frame, text='Oui', font=("Arial", 10), bg='#9999FF', fg='#000000')
    button2 = Button(button2_frame, text='Non', font=("Arial", 10), bg='#9999FF', fg='#000000')
    button1.pack(expand='YES')
    button2.pack(expand='YES')

    text_frame.grid(row=0, column=0, sticky='news')
    buttons_frame.grid(row=1, column=0, sticky='news')
    button1_frame.grid(row=0, column=0)
    button2_frame.grid(row=0, column=1)

    new_window.mainloop()

Thank you a lot ! Here si a screenshot : My problem



Read more here: https://stackoverflow.com/questions/67931192/why-dont-my-texts-center-with-tkinter-in-python

Content Attribution

This content was originally published by YogS at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: