Skip to content

Accessing the colours of the current theme manually #228

Answered by felipetesc
kelltom asked this question in Q&A
Discussion options

You must be logged in to vote

ThemeManager is the guy.

Hope it helps.

import customtkinter

from customtkinter import ThemeManager

_mode = customtkinter.get_appearance_mode()


class Theme:

	@staticmethod
	def get_color_from_name(name: str,  mode = _mode):
		return ThemeManager.theme["color"][name][mode]

	@staticmethod
	def get_property_by_name(prop_name: str):
		return ThemeManager.theme[prop_name]



class App(customtkinter.CTk):

	def _str_mode_to_int(self, mode : str):
		if mode == "Light":
			return 0
		return 1

	def print_colors(self):
		print(_mode)
		color_names = Theme.get_property_by_name("color")
		int_mode = self._str_mode_to_int(_mode)
		for color_name in color_names:
			print("Current color name is = "

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@kelltom
Comment options

Answer selected by kelltom
Comment options

You must be logged in to vote
2 replies
@matthew-efseaff
Comment options

@matthew-efseaff
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants