PyInstaller¶
build-exe.bat¶
1 2 3 4 5 6 7 8 | rem @echo off
for /f %%i in ('python -c "import site; print(site.getsitepackages()[0])"') do set PYTHON_ROOT="%%i"
rem copy %PYTHON_ROOT%\Lib\site-packages\arcade\Win64\avbin.dll .
rem copy avbin.dll avbin64.dll
rem pyinstaller --exclude-module tkinter --add-data resources;resources --add-data ./avbin64.dll;. --add-data ./avbin.dll;Win64 --onefile --noconsole sample.py
rem del avbin.dll
rem del avbin64.dll
rem pause
|
sample.py¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | import arcade
import sys
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 500
TITLE = 'Arcade cx_Freeze Sample'
BACKGROUND_COLOR = arcade.color.WHITE
def resource_path(file):
path = 'resources/' + file
# are we in a frozen environment (e.g. pyInstaller)?
if getattr(sys, 'frozen', False):
# noinspection PyProtectedMember,PyUnresolvedReferences
path = sys._MEIPASS.replace('\\', '/') + '/' + path
return path
def main():
arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, TITLE)
arcade.set_background_color(BACKGROUND_COLOR)
arcade.start_render()
arcade.draw_circle_filled(400, 250, 100, arcade.color.BLACK)
# load image
image = arcade.load_texture(resource_path('character.png'))
arcade.draw_texture_rectangle(200, 250, image.width, image.height, image)
# load sound
sound = arcade.sound.load_sound(resource_path('cat-meow.wav'))
arcade.sound.play_sound(sound)
arcade.finish_render()
arcade.run()
return
main()
|