-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHead-Ex.py
41 lines (38 loc) · 1.18 KB
/
Head-Ex.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from tkinter import *
import tkinter.messagebox
def save_data():
try:
fileD = open("deliveries.txt", "a")
fileD.write("Depot:\n")
fileD.write("%s\n" % depot.get())
fileD.write("Description:\n")
fileD.write("%s\n" % description.get())
fileD.write("Address:\n")
fileD.write("%s\n" % address.get("1.0", END))
depot.set(None)
description.delete(0, END)
description.delete(0, END)
address.delete("1.0", END)
except Exception as ex:
tkinter.messagebox.showerror("Error!", "Can't write to the file \n %s" % ex)
def read_depots(file):
depots =[]
depots_f = open(file)
for line in depots_f:
depots.append(line.rstrip())
return depots
app = Tk()
app.title('Head-Ex Deliveries')
Label(app, text = "Depot:").pack()
depot = StringVar()
depot.set(None)
options = read_depots("depots.txt")
OptionMenu(app, depot, *options).pack()
Label(app, text = "Description:").pack()
description = Entry(app)
description.pack()
Label(app, text = "Address:").pack()
address = Text(app)
address.pack()
Button(app, text = "Save", command = save_data).pack()
app.mainloop()