diff options
| author | Bobby <[email protected]> | 2022-11-06 08:37:03 -0500 |
|---|---|---|
| committer | Bobby <[email protected]> | 2022-11-06 08:37:03 -0500 |
| commit | 54cac2ebde7369400816c5f118b6dc7210dceb6d (patch) | |
| tree | 81dfb4d2a240d5de466ee69b62284ae3901b5e0d | |
| parent | 2e3f84c8e402563a9c11850ad07d95f59cd43be3 (diff) | |
| download | texty-54cac2ebde7369400816c5f118b6dc7210dceb6d.tar.xz texty-54cac2ebde7369400816c5f118b6dc7210dceb6d.zip | |
chore: self destroy if all windows cloased
| -rw-r--r-- | .DS_Store | bin | 6148 -> 8196 bytes | |||
| -rw-r--r-- | icons/copy.png | bin | 0 -> 14946 bytes | |||
| -rw-r--r-- | icons/cut.png | bin | 0 -> 28702 bytes | |||
| -rw-r--r-- | icons/new.png | bin | 0 -> 9868 bytes | |||
| -rw-r--r-- | icons/paste.png | bin | 0 -> 13504 bytes | |||
| -rw-r--r-- | icons/print.png | bin | 0 -> 9288 bytes | |||
| -rw-r--r-- | icons/save.png | bin | 0 -> 6118 bytes | |||
| -rw-r--r-- | src/config/defaults.py | 2 | ||||
| -rw-r--r-- | src/helpers/windows.py | 28 | ||||
| -rw-r--r-- | src/texty.py | 9 |
10 files changed, 34 insertions, 5 deletions
| Binary files differ diff --git a/icons/copy.png b/icons/copy.png Binary files differnew file mode 100644 index 0000000..888a570 --- /dev/null +++ b/icons/copy.png diff --git a/icons/cut.png b/icons/cut.png Binary files differnew file mode 100644 index 0000000..135de47 --- /dev/null +++ b/icons/cut.png diff --git a/icons/new.png b/icons/new.png Binary files differnew file mode 100644 index 0000000..0f9d3c4 --- /dev/null +++ b/icons/new.png diff --git a/icons/paste.png b/icons/paste.png Binary files differnew file mode 100644 index 0000000..6b19cda --- /dev/null +++ b/icons/paste.png diff --git a/icons/print.png b/icons/print.png Binary files differnew file mode 100644 index 0000000..9c301b3 --- /dev/null +++ b/icons/print.png diff --git a/icons/save.png b/icons/save.png Binary files differnew file mode 100644 index 0000000..d0c9f29 --- /dev/null +++ b/icons/save.png 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") |
