尝试使用py2app
构建我的应用程序。创建并撰写了setup.py
:
from setuptools import setup
APP = ['main.py']
DATA_FILES = ['images/ship.png', 'images/ufo.png', 'fonts/a_lcdnova.ttf']
APP_NAME = "Alien Invasion"
OPTIONS = {
'argv_emulation': True,
'includes': ('pygame'),
'iconfile': 'images/ship.icns'
}
setup(
name=APP_NAME,
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
在这种情况下main.py
导入:
from Button import Button
from Enemy import Enemy
from Ship import Ship
from random import randint
import pygame
import sys
在使用所需图标获得正确Alien Invasion.app
的性能中,但在启动时我得到一个白色屏幕。在互联网上,我找不到如何配置setup.py
:(请帮忙!
答案 0 :(得分:0)
我的错误是指定资源文件的完整路径。有必要只指定一个文件夹,如下所示:
from setuptools import setup
APP = ['main.py']
DATA_FILES = ['images', 'fonts']
APP_NAME = "Alien Invasion"
OPTIONS = {
'argv_emulation': True,
'includes': ('pygame'),
'iconfile': 'images/ship.icns'
}
setup(
name=APP_NAME,
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)