-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoted.py
70 lines (53 loc) · 1.48 KB
/
noted.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/python
from Tkinter import *
import pickle
root = Tk()
root.geometry("600x400")
root.title("Note Taker")
def Enter():
text_contents = text.get()
listbox.insert(END, text_contents)
text.delete(0,END)
def Remove():
listbox.delete(ANCHOR)
def Save():
f = file("notes.db", "wb")
notes = listbox.get(0, END)
pickle.dump(notes, f)
def ReturnInsert(event):
Enter()
def DeleteCurrent(event):
Remove()
def CopyToText(event):
text.delete(0, END)
current_note = listbox.get(ANCHOR)
text.insert(0, current_note)
textframe = Frame(root)
listframe = Frame(root)
enter_button = Button(textframe, text="Enter", command = Enter)
remove_button = Button(textframe, text="Remove", command = Remove)
save_button = Button(textframe, text="Save", command = Save)
text = Entry(textframe)
scrollbar = Scrollbar(listframe, orient=VERTICAL)
listbox = Listbox(listframe, yscrollcommand=scrollbar.set, selectmode=EXTENDED)
scrollbar.configure(command=listbox.yview)
text.bind("<Return>", ReturnInsert)
listbox.bind("<Double-Button-3>", DeleteCurrent)
listbox.bind("<Double-Button-1>", CopyToText)
text.pack(side=LEFT, fill=X, expand=1)
enter_button.pack(side=LEFT)
remove_button.pack(side=LEFT)
save_button.pack(side=LEFT)
listbox.pack(side=LEFT,fill=BOTH, expand=1)
scrollbar.pack(side=RIGHT, fill=Y)
textframe.pack(fill=X)
listframe.pack(fill=BOTH, expand=1)
try:
f = file("notes.db", "rb")
notes = pickle.load(f)
for item in notes:
listbox.insert(END,item)
f.close()
except:
pass
root.mainloop()