TomSchimansky / CustomTkinter

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

Changing Font of a Tabview #2296

Open leonardodafishy opened 7 months ago

leonardodafishy commented 7 months ago

Hi. I'm working on a program that involves a Tabview. I want to customize it and change the font, but there doesn't seem to be an argument for it on Tabview. Is there a way to change it?

b2220765049 commented 6 months ago

As i know there is no direct way to change the font. But you can make some modifications on customtkinter's files to change the font. Here is my way:

1) go to your environment and find customtkinter package 2) open ctk_tabview.py in customtkinter/windows/widgets folder 3) from .font.ctk_font import CTkFont Add this line to imports 4) in line 78 there is a segmented button creation like this: self._segmented_button = CTkSegmentedButton(self, values=[], height=self._button_height, fg_color=segmented_button_fg_color, selected_color=segmented_button_selected_color, selected_hover_color=segmented_button_selected_hover_color, unselected_color=segmented_button_unselected_color, unselected_hover_color=segmented_button_unselected_hover_color, text_color=text_color, text_color_disabled=text_color_disabled, corner_radius=corner_radius, border_width=self._segmented_button_border_width, command=self._segmented_button_callback, state=state) 5) Add font=CTkFont(size = 30, weight='bold', whatever you want) as parameter. That is all.

ichiberto commented 3 months ago

There is a... kind of illegal way:

tabview._segmented_button.configure(font=ctk.CTkFont(family="Arial", size=12, weight="bold"))

I hope you find it useful and its not to late