-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDateNote.py
More file actions
44 lines (34 loc) · 1.18 KB
/
DateNote.py
File metadata and controls
44 lines (34 loc) · 1.18 KB
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
import tkinter as tk
import tkinter.font as tkFont
import KeepAspectRatio
class DateNote(tk.Frame):
def __init__(self, controller, parent, text: str, note_id: int, color: str):
tk.Frame.__init__(self, parent)
self.txt = text
self.controller = controller
self.id = note_id
self.font = tkFont.Font(size=10)
self.menu = tk.Menu(self, tearoff=0)
self.menu.add_command(label="Obriši", command=lambda: self.Delete())
self.text = tk.Label(
self,
anchor="w",
justify="left",
text=text,
font=self.font,
bg=color
)
self.text.pack(side="top", expand=True, fill="both")
self.text.bind("<Button-3>", self.show_menu)
KeepAspectRatio.subscribe(self)
def delete(self):
self.controller.delete_note(self.id)
def show_menu(self, event):
try:
self.menu.tk_popup(event.x_root, event.y_root)
finally:
self.menu.grab_release()
def set_font(self, size: int):
self.font.configure(size=size)
def keep_aspect_ratio(self):
self.text.configure(wraplength=KeepAspectRatio.x - 20)