set_widget_scaling()
Set a global scaling factor for all widget dimensions.Parameters
The scaling factor to apply to widget dimensions.
- Values greater than
1.0make widgets larger - Values less than
1.0make widgets smaller - Default is
1.0(no scaling) - Minimum accepted value is
0.4
Behavior
- Affects all CustomTkinter widgets globally
- Changes apply immediately to all existing and new widgets
- Multiplies with automatic DPI scaling (if enabled)
- Does not affect window dimensions (use
set_window_scaling()for that)
set_window_scaling()
Set a global scaling factor for all window dimensions.Parameters
The scaling factor to apply to window dimensions.
- Values greater than
1.0make windows larger - Values less than
1.0make windows smaller - Default is
1.0(no scaling) - Minimum accepted value is
0.4
Behavior
- Affects all CustomTkinter windows (CTk, CTkToplevel) globally
- Changes apply immediately to all existing and new windows
- Multiplies with automatic DPI scaling (if enabled)
- Does not affect widget dimensions (use
set_widget_scaling()for that)
deactivate_automatic_dpi_awareness()
Disable automatic DPI awareness for the application.Parameters
This function takes no parameters.Behavior
- Must be called before creating any CTk or CTkToplevel windows
- Disables automatic DPI scaling detection on Windows
- On Windows, prevents the call to
SetProcessDpiAwareness(2) - After calling this, only the manual scaling factors from
set_widget_scaling()andset_window_scaling()are applied - On macOS, DPI scaling works automatically and cannot be disabled
- On Linux, DPI awareness is not implemented
Use Cases
- When you need full manual control over scaling
- If automatic DPI detection causes issues with your application
- When developing cross-platform applications that need consistent sizing
Example: Combined Usage
Example: Dynamic Scaling
Notes
Platform Differences
- Windows: Full DPI awareness support. CustomTkinter calls
SetProcessDpiAwareness(2)for per-monitor DPI awareness - macOS: DPI scaling works automatically at the OS level
- Linux: DPI awareness not currently implemented
Scaling Calculation
The final scaling factor is calculated as:deactivate_automatic_dpi_awareness() is called:
Best Practices
- Call scaling functions before creating widgets for consistent appearance
- Use
deactivate_automatic_dpi_awareness()only when necessary - Test your application on different DPI settings and displays
- Keep widget and window scaling separate for fine-grained control
- Values below
0.4are clamped to0.4to maintain usability