Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c1bb31e

Browse files
Merge pull request avinashkranjan#662 from vikashkumar2020/SN
Sticky Notes
2 parents 41295cf + b89e233 commit c1bb31e

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

‎sticky notes/README.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Sticky Notes
2+
3+
## Description
4+
A simple GUI based application in Python that helps you to create simple remember lists or sticky notes.
5+
6+
## Language
7+
- [X] Python
8+
9+
## Instructions to run this application
10+
11+
- Now run the below command
12+
```
13+
python main.py
14+
```
15+

‎sticky notes/main.py‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# sticky notes application
2+
import tkinter
3+
from tkinter import Toplevel,Frame,X,TOP,Label,RIGHT,LEFT,BOTH,Tk
4+
import tkinter.scrolledtext as tkst
5+
from tkinter import messagebox
6+
from tkinter import font
7+
8+
no_of_windows = 1
9+
10+
11+
class StickyNotes(Toplevel):
12+
def __init__(self, master, **kwargs):
13+
super().__init__(master, **kwargs)
14+
self.xclick = 0
15+
self.yclick = 0
16+
17+
# master (root) window
18+
self.overrideredirect(True)
19+
global no_of_windows
20+
self.geometry('350x450+' + str(1000+no_of_windows*(-30)) + '+' + str(100 + no_of_windows*20))
21+
self.config(bg = '#838383')
22+
self.attributes('-topmost', 'true')
23+
self.resizable(True,True)
24+
25+
# titlebar
26+
self.titlebar = Frame(self , bg = '#F8F796', relief = 'flat', bd = 2)
27+
self.titlebar.bind('<Button-1>', self.get_pos)
28+
self.titlebar.bind('<B1-Motion>', self.move_window)
29+
self.titlebar.pack(fill = X, expand = 1, side = TOP)
30+
31+
self.closebutton = Label(self.titlebar, text = 'X', bg = '#F8F7B6', relief = 'flat')
32+
self.closebutton.bind('<Button-1>', self.quit_window)
33+
self.closebutton.pack(side = RIGHT)
34+
35+
self.newbutton = Label(self.titlebar, text = '+', bg = '#F8F7B6', relief = 'flat')
36+
self.newbutton.pack(side = LEFT)
37+
self.newbutton.bind('<Button-1>', self.another_window)
38+
39+
self.mainarea = tkst.ScrolledText(self, bg = '#FDFDCA', font=('Comic Sans MS', 14, 'italic'), relief = 'flat', padx = 5, pady = 10)
40+
self.mainarea.pack(fill = BOTH, expand = 1)
41+
42+
43+
no_of_windows += 1
44+
45+
def get_pos(self, event):
46+
self.xclick = event.x
47+
self.yclick = event.y
48+
49+
def move_window(self, event):
50+
self.geometry('+{0}+{1}'.format(event.x_root-self.xclick, event.y_root-self.yclick))
51+
52+
def another_window(self, event):
53+
StickyNotes(root)
54+
55+
def quit_window(self, event):
56+
self.closebutton.config(relief = 'flat', bd = 0)
57+
if(messagebox.askyesno('Delete Note?','Are you sure you want to delete this note?', parent = self)):
58+
global no_of_windows
59+
self.destroy()
60+
no_of_windows -= 1
61+
if(no_of_windows == 1):
62+
root.destroy()
63+
return
64+
self.closebutton.config(relief = 'flat', bd = 0, bg = '#F8F7B6')
65+
66+
root = Tk()
67+
root.withdraw()
68+
#first note start.
69+
sticky = StickyNotes(root)
70+
root.mainloop()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /