Mega Code Archive

 
Categories / Python / GUI Tk
 

Show a file in a text widget

from Tkinter import * import Pmw, sys filename = "index.htm" root = Tk()             top = Frame(root); top.pack(side='top') text = Pmw.ScrolledText(top,        borderframe=5,         vscrollmode='dynamic',         hscrollmode='dynamic',        labelpos='n',         label_text='file %s' % filename,        text_width=40,         text_height=4,        text_wrap='none',        ) text.pack() text.insert('end', open(filename,'r').read()) Button(top, text='Quit', command=root.destroy).pack(pady=15) root.mainloop()