You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to change the font of the buttons inserted into the CTkListbox, so I used the 'font' parameter, but it wasn't changing the font of the buttons.
Here's my initialization of the CTkListbox:
list=CTkListbox(
master=self.frame1,
height=200,
text_color=['#000, #FFF'],
font=("Proxima Nova Rg", 18, "bold"), # this wasn't doing anythinghover_color='#00458A',
highlight_color='#0267c9',
multiple_selection=True,
)
I discovered a temporary fix for myself by modifying your ctk_listbox.py file, particularly the 'insert' method in line 198.
I did have to add the import line import ast to the top of your ctk_listbox.py file for my fix, though.
'ctk_listbox.py' (line 198):
definsert(self, index, option, update=True, **args):
"""add new option in the listbox"""ifstr(index).lower() =="end":
index=f"END{self.end_num}"self.end_num+=1ifindexinself.buttons:
self.buttons[index].destroy()
font=ast.literal_eval(self.font.cget('family')) # i added thisself.buttons[index] =customtkinter.CTkButton(
self,
text=option,
fg_color=self.button_fg_color,
anchor=self.justify,
text_color=self.text_color,
font=font, # i changed this from 'font=self.font' to 'font=font'hover_color=self.hover_color,
**args,
)
# the rest of the method stays the same
I'm hoping there is a better fix for this? Let me know, and if you're having trouble reproducing it I can provide more of my code.
The text was updated successfully, but these errors were encountered:
It doesn't work instancing the class with font parameter, but it works if assigned after with the font property :
Example:
`
custom_font =("Arial",11)
self.listBoxAnnoTarget = CTkListbox(self.targetoptselection_frame, multiple_selection=False, command=self.filter_ui, font=custom_font) #NO CHANGE
self.listBoxAnnoTarget = CTkListbox(self.targetoptselection_frame, multiple_selection=False, command=self.filter_ui)
self.listBoxAnnoTarget.font=custom_font #THIS WORKS
`
This is the workaround I used.
I wanted to change the font of the buttons inserted into the CTkListbox, so I used the 'font' parameter, but it wasn't changing the font of the buttons.
Here's my initialization of the CTkListbox:
I discovered a temporary fix for myself by modifying your ctk_listbox.py file, particularly the 'insert' method in line 198.
I did have to add the import line
import ast
to the top of your ctk_listbox.py file for my fix, though.'ctk_listbox.py' (line 198):
I'm hoping there is a better fix for this? Let me know, and if you're having trouble reproducing it I can provide more of my code.
The text was updated successfully, but these errors were encountered: