forked from Gaoshiguo/Python-GUI-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotepad.py
More file actions
23 lines (20 loc) · 904 Bytes
/
Copy pathnotepad.py
File metadata and controls
23 lines (20 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import tkinter
from tkinter.filedialog import *
from tkinter import *
root = tkinter.Tk()
def file_save():
f = tkinter.filedialog.asksaveasfile(mode='w', filetypes=[("txt",".txt"),("csv",".csv"),("PNG",".png"),("GPF",".gpf"),("JPG",".jpg"),("python",".py")])
if f is None: # asksaveasfile return `None` if dialog closed with "cancel".
return
text2save = str(text.get(1.0, END)) # starts from `1.0`, not `0.0`
f.write(text2save)
f.close() # `()` was missing.
label=Label(root,text="请输入您想要保存的文字:")
label.place(relx=0.3,rely=0.01,relwidth=0.3,relheight=0.2)
text = Text(root,width=20,height=15)
text.place(relx=0.3,rely=0.2,relwidth=0.5,relheight=0.5)
button=Button(root,text="选择想要复制的存储路径",command=file_save)
button.place(relx=0.3,rely=0.7)
root.title = ('记事本')
root.geometry('640x480')
root.mainloop()