简体   繁体   中英

How to change the font according to selection in text tkinter?

How to change the font of the selected text in tkinter? I have checked the web, but I did not get any results. I want the fonts in a ComboBox of tkinter.ttk .

Please help!

I think you are looking for something like this:

text_widget.tag_add("font_1", *map(str, text_widget.tag_ranges("sel")))
text_widget.tag_config("font_1", font=...)

That will change the font of the selected text. If you bind to the ComboBox changing and run the script, it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM