-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
43 lines (35 loc) · 1.5 KB
/
main.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
import tkinter as tk
import tkinter.messagebox as tkmb
# Create the GUI window
root = tk.Tk()
root.title("Scribblespace")
root.configure(bg='light yellow')
# Create a Text widget to display the notes
notes_text = tk.Text(root, bg='light yellow')
notes_text.pack()
# Create a Save button
def save_notes():
if tkmb.askyesno("Scribblespace", "Are you sure you want to save? This will overwrite existing notes."):
with open("scribbles.txt", "w") as file:
file.write(notes_text.get("1.0", "end"))
tkmb.showinfo("Scribblespace", "Notes saved successfully!")
save_button = tk.Button(root, text="Save", command=save_notes, bg='light yellow')
save_button.pack()
# Create a Load button
def load_notes():
if notes_text.get("1.0", "end-1c") != "":
if not tkmb.askyesno("Scribblespace", "Are you sure you want to load? This will overwrite your current notes."):
return
with open("scribbles.txt", "r") as file:
notes_text.delete("1.0", tk.END)
notes_text.insert("1.0", file.read())
tkmb.showinfo("Scribblespace", "Notes loaded successfully!")
load_button = tk.Button(root, text="Load", command=load_notes, bg='light yellow')
load_button.pack()
# Confirmation message before clearing the notes
def clear_notes():
if tkmb.askyesno("Scribblespace", "Are you sure you want to clear all notes?"):
notes_text.delete("1.0", tk.END)
clear_button = tk.Button(root, text="Clear", command=clear_notes, bg='light yellow')
clear_button.pack()
root.mainloop()