Python save as/open

。_饼干妹妹 提交于 2021-02-11 15:44:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!