Skip to content

Commit

Permalink
macos notifications work
Browse files Browse the repository at this point in the history
  • Loading branch information
RainbowTabitha committed Feb 4, 2024
1 parent 3b11e6c commit 42c0338
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 39 deletions.
43 changes: 6 additions & 37 deletions functions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# ============================================
# Mario Party Toolkit
# Author: Nayla Hanegan ([email protected])
# Date: 1/23/2024

# Date: 2/4/2024
# License: MIT
# ============================================

Expand All @@ -15,38 +14,6 @@
import webbrowser
from version import appVersion

def createDialog(windowTitle, warn, info, buttonTxt=None):
completeWindow = ctk.CTkToplevel()
completeWindow.geometry("600x165")
completeWindow.title(windowTitle)

# Load success image and display it in the success window
img = ctk.CTkImage(Image.open(fetchResource("assets/" + warn + ".png")), size=(100, 100))
imgLabel = ctk.CTkLabel(completeWindow, image=img, text="")
imgLabel.grid(row=0, column=0, padx=10, pady=10)
imgLabel.image = img # Keep a reference to the image

if buttonTxt == None:
pass
else:
try:
button = ctk.CTkButton(completeWindow, command=run_update, text=buttonTxt)
button.grid(row=1, column=0, padx=50, pady=10)
except:
pass

# Configure row and column weights
completeWindow.columnconfigure(0, weight=1)
completeWindow.rowconfigure(0, weight=1)

# Display success message in the success window
label = ctk.CTkLabel(completeWindow, text=info, font=ctk.CTkFont(size=18))
label.grid(row=0, column=1, padx=25, pady=10)
completeWindow.focus()

def updateEmu():
pass

def fetchResource(resource_path: Path) -> Path:
try: # Running as *.exe; fetch resource from temp directory
base_path = Path(sys._MEIPASS)
Expand All @@ -61,6 +28,7 @@ def create_image_icon(frame, image_path, row, column):
image = image.resize((48, 48))
image_tk = ImageTk.PhotoImage(image)
label = tk.Label(frame, image=image_tk)
label.configure(bg='#323232') # Windows fix
label.image = image_tk # Keep a reference to the image to prevent it from being garbage collected
label.grid(row=row, column=column)

Expand All @@ -71,10 +39,11 @@ def check_for_updates():
if response.status_code == 200:
latest_version = response.text.strip()

if latest_version > current_version:
createDialog("Update Available", "update", "A new version is available. Please update.", "Update Now")
if latest_version > appVersion:
notification.notify(title= "Error", message = "Update Available!", app_icon=fetchResource("assets/diceBlock.ico"), timeout = 10)

else:
createDialog("Error", "error", "Unable to check for updates!")
notification.notify(title= "Error", message = "Unable to check for updates!", app_icon=fetchResource("assets/diceBlock.ico"), timeout = 10)

def run_update():
url = "https://github.com/EndangeredNayla/Mario-Party-Toolkit/releases"
Expand Down
8 changes: 8 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@

from CTkToolTip import *
from plyer import notification
from functools import partial

from functions import *
from credits import *
from codes import *

try:
from mac_notifications import client
except:
pass # Any OS other then Winodws

customtkinter.set_appearance_mode("Dark") # Modes: "System" (standard), "Dark", "Light"
customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"

Expand All @@ -32,6 +38,8 @@ def __init__(self):
self.title("Mario Party: Toolkit")
self.geometry(f"{1330}x{780}")

check_for_updates()

# configure grid layout (4x4)
self.grid_columnconfigure(1, weight=1)
self.grid_columnconfigure((2, 3), weight=0)
Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ pyinstaller
requests
nuitka
CTkToolTip
plyer
pyobjus
plyer; sys_platform == 'win32' or 'linux'
pyobjus; sys_platform == 'win32' or 'linux'
macos-notifications; sys_platform == 'darwin'

0 comments on commit 42c0338

Please sign in to comment.