11import pygame
2- import sys
2+ from sys import exit
33import tkinter
4- import os
54from tkinter import messagebox , ttk , filedialog
65from blackboard import Blackboard as Bb
7- from blackboard import dubel_sound , bravo_sound , round_sound , intro_music , ending_music
6+ from blackboard import dubel_sound , bravo_sound , round_sound , intro_music , ending_music , res_path , CWD_PATH
87
98# The program provides a graphical interface for the game Familiada.
109
@@ -21,24 +20,20 @@ def exit_app(tkwindow):
2120 tkwindow .destroy ()
2221 pygame .display .quit ()
2322 pygame .quit ()
24- sys . exit ()
23+ exit ()
2524
2625
2726def terminate_error (error_description ):
2827 if messagebox .showerror ("FAMILIADA ERROR" , error_description ):
29- sys .exit ()
30-
28+ exit ()
3129
3230# Initialize the main game object
3331game1 = Bb (20 )
34-
35- # Read data from the disk
36- current_dir = os .path .dirname (os .path .abspath (__file__ ))
3732# lepiej zrobić pulpit na start, do finalnej wersji bo jak sie d exe spakuje to wywala do jakiegoś folderu temp,
3833# gdzie jest interpreter pythona przenosny z Pyinstallera
3934# current_dir=os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop')
4035
41- filename = filedialog .askopenfilename (initialdir = current_dir , title = "Wybierz plik z danymi" , filetypes = (("csv files" , "*.csv" ), ("all files" , "*.*" )))
36+ filename = filedialog .askopenfilename (initialdir = CWD_PATH , title = "Wybierz plik z danymi" , filetypes = (("csv files" , "*.csv" ), ("all files" , "*.*" )))
4237
4338if filename == "" :
4439 terminate_error ("Nie wybrano pliku" )
@@ -102,13 +97,13 @@ def terminate_error(error_description):
10297pygame .init ()
10398surface = pygame .display .set_mode ((800 , 600 ), pygame .RESIZABLE )
10499pygame .display .set_caption ("Familiada" )
105- programIcon = pygame .image .load ("familiada.ico" )
100+ programIcon = pygame .image .load (res_path ( "familiada.ico" ) )
106101pygame .display .set_icon (programIcon )
107102
108103# Create the second window
109104window1 = tkinter .Tk ()
110105window1 .title ("Familiada - reżyserka" )
111- window1 .iconbitmap ("familiada.ico" )
106+ window1 .iconbitmap (res_path ( "familiada.ico" ) )
112107window1 .geometry ("650x400" )
113108style = ttk .Style (window1 )
114109window1 .protocol ("WM_DELETE_WINDOW" , lambda : exit_app (window1 ))
@@ -234,7 +229,7 @@ def terminate_error(error_description):
234229 font_height = max (round (block_height * 0.75 ), 2 )
235230
236231 # Set the font
237- myfont = pygame .font .Font ("familiada.ttf" , font_height )
232+ myfont = pygame .font .Font (res_path ( "familiada.ttf" ) , font_height )
238233
239234 # Draw black rectangles & letters on the surface.
240235 for i in range (10 ):
@@ -261,4 +256,4 @@ def terminate_error(error_description):
261256
262257 # Quit the game if the window is closed
263258 except pygame .error :
264- sys . exit ()
259+ exit ()
0 commit comments