Open Dak3117 opened 4 months ago
Do like this : CTkButton(master,text=' ') # Put a space between quotes Here's You Fixed Code:
app = ctk.CTk()
app.geometry(str(1280) + 'x' + str(720) + '+0+0')
app.rowconfigure(0, weight=1, uniform='u')
app.columnconfigure(0, weight=1, uniform='u')
frame = ctk.CTkFrame(master=app, corner_radius=0, fg_color='gray')
frame.grid(row=0, column=0, sticky='nsew')
frame.grid_rowconfigure((0, 1, 2, 3, 4), weight = 1, uniform='u')
frame.columnconfigure((0, 1), weight = 1, uniform='u')
buttons = []
for r in range(5):
btn_array = []
for c in range(2):
btn_array.append(ctk.CTkButton(master=frame, text = ' ', corner_radius=0))
btn_array[-1].configure(fg_color='white', text_color='black', state='enabled')
btn_array[-1].grid(row=r, column=c, sticky="nsew", pady=2, padx=4)
buttons.append(btn_array)
app.mainloop()
Yes, like I stated, creating the button widget with the text as some value other than '' has the grid management working. I briefly looked at the source code, and it may be that the text widget within the button is not being configured/created if the text is set to ''. If that is intended behavior, then the issue can be closed, but I feel like text values of '' has distinct uses compared to ' '.
For those coming across this same issue, this would probably be the work around:
btn = ctk.CTkButton(master=root, text = ' '))
btn.configure(text='')
The button widget seems to not properly apply the sticky attribute when using the grid manager if the text of the button is empty, i.e. text = ''.
If the button is initialized with text and then the text is set to '' using configure, the sticky property seems to work correctly.