Text Widgets : Entry « Tkinker « Python Tutorial






Text Widgets
from Tkinter import *

class FileDisplay :

    def loadfile(self) :
        myFile=file(self.filename.get())
        myText= myFile.read()
        myFile.close()

        self.text_widget.insert(0.0,myText)

    def __init__(self) :
        self.root = Tk()
        Label(self.root, text="Filename: ").pack()
        self.filename = Entry(self.root)
        self.filename.pack()
        Button(self.root, text="Display", command=self.loadfile).pack()
        self.text_widget = Text(self.root)
        self.text_widget.pack(expand=1, fill=BOTH)

        self.root.mainloop()

fd = FileDisplay()








18.11.Entry
18.11.1.Read data from EntryRead data from Entry
18.11.2.Create a story based on user inputCreate a story based on user input
18.11.3.Working with Entry Fields and Grid LayoutsWorking with Entry Fields and Grid Layouts
18.11.4.Text WidgetsText Widgets