问题
hello there i am making a text editor in Tkinter (python) and so i made a menu and wanted to know how i can call a function that will display the windows Save-as or open boxes that every program uses. For example in notepad you can click file-save and then it opens the windows save box. I already have the menu but how can i open the save box. Thanks a lot.
回答1:
Here is an example from http://www.daniweb.com/forums/thread39327.html:
import tkFileDialog
def open_it():
filename = tkFileDialog.askopenfilename()
print filename # test
def save_it():
filename = tkFileDialog.askopenfilename()
print filename # test
def save_as():
filename = tkFileDialog.asksaveasfilename()
print filename # test
来源:https://stackoverflow.com/questions/3950034/python-save-as-open