Text in a window

Here is a simple way to place text in a window. There is no provision made to interact with the text.

How to do it...

Execute the program shown in the usual way.

# text_in_window_1.py
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
from Tkinter import *
root = Tk()
root.title("Text in a window")
text_on_window = Text(root)
text_on_window.grid(row=0, column=0)
for i in range(20):
text_on_window.insert(END, "Fill an area with some text: line %d
"
% i)
root.mainloop()

How it works...

A Text widget is created by the Text(root) method and the insert(…) function places the text inside. The END attribute places each new line at the end of the previous one.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.255.87