I'm SLOWLY learning python and want to learn more from you guys who knows the language...
my first experiment is this...
Code: Select all
#!/usr/bin/env python
from Tkinter import *
from ScrolledText import *
from tkFileDialog import *
def opnfile():
filename = askopenfilename(filetypes=[("allfiles","*.py"),("pythonfiles","*.py")])
file = open(filename, 'r')
stext.delete("1.0", END)
stext.insert("1.0",file.read())
thisfile = filename
file.close()
def savfile():
filename = asksaveasfilename(filetypes=[("allfiles","*.py"),("pythonfiles","*.py")])
thisfile = filename
file = open(thisfile, 'w')
file.write(stext.get("1.0", END))
file.close()
root = Tk()
# create a menu
menu = Menu(root)
root.config(menu=menu)
stext = ScrolledText(root)
stext.pack()
filemenu = Menu(menu)
menu.add_cascade(label="File", menu=filemenu)
filemenu.add_command(label="Open", command=opnfile)
filemenu.add_command(label="Save...", command=savfile)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=menu.quit)
mainloop()
any comments will be appreciated...