Python Forum
tkinter scrolledtext formatting - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: tkinter scrolledtext formatting (/thread-4396.html)



tkinter scrolledtext formatting - Lux - Aug-13-2017

I am using tkinter's scrolledtext and I was wondering if it is possible to format some of the text inside of it, like making one word bold while leaving the rest normal.
Is this possible? If so, what is the best way to do it?


RE: tkinter scrolledtext formatting - Larz60+ - Aug-14-2017

I think the only way to do this in tkinter is to use the weight attribute of the font command
self.bigFont = tkFont.Font(family='times', size=24, weight='bold')
see: http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/universal.html
I would set up several fonts, and toggle between them.

wxpython (phoenix) does a much better job at this.


RE: tkinter scrolledtext formatting - Rama2020 - Feb-17-2020

try this one :

def create_scrolltext(self):
F_font = ('bold', 30)
scroll_w = 30
scroll_h = 10
scrollText = scrolledtext.ScrolledText(self, width=scroll_w, height=scroll_h, wrap = tk.WORD, font=F_font)
scrollText.config(bg='white', fg='blue')
scrollText.grid(column=0, columnspan=3)