TomSchimansky / TomSchimansky/CustomTkinter

.bind function does not correct for widget scaling

Open
#2,012 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
13.6k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Consider the following code snippet:

import customtkinter

app = customtkinter.CTk()
app.title("my app")
app.geometry("200x400")
app.grid_columnconfigure(0, weight=1)
app.grid_rowconfigure(0, weight=1)

tall = customtkinter.CTkFrame(app, border_color="blue", border_width=2)
tall.grid(row=0, column=0, sticky="ns")
tall.bind("<Configure>",
          lambda event: tall.configure(width=event.height))

app.mainloop()

This does not let the frame be wider than it is tall.
However, when turning on display scaling with Windows at 150%, the frame gets to 3:2 before getting restricted. This is because the configure event is not scaled back by the widget scaling amount.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the handling of the event used by widget .bind callbacks and trace how widget scaling is applied to event dimensions. Reproduce the example at 150% Windows display scaling, then verify that the frame remains square when its width is set from event.height.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.