Author Topic: [Python] Very Basic Text Editor  (Read 483 times)

0 Members and 1 Guest are viewing this topic.

Offline AnonymousCelt

  • /dev/null
  • *
  • Posts: 11
  • Cookies: 0
    • View Profile
[Python] Very Basic Text Editor
« on: March 12, 2015, 06:19:21 pm »
Code: [Select]

from Tkinter import *
from tkFileDialog import askopenfilename
from tkFileDialog import asksaveasfilename


def OpenFile():
    name = askopenfilename()
    with file(name) as f:
        T.insert(END,f.read())


def SaveFileAs():
    name = asksaveasfilename()
    a = open(name, 'w')
    a.write(T.get('1.0', 'end'))


#Create Menu
root = Tk()
menu = Menu(root)
root.config(menu=menu)


#File Menu
filemenu = Menu(menu)
menu.add_cascade(label="File", menu=filemenu)
filemenu.add_command(label="Open", command=OpenFile)
filemenu.add_command(label="Save As", command=SaveFileAs)
           
#Create Text Box
T = Text(root,height=50, width=100)
T.pack()


#Main
root.mainloop()