Skip to content

Commit

Permalink
changed theme file format
Browse files Browse the repository at this point in the history
  • Loading branch information
TomSchimansky committed Nov 27, 2022
1 parent a921eb8 commit 01e64f3
Show file tree
Hide file tree
Showing 25 changed files with 498 additions and 241 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ ToDo:
- font attribute must be tuple or CTkFont now, all size values are measured in pixel now
- Changed dictionary key 'window_bg_color' to 'window' in theme files
- CTkInputDialog attributes completely changed
- CTkScrollbar attributes scrollbar_color, scrollbar_hover_color changed to button_color, button_hover_color

### Removed
- Removed setter and getter functions like set_text in CTkButton
Expand Down
216 changes: 143 additions & 73 deletions customtkinter/assets/themes/blue.json
Original file line number Diff line number Diff line change
@@ -1,82 +1,152 @@
{
"color": {
"window": ["#EBEBEC", "#212325"],
"button": ["#3B8ED0", "#1F6AA5"],
"button_hover": ["#36719F", "#144870"],
"button_border": ["#3E454A", "#949A9F"],
"checkbox_border": ["#3E454A", "#949A9F"],
"checkmark": ["#DCE4EE", "gray90"],
"entry": ["#F9F9FA", "#343638"],
"entry_border": ["#979DA2", "#565B5E"],
"entry_placeholder_text": ["gray52", "gray62"],
"frame_border": ["#979DA2", "#565B5E"],
"frame_low": ["#D1D5D8", "#2A2D2E"],
"frame_high": ["#C0C2C5", "#343638"],
"label": "transparent",
"text": ["gray10", "#DCE4EE"],
"text_disabled": ["gray60", "gray45"],
"text_button": ["#DCE4EE", "#DCE4EE"],
"text_button_disabled": ["gray74", "gray60"],
"progressbar": ["#939BA2", "#4A4D50"],
"progressbar_progress": ["#3B8ED0", "#1F6AA5"],
"progressbar_border": ["gray", "gray"],
"slider": ["#939BA2", "#4A4D50"],
"slider_progress": ["gray40", "#AAB0B5"],
"slider_button": ["#3B8ED0", "#1F6AA5"],
"slider_button_hover": ["#36719F", "#144870"],
"switch": ["#939BA2", "#4A4D50"],
"switch_progress": ["#3B8ED0", "#1F6AA5"],
"switch_button": ["gray36", "#D5D9DE"],
"switch_button_hover": ["gray20", "gray100"],
"optionmenu_button": ["#36719F", "#144870"],
"optionmenu_button_hover": ["#27577D", "#203A4F"],
"combobox_border": ["#979DA2", "#565B5E"],
"combobox_button_hover": ["#6E7174", "#7A848D"],
"dropdown_color": ["gray90", "gray20"],
"dropdown_hover": ["gray75", "gray28"],
"dropdown_text": ["gray10", "#DCE4EE"],
"scrollbar_button": ["gray55", "gray41"],
"scrollbar_button_hover": ["gray40", "gray53"],
"segmented_button": ["#979DA2", "#4A4D50"],
"segmented_button_unselected": ["#979DA2", "#4A4D50"],
"segmented_button_unselected_hover": ["gray70", "gray41"]
},
"text": {
"CTk": {
"fg_color": ["#EBEBEC", "#212325"]
},
"CTkToplevel": {
"fg_color": ["#EBEBEC", "#212325"]
},
"CTkFrame": {
"corner_radius": 6,
"border_width": 0,
"fg_color": ["#D1D5D8", "#2A2D2E"],
"top_fg_color": ["#C0C2C5", "#343638"],
"border_color": ["#979DA2", "#565B5E"]
},
"CTkButton": {
"corner_radius": 6,
"border_width": 0,
"fg_color": ["#3B8ED0", "#1F6AA5"],
"hover_color": ["#36719F", "#144870"],
"border_color": ["#3E454A", "#949A9F"],
"text_color": ["#DCE4EE", "#DCE4EE"],
"text_color_disabled": ["gray74", "gray60"]
},
"CTkLabel": {
"corner_radius": 0,
"fg_color": "transparent",
"text_color": ["gray10", "#DCE4EE"]
},
"CTkEntry": {
"corner_radius": 6,
"border_width": 2,
"fg_color": ["#F9F9FA", "#343638"],
"border_color": ["#979DA2", "#565B5E"],
"text_color":["gray10", "#DCE4EE"],
"placeholder_text_color": ["gray52", "gray62"]
},
"CTkCheckbox": {
"corner_radius": 6,
"border_width": 3,
"fg_color": ["#3B8ED0", "#1F6AA5"],
"border_color": ["#3E454A", "#949A9F"],
"hover_color": ["#3B8ED0", "#1F6AA5"],
"checkmark_color": ["#DCE4EE", "gray90"],
"text_color": ["gray10", "#DCE4EE"],
"text_color_disabled": ["gray60", "gray45"]
},
"CTkSwitch": {
"corner_radius": 1000,
"border_width": 3,
"button_length": 0,
"fg_Color": ["#939BA2", "#4A4D50"],
"progress_color": ["#3B8ED0", "#1F6AA5"],
"button_color": ["gray36", "#D5D9DE"],
"button_hover_color": ["gray20", "gray100"],
"text_color": ["gray10", "#DCE4EE"],
"text_color_disabled": ["gray60", "gray45"]
},
"CTkRadiobutton": {
"corner_radius": 1000,
"border_width_checked": 6,
"border_width_unchecked": 3,
"fg_color": ["#3B8ED0", "#1F6AA5"],
"border_color": ["#3E454A", "#949A9F"],
"hover_color": ["#36719F", "#144870"],
"text_color": ["gray10", "#DCE4EE"],
"text_color_disabled": ["gray60", "gray45"]
},
"CTkProgressBar": {
"corner_radius": 1000,
"border_width": 0,
"fg_color": ["#939BA2", "#4A4D50"],
"progress_color": ["#3B8ED0", "#1F6AA5"],
"border_color": ["gray", "gray"]
},
"CTkSlider": {
"corner_radius": 1000,
"button_corner_radius": 1000,
"border_width": 6,
"button_length": 0,
"fg_color": ["#939BA2", "#4A4D50"],
"progress_color": ["gray40", "#AAB0B5"],
"button_color": ["#3B8ED0", "#1F6AA5"],
"button_hover_color": ["#36719F", "#144870"]
},
"CTkOptionMenu": {
"corner_radius": 6,
"fg_color": ["#3B8ED0", "#1F6AA5"],
"button_color": ["#36719F", "#144870"],
"button_hover_color": ["#27577D", "#203A4F"],
"text_color": ["#DCE4EE", "#DCE4EE"],
"text_color_disabled": ["gray74", "gray60"]
},
"CTkComboBox": {
"corner_radius": 6,
"border_width": 2,
"fg_color": ["#F9F9FA", "#343638"],
"border_color": ["#979DA2", "#565B5E"],
"button_color": ["#979DA2", "#565B5E"],
"button_hover_color": ["#6E7174", "#7A848D"],
"text_color": ["gray10", "#DCE4EE"],
"text_color_disabled": ["gray50", "gray45"]
},
"CTkScrollbar": {
"corner_radius": 1000,
"border_spacing": 4,
"fg_color": "transparent",
"button_color": ["#36719F", "#144870"],
"button_hover_color": ["#27577D", "#203A4F"]
},
"CTkSegmentedButton": {
"corner_radius": 6,
"border_width": 2,
"fg_color": ["#979DA2", "#4A4D50"],
"selected_color": ["#3B8ED0", "#1F6AA5"],
"selected_hover_color": ["#36719F", "#144870"],
"unselected_color": ["#979DA2", "#4A4D50"],
"unselected_hover_color": ["gray70", "gray41"],
"text_color": ["#DCE4EE", "#DCE4EE"],
"text_color_disabled": ["gray74", "gray60"]
},
"CTkTextbox": {
"corner_radius": 6,
"border_width": 0,
"fg_color": ["#F9F9FA", "#343638"],
"border_color": ["#979DA2", "#565B5E"],
"text_color":["gray10", "#DCE4EE"],
"scrollbar_button_color": ["gray55", "gray41"],
"scrollbar_button_hover_color": ["gray40", "gray53"]
},
"DropdownMenu": {
"fg_color": ["gray90", "gray20"],
"hover_color": ["gray75", "gray28"],
"text_color": ["#DCE4EE", "#DCE4EE"]
},
"CTkFont": {
"macOS": {
"font": "SF Display",
"size": -13
"family": "SF Display",
"size": 13,
"weight": "normal"
},
"Windows": {
"font": "Roboto",
"size": -13
"family": "Roboto",
"size": 13,
"weight": "normal"
},
"Linux": {
"font": "Roboto",
"size": -13
"family": "Roboto",
"size": 13,
"weight": "normal"
}
},
"shape": {
"button_corner_radius": 6,
"button_border_width": 0,
"checkbox_corner_radius": 6,
"checkbox_border_width": 3,
"radiobutton_corner_radius": 1000,
"radiobutton_border_width_unchecked": 3,
"radiobutton_border_width_checked": 6,
"entry_border_width": 2,
"frame_corner_radius": 6,
"frame_border_width": 0,
"label_corner_radius": 0,
"progressbar_border_width": 0,
"progressbar_corner_radius": 1000,
"slider_border_width": 6,
"slider_corner_radius": 1000,
"slider_button_length": 0,
"slider_button_corner_radius": 1000,
"switch_border_width": 3,
"switch_corner_radius": 1000,
"switch_button_length": 0,
"scrollbar_corner_radius": 1000,
"scrollbar_border_spacing": 4
}
}
82 changes: 82 additions & 0 deletions customtkinter/assets/themes/blue_old.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"color": {
"window": ["#EBEBEC", "#212325"],
"button": ["#3B8ED0", "#1F6AA5"],
"button_hover": ["#36719F", "#144870"],
"button_border": ["#3E454A", "#949A9F"],
"checkbox_border": ["#3E454A", "#949A9F"],
"checkmark": ["#DCE4EE", "gray90"],
"entry": ["#F9F9FA", "#343638"],
"entry_border": ["#979DA2", "#565B5E"],
"entry_placeholder_text": ["gray52", "gray62"],
"frame_border": ["#979DA2", "#565B5E"],
"frame_low": ["#D1D5D8", "#2A2D2E"],
"frame_high": ["#C0C2C5", "#343638"],
"label": "transparent",
"text": ["gray10", "#DCE4EE"],
"text_disabled": ["gray60", "gray45"],
"text_button": ["#DCE4EE", "#DCE4EE"],
"text_button_disabled": ["gray74", "gray60"],
"progressbar": ["#939BA2", "#4A4D50"],
"progressbar_progress": ["#3B8ED0", "#1F6AA5"],
"progressbar_border": ["gray", "gray"],
"slider": ["#939BA2", "#4A4D50"],
"slider_progress": ["gray40", "#AAB0B5"],
"slider_button": ["#3B8ED0", "#1F6AA5"],
"slider_button_hover": ["#36719F", "#144870"],
"switch": ["#939BA2", "#4A4D50"],
"switch_progress": ["#3B8ED0", "#1F6AA5"],
"switch_button": ["gray36", "#D5D9DE"],
"switch_button_hover": ["gray20", "gray100"],
"optionmenu_button": ["#36719F", "#144870"],
"optionmenu_button_hover": ["#27577D", "#203A4F"],
"combobox_border": ["#979DA2", "#565B5E"],
"combobox_button_hover": ["#6E7174", "#7A848D"],
"dropdown_color": ["gray90", "gray20"],
"dropdown_hover": ["gray75", "gray28"],
"dropdown_text": ["gray10", "#DCE4EE"],
"scrollbar_button": ["gray55", "gray41"],
"scrollbar_button_hover": ["gray40", "gray53"],
"segmented_button": ["#979DA2", "#4A4D50"],
"segmented_button_unselected": ["#979DA2", "#4A4D50"],
"segmented_button_unselected_hover": ["gray70", "gray41"]
},
"text": {
"macOS": {
"font": "SF Display",
"size": -13
},
"Windows": {
"font": "Roboto",
"size": -13
},
"Linux": {
"font": "Roboto",
"size": -13
}
},
"shape": {
"button_corner_radius": 6,
"button_border_width": 0,
"checkbox_corner_radius": 6,
"checkbox_border_width": 3,
"radiobutton_corner_radius": 1000,
"radiobutton_border_width_unchecked": 3,
"radiobutton_border_width_checked": 6,
"entry_border_width": 2,
"frame_corner_radius": 6,
"frame_border_width": 0,
"label_corner_radius": 0,
"progressbar_border_width": 0,
"progressbar_corner_radius": 1000,
"slider_border_width": 6,
"slider_corner_radius": 1000,
"slider_button_length": 0,
"slider_button_corner_radius": 1000,
"switch_border_width": 3,
"switch_corner_radius": 1000,
"switch_button_length": 0,
"scrollbar_corner_radius": 1000,
"scrollbar_border_spacing": 4
}
}
2 changes: 1 addition & 1 deletion customtkinter/windows/ctk_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self,
self._max_height: int = 1_000_000
self._last_resizable_args: Union[Tuple[list, dict], None] = None # (args, kwargs)

