forked from prathimacode-hub/Awesome_Python_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes.py
78 lines (59 loc) · 2.49 KB
/
notes.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
71
72
73
74
75
76
77
78
# sticky notes application
import tkinter
from tkinter import Toplevel, Frame, X, TOP, Label, RIGHT, LEFT, BOTH, Tk
import tkinter.scrolledtext as tkst
from tkinter import messagebox
from tkinter import font
no_of_windows = 1
class StickyNotes(Toplevel):
def __init__(self, master, **kwargs):
super().__init__(master, **kwargs)
self.yclick = 0
# master (root) window
self.overrideredirect(True)
global no_of_windows
self.geometry('450x450+' + str(1000+no_of_windows*(-30)
) + '+' + str(100 + no_of_windows*20))
self.config(bg='#00FFFF')
self.attributes('-topmost', 'true')
self.resizable(True, True)
# titlebar
self.titlebar = Frame(self, bg='#0859C6', relief='flat', bd=2)
self.titlebar.bind('<Button-1>', self.get_pos)
self.titlebar.bind('<B1-Motion>', self.move_window)
self.titlebar.pack(fill=X, expand=1, side=TOP)
self.closebutton = Label(
self.titlebar, text='X', bg='#daf0ff', relief='flat')
self.closebutton.bind('<Button-1>', self.quit_window)
self.closebutton.pack(side=RIGHT)
self.newbutton = Label(self.titlebar, text='+',
bg='#0859C6', relief='flat')
self.newbutton.pack(side=LEFT)
self.newbutton.bind('<Button-1>', self.another_window)
self.mainarea = tkst.ScrolledText(self, bg='#DBF3FA', font=(
'Comic Sans MS', 14, 'italic'), relief='flat', padx=5, pady=10)
self.mainarea.pack(fill=BOTH, expand=1)
no_of_windows += 1
def get_pos(self, event):
self.xclick = event.x
self.yclick = event.y
def move_window(self, event):
self.geometry('+{0}+{1}'.format(event.x_root -
self.xclick, event.y_root-self.yclick))
def another_window(self, event):
StickyNotes(root)
def quit_window(self, event):
self.closebutton.config(relief='flat', bd=0)
if(messagebox.askyesno('What happened ? ', "want to delete notes?", parent=self)):
global no_of_windows
self.destroy()
no_of_windows -= 1
if(no_of_windows == 1):
root.destroy()
return
self.closebutton.config(relief='flat', bd=0, bg='#003166')
root = Tk()
root.withdraw()
# first note start.
sticky = StickyNotes(root)
root.mainloop()