how to create a save command in python

Solutions on MaxInterview for how to create a save command in python by the best coders in the world

showing results for - "how to create a save command in python"
Janelle
09 Jul 2018
1from tkinter import *
2
3# ********** Functions **********
4def doNothing():
5print("Ok, i won't!")
6
7# ********** TK Initialization **********
8root = Tk()
9# ********** Main Menu **********
10menu = Menu(root)
11root.config(menu=menu)
12
13subMenu = Menu(menu)
14menu.add_cascade(label="File", menu=subMenu)
15subMenu.add_command(label="New", command=doNothing)
16subMenu.add_command(label="Open...", command=doNothing)
17subMenu.add_command(label="Save", command=doNothing)
18subMenu.add_command(label="Save As...", command=doNothing)
19subMenu.add_separator()
20subMenu.add_command(label="Page Setup...", command=doNothing)
21subMenu.add_command(label="Print...", command=doNothing)
22subMenu.add_separator()
23subMenu.add_command(label="Exit", command=root.quit)
24
25editMenu = Menu(menu)
26menu.add_cascade(label="Edit", menu=editMenu)
27editMenu.add_command(label="Undo", command=doNothing)
28editMenu.add_separator()
29editMenu.add_command(label="Cut", command=doNothing)
30editMenu.add_command(label="Copy", command=doNothing)
31editMenu.add_command(label="Paste", command=doNothing)
32editMenu.add_command(label="Delete", command=doNothing)
33editMenu.add_separator()
34editMenu.add_command(label="Find...", command=doNothing)
35editMenu.add_command(label="Find Next", command=doNothing)
36editMenu.add_command(label="Replace...", command=doNothing)
37editMenu.add_command(label="Go To...", command=doNothing)
38editMenu.add_separator()
39editMenu.add_command(label="Select All", command=doNothing)
40editMenu.add_command(label="Time/Date", command=doNothing)
41
42FormatMenu = Menu(menu)
43menu.add_cascade(label="Format", menu=FormatMenu)
44FormatMenu.add_command(label="Word Wrap", command=doNothing)
45FormatMenu.add_command(label="Font...", command=doNothing)
46
47ViewMenu = Menu(menu)
48menu.add_cascade(label="View", menu=ViewMenu)
49ViewMenu.add_command(label="Status Bar", command=doNothing)
50
51HelpMenu = Menu(menu)
52menu.add_cascade(label="Help", menu=HelpMenu)
53HelpMenu.add_command(label="View Help", command=doNothing)
54HelpMenu.add_separator()
55HelpMenu.add_command(label="About Editor", command=doNothing)
56
57AboutMenu = Menu(menu)
58menu.add_cascade(label="About", menu=AboutMenu)
59AboutMenu.add_command(label="About the Developer", command=doNothing)
60AboutMenu.add_separator()
61AboutMenu.add_command(label="FK YOALL", command=doNothing)
62
63
64
65# ********** Status Bar **********
66status = Label(root, text="Preparing to do nothing...", bd=1, relief=SUNKEN, 
67anchor=W)
68status.pack(side=BOTTOM, fill=X)
69
70# ********** Text Area **********
71text = Text(root, height=100, width=200)
72text.pack()
73
74# ********** Window Properties **********
75root.maxsize(width=800, height=680)
76root.minsize(width=666, height=666)
77root.title('Text Editor')
78root.mainloop()