aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby <[email protected]>2022-11-06 08:37:03 -0500
committerBobby <[email protected]>2022-11-06 08:37:03 -0500
commit54cac2ebde7369400816c5f118b6dc7210dceb6d (patch)
tree81dfb4d2a240d5de466ee69b62284ae3901b5e0d
parent2e3f84c8e402563a9c11850ad07d95f59cd43be3 (diff)
downloadtexty-54cac2ebde7369400816c5f118b6dc7210dceb6d.tar.xz
texty-54cac2ebde7369400816c5f118b6dc7210dceb6d.zip
chore: self destroy if all windows cloased
-rw-r--r--.DS_Storebin6148 -> 8196 bytes
-rw-r--r--icons/copy.pngbin0 -> 14946 bytes
-rw-r--r--icons/cut.pngbin0 -> 28702 bytes
-rw-r--r--icons/new.pngbin0 -> 9868 bytes
-rw-r--r--icons/paste.pngbin0 -> 13504 bytes
-rw-r--r--icons/print.pngbin0 -> 9288 bytes
-rw-r--r--icons/save.pngbin0 -> 6118 bytes
-rw-r--r--src/config/defaults.py2
-rw-r--r--src/helpers/windows.py28
-rw-r--r--src/texty.py9
10 files changed, 34 insertions, 5 deletions
diff --git a/.DS_Store b/.DS_Store
index 72f0653..15a41de 100644
--- a/.DS_Store
+++ b/.DS_Store
Binary files differ
diff --git a/icons/copy.png b/icons/copy.png
new file mode 100644
index 0000000..888a570
--- /dev/null
+++ b/icons/copy.png
Binary files differ
diff --git a/icons/cut.png b/icons/cut.png
new file mode 100644
index 0000000..135de47
--- /dev/null
+++ b/icons/cut.png
Binary files differ
diff --git a/icons/new.png b/icons/new.png
new file mode 100644
index 0000000..0f9d3c4
--- /dev/null
+++ b/icons/new.png
Binary files differ
diff --git a/icons/paste.png b/icons/paste.png
new file mode 100644
index 0000000..6b19cda
--- /dev/null
+++ b/icons/paste.png
Binary files differ
diff --git a/icons/print.png b/icons/print.png
new file mode 100644
index 0000000..9c301b3
--- /dev/null
+++ b/icons/print.png
Binary files differ
diff --git a/icons/save.png b/icons/save.png
new file mode 100644
index 0000000..d0c9f29
--- /dev/null
+++ b/icons/save.png
Binary files differ
diff --git a/src/config/defaults.py b/src/config/defaults.py
index f0da742..f3796dc 100644
--- a/src/config/defaults.py
+++ b/src/config/defaults.py
@@ -42,3 +42,5 @@ MAC_KEYBINDS = {
"Hide Others": f"meta-Shift-H", # Hide Others
"Show All": f"meta-Shift-A", # Show All
}
+
+ICONS_FOLDER = "icons"
diff --git a/src/helpers/windows.py b/src/helpers/windows.py
index fc2ebbf..3ed578e 100644
--- a/src/helpers/windows.py
+++ b/src/helpers/windows.py
@@ -1,5 +1,8 @@
+import os
import tkinter as tk
+from config.defaults import ICONS_FOLDER
+
class TextyWindow(tk.Toplevel):
def __init__(self, parent):
@@ -19,9 +22,26 @@ class TextyWindow(tk.Toplevel):
self.parent.log("Resize, Move, and Close bindings set to save preferences.")
self.config(menu=self.parent.get_menubar())
+ self.set_toolbar()
def on_close(self):
- if self.parent.system == "aqua":
- self.destroy()
- else:
- self.quit()
+ self.parent.destroy_window(self)
+
+ def draw_layout(self):
+ self.parent.log("Drawing layout")
+
+ def set_toolbar(self):
+ self.parent.log("Drawing Toolbar")
+
+ toolbar = tk.Frame(self, bd=1, relief=tk.RAISED)
+
+ # add icon 16x16 buttons
+ def get_icon(name):
+ return tk.PhotoImage(file=os.path.join(ICONS_FOLDER, name))
+
+ new_icon = get_icon("new.png")
+ save_icon = get_icon("save.png")
+ cut_icon = get_icon("cut.png")
+ copy_icon = get_icon("copy.png")
+ paste_icon = get_icon("paste.png")
+ print_icon = get_icon("print.png")
diff --git a/src/texty.py b/src/texty.py
index 5e847a5..a8c92b1 100644
--- a/src/texty.py
+++ b/src/texty.py
@@ -26,16 +26,23 @@ class Texty(tk.Tk):
self.system, sys.platform
)
)
-
+ self.windows = 0
self.withdraw()
self.create_window()
def create_window(self):
+ self.windows += 1
window = TextyWindow(self)
window.grab_set()
window.focus_set()
window.mainloop()
+ def destroy_window(self, window):
+ self.windows -= 1
+ window.destroy()
+ if self.windows == 0:
+ self.destroy()
+
def get_window_geometry(self):
width = self.prefs.get("width")
height = self.prefs.get("height")