I'm trying to implement a resizable window with some widgets inside it, some of which should be centered and some left-justified. Currently, all widgets are centered:
from tkinter import *
root = Tk()
root.resizable()
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
x_cordinate = int((screen_width / 2) - (300 / 2))
y_cordinate = int((screen_height / 2) - (200 / 2))
root.geometry("{}x{}+{}+{}".format(300, 200, x_cordinate, y_cordinate))
root.title("Pane Sticky Test")
main_pane = PanedWindow(root, orient=VERTICAL)
main_pane.pack(fill=BOTH, expand=1)
var = IntVar()
# check = Checkbutton(main_pane, text="My option", variable=var, sticky=W) --> error unknown option "-sticky"
check = Checkbutton(main_pane, text="My option", variable=var)
main_pane.add(check)
# label = Label(main_pane, text="Preview:", sticky=W) --> error unknown option "-sticky"
label = Label(main_pane, text="Preview:")
main_pane.add(label)
entry = Text(main_pane, height=10, width=50)
main_pane.add(entry)
root.mainloop()
I want to place my option check box and my preview label left-justified. I read in this documentation, there should be a sticky option that "functions like the sticky argument to the .grid() method." But this option does not work (see the two lines I commented out).
Is there a way to place some widgets left-justified or right-justified inside a vertically oriented paned window in tkinter? I'm using tkinter version 8.6 with Tcl/Tk version 8.6.9 on windows.