November 9th, 2004, 10:06 PM
Changing fonts and such in ScrolledText class
I have a ScrolledText object in my program, which displays text read in from a text file. I want to be able to change the font for the displayed text. I also want to make it so that some of the text, when clicked upon, creates a pop up window. I know how to create a new window, but I don't know how to link text to the window. Here is the code that I am using.
#creates tutorial box
self.tutorial = ScrolledText(root)
self.tutorial.config(height = 40, width = 40)
fileName = 'v1.txt'
readFile = open(fileName, 'r')
allTheText = readFile.readlines()
for i in range(len(allTheText)):
Any suggestions would be very appreciated! Thank you in advance! :-)
November 10th, 2004, 08:09 PM
Here are some basic ideas...
This is how you set the font globally for a text widget self.text.
To do something when you double click some text:
self.text.config(bg = 'grey',fg = 'black',font=('courier', 10, 'normal'))
where self.text_double_click is a routine whose function is up to you.
This is how you define diferent styles for text:
And you insert text into the widget with styles like this:
This is basic styling you can do more.