Skip to content

Commit

Permalink
Update homebase.py
Browse files Browse the repository at this point in the history
- minimize to tray actually minimizes to the tray now!
  • Loading branch information
alec-jensen authored Feb 7, 2022
1 parent 41c0daa commit e36452d
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions homebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
from pydub.playback import play
from plyer import notification
import base64
from pystray import MenuItem as item
import pystray
from PIL import Image, ImageTk

# INITIALIZATIONS


hb_version = "1.1-dev"
hb_version = "1.1-dev2"
main = Tk()
main.title('Homebase')
main.resizable(False, False)
Expand Down Expand Up @@ -72,8 +74,27 @@ def settingsWrite():
settings['minimizetotray'] = True
settingsWrite()

def quit_window(icon, item):
icon.stop()
main.destroy()


def show_window(icon, item):
icon.stop()
main.after(0,main.deiconify)


def hide_window():
main.withdraw()
image=Image.open("logo.gif")
menu=(item('Quit', quit_window), item('Show', show_window), pystray.MenuItem(text='Default', action=show_window, visible=False, default=True, enabled=True))
icon=pystray.Icon("name", image, "homebase", menu)
icon.run()


if settings["minimizetotray"] == True:
main.protocol("WM_DELETE_WINDOW", main.iconify)
main.protocol("WM_DELETE_WINDOW", hide_window)

else:
main.protocol("WM_DELETE_WINDOW", main.destroy)

Expand Down Expand Up @@ -105,7 +126,7 @@ def mtt():
main.protocol("WM_DELETE_WINDOW", main.destroy)
else:
settings["minimizetotray"] = True
main.protocol("WM_DELETE_WINDOW", main.iconify)
main.protocol("WM_DELETE_WINDOW", hide_window)
settingsWrite()


Expand Down

0 comments on commit e36452d

Please sign in to comment.