TomSchimansky / TomSchimansky/CustomTkinter
Button widget not correctly aligning in grid with sticky = 'nsew' when the button does not have text
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 13.6k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
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 = ''.
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()
If the button is initialized with text and then the text is set to '' using configure, the sticky property seems to work correctly.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided CTkButton grid example with text='' and compare it with a button initialized with text before configure sets it to empty. Trace the CTkButton initialization and grid behavior to identify why sticky='nsew' differs, then verify the same layout works for empty-text buttons without the workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100