TomSchimansky / CustomTkinter

A modern and customizable python UI-library based on Tkinter
MIT License
10.77k stars 1.03k forks source link

CTkCanvas Uses Different Scaling Than Other Widgets #2461

Open RetroDeveloper232 opened 3 weeks ago

RetroDeveloper232 commented 3 weeks ago

I am developing a calculator application that uses the grid() geometry manager. I noticed the CTkCanvas widget does not scale like other widgets when declaring the canvas's width/height. Moreover, I attached some pictures of the issue and how the canvas is similar in width to the operation bar when it should not be. Moreover, a list of arguments is nonexistent for CTkCanvas when the other widgets have their arguments transparent (For Pylance's option of listing all present arguments in a class/function).

calculator ctk-canvas ctk-frame
dipeshSam commented 3 weeks ago

It's true that Canvas does not scale and even does not have appearance mode in customtkinter.

Why are there two __init__ methods in your Display class?

Could you please provide sample reproducible code demonstrating how Canvas and Frame width mismatch in your case.

Regards.

RetroDeveloper232 commented 3 weeks ago

Hi @dipeshSam , As you know, the init method is responsible for initializing the arguments in a class. When you inherit another class, these arguments can only be customized using the super().__init__() method. To clarify, the first init creates arguments for the new class, while the second init inherits the arguments from the original CustomTkinter class, allowing for configurations of the original base class. I hope this explanation is clear.

Moreover, I will provide a more apparent example of the inconsistent sizing associated with the CustomTkinter Canvas class. The two widgets are both ten pixels less in width than their masters, yet the display still touches the sides of the screen. This seems to be an occurrence only at higher sizes (ex: 30 pixels less make them equal in sizing).

Screenshot 2024-06-09 at 1 07 15 PM Screenshot 2024-06-09 at 1 07 23 PM Screenshot 2024-06-09 at 1 08 06 PM