In this video we’ll talk about high definition scaling for apps in CustomTkinter and Python.

What happens to your app if your user has different monitor display settings? What if they have scaling turned on?

Scaling apps in CustomTkinter is super easy and done automatically.

I’ll show you how to turn it off, or over-ride the scaling in any way you choose.

Python Code: ctk_customcolor2.py
(Github Code)

from tkinter import *
import customtkinter

customtkinter.set_appearance_mode("dark")  # Modes: system (default), light, dark
customtkinter.set_default_color_theme("themes/red.json")  # Themes: blue (default), dark-blue, green
# Turn off scaling
customtkinter.deactivate_automatic_dpi_awareness()
# Scale Window
customtkinter.set_window_scaling(1.5)
# Scale Widgets
customtkinter.set_widget_scaling(1.5) 

#root = Tk()
root = customtkinter.CTk()

root.title('Tkinter.com - CustomTkinter Custom Color Themes')
root.iconbitmap('images/codemy.ico')
root.geometry('700x550')

mode = "dark"

def change_colors(choice):
	customtkinter.set_default_color_theme(choice)

def change():
	global mode
	if mode == "dark":
		customtkinter.set_appearance_mode("light")
		mode = "light"
		# Clear text box
		my_text.delete(0.0, END)
		my_text.insert(END, "This is Light Mode...")
	else:
		customtkinter.set_appearance_mode("dark")
		mode = "dark"
		# Clear text box
		my_text.delete(0.0, END)
		my_text.insert(END, "This is Dark Mode...")


my_text = customtkinter.CTkTextbox(root, width=600, height=300)
my_text.pack(pady=20)

my_button = customtkinter.CTkButton(root, text="Change Light/Dark", command=change)
my_button.pack(pady=20)

colors = ["blue", "dark-blue", "green"]
my_option = customtkinter.CTkOptionMenu(root, values=colors, command=change_colors)
my_option.pack(pady=10)

my_progress = customtkinter.CTkProgressBar(root, orientation="horizontal")
my_progress.pack(pady=20)





root.mainloop()

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts

Add comment

Your email address will not be published. Required fields are marked *

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of...