Skip to content

Commit 99e5ff1

Browse files
committed
Add GitHub workflows for packaging Tkinter version and PyInstaller version; update .gitignore and pyproject.toml; refactor sound file paths in blackboard.py and familiada.py
1 parent e7fe2ce commit 99e5ff1

8 files changed

Lines changed: 385 additions & 25 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Package Tkinter version of Familiada app
2+
3+
on:
4+
push:
5+
tags:
6+
- 'tkinter_v*' # Push events with a tag that starts with 'tkinter_v'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v6.0.2
17+
18+
- name: Package Application using Cythinst64
19+
uses: PlohnenSoftware/Cythinst64@v2.2
20+
with:
21+
path: src
22+
zip_name: familiada.zip
23+
zip_paths: |
24+
src/dist/windows
25+
dane.csv
26+
27+
# Step to upload the zipped folder as a workflow artifact
28+
- name: Upload artifact
29+
uses: actions/upload-artifact@v7.0.1
30+
with:
31+
name: familiada-tkinter
32+
path: familiada.zip
33+
if-no-files-found: error
34+
35+
# Step to create a release and upload the zipped folder as an asset
36+
- name: Create Release
37+
if: startsWith(github.ref, 'refs/tags/tkinter_v')
38+
id: create_release
39+
uses: softprops/action-gh-release@v3.0.0
40+
with:
41+
files: familiada.zip
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pyinstaller.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Package Familiada App with Pyinstaller
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v6.0.2
17+
- name: Package Application using Cythinst64
18+
uses: PlohnenSoftware/Cythinst64@v2.2
19+
with:
20+
path: src
21+
cython_out: prec
22+
zip_name: familiada.zip
23+
zip_paths: |
24+
src/dist/windows
25+
dane.csv
26+
27+
# Step to upload the zipped folder as a workflow artifact
28+
- name: Upload artifact
29+
uses: actions/upload-artifact@v7.0.1
30+
with:
31+
name: familiada
32+
path: familiada.zip
33+
if-no-files-found: error
34+
35+
# Step to create a release and upload the zipped folder as an asset
36+
- name: Create Release
37+
if: startsWith(github.ref, 'refs/tags/v')
38+
id: create_release
39+
uses: softprops/action-gh-release@v3.0.0
40+
with:
41+
files: familiada.zip
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
ve
12
venv
3+
.venv
24
__pycache__
35
*.pyc
4-
*.spec
6+
stare.py
7+
build
8+
*.exe

pyproject.toml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
1+
[project]
2+
name = "Familiada"
3+
version = "1.1.1"
4+
description = "Tkinter legacy release of the Familiada game."
5+
readme = "README.md"
6+
requires-python = "==3.13.*"
7+
dependencies = [
8+
"pygame>=2.6.1",
9+
"setuptools[core]>=82.0.1",
10+
]
11+
112
[tool.black]
2-
line-length = 200
13+
line-length = 200

src/Familiada.spec

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# -*- mode: python ; coding: utf-8 -*-
2+
3+
4+
a = Analysis(
5+
['familiada.py'],
6+
pathex=[],
7+
binaries=[],
8+
datas=[('../sfx', 'sfx'), ('../familiada.ico', './'), ('../familiada.ttf', './'), ('../dane.csv', './')],
9+
hiddenimports=[],
10+
hookspath=[],
11+
hooksconfig={},
12+
runtime_hooks=[],
13+
excludes=[],
14+
noarchive=False,
15+
)
16+
pyz = PYZ(a.pure)
17+
18+
exe = EXE(
19+
pyz,
20+
a.scripts,
21+
a.binaries,
22+
a.datas,
23+
[],
24+
name='Familiada',
25+
debug=False,
26+
bootloader_ignore_signals=False,
27+
strip=False,
28+
upx=True,
29+
upx_exclude=[],
30+
runtime_tmpdir=None,
31+
console=False,
32+
disable_windowed_traceback=False,
33+
argv_emulation=False,
34+
target_arch=None,
35+
codesign_identity=None,
36+
entitlements_file=None,
37+
icon=['..\\familiada.ico'],
38+
)

src/blackboard.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
1-
import pygame
1+
import pygame,sys
22
from math import floor
33
from threading import Timer as Delay
4+
from os import path, getcwd
45

56

7+
if getattr(sys, "frozen", False):
8+
application_path = path.dirname(path.abspath(__file__))
9+
CWD_PATH = getcwd()
10+
elif __file__:
11+
application_path = path.abspath("./")
12+
CWD_PATH = application_path
13+
14+
15+
def res_path(relative_path):
16+
return path.join(application_path, relative_path)
17+
618
# Import pygame SFX
719
pygame.mixer.init()
8-
correct_sound = pygame.mixer.Sound("sfx/correct.wav")
9-
wrong_sound = pygame.mixer.Sound("sfx/incorrect.wav")
10-
dubel_sound = pygame.mixer.Sound("sfx/dubel.wav")
11-
bravo_sound = pygame.mixer.Sound("sfx/bravo.wav")
12-
write_sound = pygame.mixer.Sound("sfx/write.wav")
13-
round_sound = pygame.mixer.Sound("sfx/round_sound.wav")
14-
ending_music = pygame.mixer.Sound("sfx/final_ending.flac")
15-
intro_music = pygame.mixer.Sound("sfx/show_music.flac")
20+
correct_sound = pygame.mixer.Sound(res_path("sfx/correct.wav"))
21+
wrong_sound = pygame.mixer.Sound(res_path("sfx/incorrect.wav"))
22+
dubel_sound = pygame.mixer.Sound(res_path("sfx/dubel.wav"))
23+
bravo_sound = pygame.mixer.Sound(res_path("sfx/bravo.wav"))
24+
write_sound = pygame.mixer.Sound(res_path("sfx/write.wav"))
25+
round_sound = pygame.mixer.Sound(res_path("sfx/round_sound.wav"))
26+
ending_music = pygame.mixer.Sound(res_path("sfx/final_ending.flac"))
27+
intro_music = pygame.mixer.Sound(res_path("sfx/show_music.flac"))
1628

1729

1830
class Blackboard:

src/familiada.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import pygame
2-
import sys
2+
from sys import exit
33
import tkinter
4-
import os
54
from tkinter import messagebox, ttk, filedialog
65
from 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

2726
def 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
3331
game1 = 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

4338
if filename == "":
4439
terminate_error("Nie wybrano pliku")
@@ -102,13 +97,13 @@ def terminate_error(error_description):
10297
pygame.init()
10398
surface = pygame.display.set_mode((800, 600), pygame.RESIZABLE)
10499
pygame.display.set_caption("Familiada")
105-
programIcon = pygame.image.load("familiada.ico")
100+
programIcon = pygame.image.load(res_path("familiada.ico"))
106101
pygame.display.set_icon(programIcon)
107102

108103
# Create the second window
109104
window1 = tkinter.Tk()
110105
window1.title("Familiada - reżyserka")
111-
window1.iconbitmap("familiada.ico")
106+
window1.iconbitmap(res_path("familiada.ico"))
112107
window1.geometry("650x400")
113108
style = ttk.Style(window1)
114109
window1.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

Comments
 (0)