How do I set a specific width for a grid column in customtkinter?

I have the following options GUI which I’m trying to build:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import customtkinter as ctk
# Create a tkinter window
window = ctk.CTk()
# Create a frame for options
opts_frame = ctk.CTkFrame(window)
opts_frame.pack()
# Define variables
blank_window = ctk.IntVar()
smoothing = ctk.DoubleVar()
iterations = ctk.IntVar()
bootstraps = ctk.IntVar()
blank_window.set(0)
smoothing.set(0.1)
iterations.set(3)
bootstraps.set(100)
# Create labels
ctk.CTkLabel(opts_frame, text='Window Size:').grid(row=0, column=0, sticky='w')
ctk.CTkLabel(opts_frame, text='Smoothing:').grid(row=1, column=0, sticky='w')
ctk.CTkLabel(opts_frame, text='Iterations:').grid(row=2, column=0, sticky='w')
ctk.CTkLabel(opts_frame, text='Bootstraps:').grid(row=3, column=0, sticky='w')
# Create entry fields
window_entry = ctk.CTkEntry(opts_frame, textvariable=blank_window)
smooth_entry = ctk.CTkEntry(opts_frame, textvariable=smoothing)
iter_entry = ctk.CTkEntry(opts_frame, textvariable=iterations)
boot_entry = ctk.CTkEntry(opts_frame, textvariable=bootstraps)
window_entry.grid(row=0, column=1)
smooth_entry.grid(row=1, column=1)
iter_entry.grid(row=2, column=1)
boot_entry.grid(row=3, column=1)
# Create increase and decrease functions
def increase_window():
blank_window.set(blank_window.get() + 1)
def decrease_window():
blank_window.set(blank_window.get() - 1)
# Create buttons
inc_button = ctk.CTkButton(opts_frame, text="+", command=increase_window)
dec_button = ctk.CTkButton(opts_frame, text="-", command=decrease_window)
inc_button.grid(row=0, column=2)
dec_button.grid(row=0, column=3)
# Start the ctkinter event loop
window.mainloop()
</code>
<code>import customtkinter as ctk # Create a tkinter window window = ctk.CTk() # Create a frame for options opts_frame = ctk.CTkFrame(window) opts_frame.pack() # Define variables blank_window = ctk.IntVar() smoothing = ctk.DoubleVar() iterations = ctk.IntVar() bootstraps = ctk.IntVar() blank_window.set(0) smoothing.set(0.1) iterations.set(3) bootstraps.set(100) # Create labels ctk.CTkLabel(opts_frame, text='Window Size:').grid(row=0, column=0, sticky='w') ctk.CTkLabel(opts_frame, text='Smoothing:').grid(row=1, column=0, sticky='w') ctk.CTkLabel(opts_frame, text='Iterations:').grid(row=2, column=0, sticky='w') ctk.CTkLabel(opts_frame, text='Bootstraps:').grid(row=3, column=0, sticky='w') # Create entry fields window_entry = ctk.CTkEntry(opts_frame, textvariable=blank_window) smooth_entry = ctk.CTkEntry(opts_frame, textvariable=smoothing) iter_entry = ctk.CTkEntry(opts_frame, textvariable=iterations) boot_entry = ctk.CTkEntry(opts_frame, textvariable=bootstraps) window_entry.grid(row=0, column=1) smooth_entry.grid(row=1, column=1) iter_entry.grid(row=2, column=1) boot_entry.grid(row=3, column=1) # Create increase and decrease functions def increase_window(): blank_window.set(blank_window.get() + 1) def decrease_window(): blank_window.set(blank_window.get() - 1) # Create buttons inc_button = ctk.CTkButton(opts_frame, text="+", command=increase_window) dec_button = ctk.CTkButton(opts_frame, text="-", command=decrease_window) inc_button.grid(row=0, column=2) dec_button.grid(row=0, column=3) # Start the ctkinter event loop window.mainloop() </code>
import customtkinter as ctk

# Create a tkinter window
window = ctk.CTk()

# Create a frame for options
opts_frame = ctk.CTkFrame(window)
opts_frame.pack()

# Define variables
blank_window = ctk.IntVar()
smoothing = ctk.DoubleVar()
iterations = ctk.IntVar()
bootstraps = ctk.IntVar()
blank_window.set(0)
smoothing.set(0.1)
iterations.set(3)
bootstraps.set(100)

# Create labels
ctk.CTkLabel(opts_frame, text='Window Size:').grid(row=0, column=0, sticky='w')
ctk.CTkLabel(opts_frame, text='Smoothing:').grid(row=1, column=0, sticky='w')
ctk.CTkLabel(opts_frame, text='Iterations:').grid(row=2, column=0, sticky='w')
ctk.CTkLabel(opts_frame, text='Bootstraps:').grid(row=3, column=0, sticky='w')

# Create entry fields
window_entry = ctk.CTkEntry(opts_frame, textvariable=blank_window)
smooth_entry = ctk.CTkEntry(opts_frame, textvariable=smoothing)
iter_entry = ctk.CTkEntry(opts_frame, textvariable=iterations)
boot_entry = ctk.CTkEntry(opts_frame, textvariable=bootstraps)
window_entry.grid(row=0, column=1)
smooth_entry.grid(row=1, column=1)
iter_entry.grid(row=2, column=1)
boot_entry.grid(row=3, column=1)

# Create increase and decrease functions
def increase_window():
    blank_window.set(blank_window.get() + 1)

def decrease_window():
    blank_window.set(blank_window.get() - 1)

# Create buttons
inc_button = ctk.CTkButton(opts_frame, text="+", command=increase_window)
dec_button = ctk.CTkButton(opts_frame, text="-", command=decrease_window)
inc_button.grid(row=0, column=2)
dec_button.grid(row=0, column=3)

# Start the ctkinter event loop
window.mainloop()

I want to shrink the column widths for the entry fields and the buttons down to a smaller size so they don’t take up so much room.

I have tried using weights and minsize in columnconfigure but have had no luck.

Surely, I’m overlooking something very simple here. How can I shrink column sizes in customtkinter?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật