Skip to content

Commit

Permalink
shortcut links now to the "real" location
Browse files Browse the repository at this point in the history
  • Loading branch information
Teru Kaazhooft committed Jun 12, 2023
1 parent 90de679 commit a82b9c6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
15 changes: 10 additions & 5 deletions flashbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
import os
import platform
import sys
import webbrowser
import pygame
import random
Expand Down Expand Up @@ -68,18 +69,22 @@ def __init__(self, screen: pygame.Surface):

self.tournament_mode = False



def create_shortcut(self):

import main
original_exec_file_name = sys.argv[0]

logger.log(f"Creating desktop shortcut that links to {original_exec_file_name}")

if platform.system() == "Windows":
try:
import winshell
from win32com.client import Dispatch

path = os.path.join(os.path.join(os.environ["USERPROFILE"]), "Desktop") + "\\Flashbox.lnk"
target = os.path.abspath(main.__file__)
work_dir = os.path.dirname(os.path.abspath(main.__file__))
target = os.path.abspath(original_exec_file_name)
work_dir = os.path.dirname(os.path.abspath(original_exec_file_name))

shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(path)
Expand All @@ -90,7 +95,7 @@ def create_shortcut(self):
except ModuleNotFoundError:
try:
path = Path(os.path.join(os.path.join(os.environ["USERPROFILE"]), "Desktop") + "\\Flashbox.lnk")
target = Path(os.path.abspath(main.__file__))
target = Path(os.path.abspath(original_exec_file_name))

path.symlink_to(target)
except Exception as e:
Expand All @@ -101,7 +106,7 @@ def create_shortcut(self):
else:
try:
link = Path("~/Desktop/Flashbox")
target = Path(os.path.realpath(main.__file__))
target = Path(os.path.realpath(original_exec_file_name))

link.symlink_to(target)
except Exception as e:
Expand Down
3 changes: 2 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
screen = pygame.display.set_mode(size, pygame.RESIZABLE)
size = screen.get_size()

f = flashbox.Flashbox(screen)

FPS = 60
clock = pygame.time.Clock()

Expand All @@ -27,7 +29,6 @@

run = 1

f = flashbox.Flashbox(screen)
f.load()

class PeriodicSleeper(threading.Thread):
Expand Down

0 comments on commit a82b9c6

Please sign in to comment.