self._fg_color = ThemeManager.theme["color"]["window"] if fg_color is None else self._check_color_type(fg_color)
self._fg_color = ThemeManager.theme["CTk"]["fg_color"] if fg_color is None else self._check_color_type(fg_color)

# set bg of tkinter.Tk
super().configure(bg=self._apply_appearance_mode(self._fg_color))
Expand Down
2 changes: 1 addition & 1 deletion customtkinter/windows/ctk_toplevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, *args,
self._max_height: int = 1_000_000
self._last_resizable_args: Union[Tuple[list, dict], None] = None # (args, kwargs)

self._fg_color = ThemeManager.theme["color"]["window"] if fg_color is None else self._check_color_type(fg_color)
self._fg_color = ThemeManager.theme["CTkToplevel"]["fg_color"] if fg_color is None else self._check_color_type(fg_color)

# set bg color of tkinter.Toplevel
super().configure(bg=self._apply_appearance_mode(self._fg_color))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def __init__(self, *args,
CTkScalingBaseClass.__init__(self, scaling_type="widget")

self._min_character_width = min_character_width
self._fg_color = ThemeManager.theme["color"]["dropdown_color"] if fg_color is None else self._check_color_type(fg_color)
self._hover_color = ThemeManager.theme["color"]["dropdown_hover"] if hover_color is None else self._check_color_type(hover_color)
self._text_color = ThemeManager.theme["color"]["text"] if text_color is None else self._check_color_type(text_color)
self._fg_color = ThemeManager.theme["DropdownMenu"]["fg_color"] if fg_color is None else self._check_color_type(fg_color)
self._hover_color = ThemeManager.theme["DropdownMenu"]["hover_color"] if hover_color is None else self._check_color_type(hover_color)
self._text_color = ThemeManager.theme["DropdownMenu"]["text_color"] if text_color is None else self._check_color_type(text_color)

# font
self._font = CTkFont() if font is None else self._check_font_type(font)
Expand Down
14 changes: 7 additions & 7 deletions customtkinter/windows/widgets/ctk_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ def __init__(self,
super().__init__(master=master, bg_color=bg_color, width=width, height=height, **kwargs)

# shape
self._corner_radius: int = ThemeManager.theme["shape"]["button_corner_radius"] if corner_radius is None else corner_radius
self._corner_radius: int = ThemeManager.theme["CTkButton"]["corner_radius"] if corner_radius is None else corner_radius
self._corner_radius = min(self._corner_radius, round(self._current_height / 2))
self._border_width: int = ThemeManager.theme["shape"]["button_border_width"] if border_width is None else border_width
self._border_width: int = ThemeManager.theme["CTkButton"]["border_width"] if border_width is None else border_width
self._border_spacing: int = border_spacing

# color
self._fg_color: Union[str, Tuple[str, str]] = ThemeManager.theme["color"]["button"] if fg_color is None else self._check_color_type(fg_color, transparency=True)
self._hover_color: Union[str, Tuple[str, str]] = ThemeManager.theme["color"]["button_hover"] if hover_color is None else self._check_color_type(hover_color)
self._border_color: Union[str, Tuple[str, str]] = ThemeManager.theme["color"]["button_border"] if border_color is None else self._check_color_type(border_color)
self._text_color: Union[str, Tuple[str, str]] = ThemeManager.theme["color"]["text_button"] if text_color is None else self._check_color_type(text_color)
self._text_color_disabled: Union[str, Tuple[str, str]] = ThemeManager.theme["color"]["text_button_disabled"] if text_color_disabled is None else self._check_color_type(text_color_disabled)
self._fg_color: Union[str, Tuple[str, str]] = ThemeManager.theme["CTkButton"]["fg_color"] if fg_color is None else self._check_color_type(fg_color, transparency=True)
self._hover_color: Union[str, Tuple[str, str]] = ThemeManager.theme["CTkButton"]["hover_color"] if hover_color is None else self._check_color_type(hover_color)
self._border_color: Union[str, Tuple[str, str]] = ThemeManager.theme["CTkButton"]["border_color"] if border_color is None else self._check_color_type(border_color)
self._text_color: Union[str, Tuple[str, str]] = ThemeManager.theme["CTkButton"]["text_color"] if text_color is None else self._check_color_type(text_color)
self._text_color_disabled: Union[str, Tuple[str, str]] = ThemeManager.theme["CTkButton"]["text_color_disabled"] if text_color_disabled is None else self._check_color_type(text_color_disabled)

# rendering options
self._background_corner_colors: Union[Tuple[Union[str, Tuple[str, str]]], None] = background_corner_colors # rendering options for DrawEngine
Expand Down
Loading

0 comments on commit 01e64f3

Please sign in to comment.