Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Python

Cách căn lề trái Checkbutton trong ttk Tkinter

Để căn trái checkbutton, dùng tham số anchor="w" (west) khi tạo Checkbutton.

Ví dụ

from tkinter import *

root = Tk()
root.geometry("700x350")

frame = LabelFrame(root, text="Select the Subjects", padx=20, pady=20)
frame.pack(pady=20, padx=10)

Checkbutton(frame, text="Mathematics", width=200, anchor="w").pack()
Checkbutton(frame, text="Physics", width=200, anchor="w").pack()
Checkbutton(frame, text="Chemistry", width=200, anchor="w").pack()
Checkbutton(frame, text="Biology", width=200, anchor="w").pack()

root.mainloop()

Kết quả

Các checkbutton căn lề trái trong LabelFrame.

Cách căn lề trái Checkbutton trong ttk Tkinter