Skip to content

Instantly share code, notes, and snippets.

@jamesadney
Created May 18, 2011 15:49
Show Gist options
  • Save jamesadney/978852 to your computer and use it in GitHub Desktop.
Save jamesadney/978852 to your computer and use it in GitHub Desktop.
Simple Tk text file reader
from Tkinter import *
import tkFileDialog
main = Tk()
main.title("Notpad")
main.minsize(width=500,height=400)
text = Text(main)
text.pack(expand=YES, fill=BOTH)
def doOpen():
the_file = tkFileDialog.askopenfile(mode='r')
text.insert(0.0, the_file.read())
button = Button(main, text="Open file", command=doOpen)
button.pack()
main.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment