|
3 | 3 | import tkinter as tk |
4 | 4 | import customtkinter as ctk |
5 | 5 | import os |
| 6 | +import sys |
6 | 7 | import configparser |
7 | 8 | from datetime import datetime, timezone |
8 | 9 |
|
| 10 | +# pyinstaller main.py --onefile --icon=VATSIM.ico --add-data "VATSIM.ico;." -w -n Vatsim-Discord-RPC |
| 11 | + |
| 12 | +'''Used for VATSIM.ico file during compiling''' |
| 13 | +def resource_path(relative_path): |
| 14 | + try: |
| 15 | + # PyInstaller creates a temp folder and stores the path in _MEIPASS |
| 16 | + base_path = sys._MEIPASS |
| 17 | + except Exception: |
| 18 | + base_path = os.path.abspath(".") |
| 19 | + |
| 20 | + return os.path.join(base_path, relative_path) |
9 | 21 |
|
10 | 22 | # Path for config.ini |
11 | 23 | roaming_path = os.path.join(os.getenv('APPDATA'), "VATSIM-Discord-RPC") |
| 24 | + |
12 | 25 | # If path does not exist, then creates it |
13 | 26 | if not os.path.exists(roaming_path): |
14 | 27 | os.makedirs(roaming_path) |
@@ -46,7 +59,6 @@ def get_pilot_info(user_cid): |
46 | 59 | def get_data(user_cid): |
47 | 60 | try: |
48 | 61 | pilot = get_pilot_info(user_cid) |
49 | | - print(pilot) |
50 | 62 | call_sign = pilot.get("callsign") |
51 | 63 | altitude = pilot.get("altitude") |
52 | 64 | hdg = pilot.get("heading") |
@@ -99,6 +111,7 @@ def get_data(user_cid): |
99 | 111 | root = ctk.CTk() |
100 | 112 | root.title("VATSIM Discord Rich Presence") |
101 | 113 | root.geometry("450x200") |
| 114 | +root.wm_iconbitmap(resource_path("VATSIM.ico")) |
102 | 115 |
|
103 | 116 | # cid and checkbox values |
104 | 117 | cid_var = tk.StringVar() |
@@ -176,7 +189,7 @@ def update_presence(): |
176 | 189 | # Makes sure pilot is online and exists |
177 | 190 | if(data!= None): |
178 | 191 | formated_string = "" |
179 | | - |
| 192 | + |
180 | 193 | # Sets depature airport |
181 | 194 | if data[1]: |
182 | 195 | formated_string += f"{data[1]}" |
|
0 commit comments