我在mac osx上使用python创建应用程序。我使用py2app从myapp.py python脚本文件和setup.py中创建myapp.app。在我myapp.py的代码,我使用的终端,通知作为如何在使用py2app打包时包含终端通知器
def notify(title, subtitle, message):
t = '-title {!r}'.format(title)
s = '-subtitle {!r}'.format(subtitle)
m = '-message {!r}'.format(message)
os.system('terminal-notifier {}'.format(' '.join([m, t, s])))
notify(
title = 'Title message',
subtitle = 'with python',
message = 'Validating user'
)
它工作正常的显示为安装后sudo gem install terminal-notifier
通知。终端通知器出现在我的系统in location /Library/Ruby
中。我的问题是how to include this in py2app for developing my app, as py2app is not able to include terminal-notifier in myapp.app
。我的setup.py是
from setuptools import setup
APP=['myapp.py']
DATA_FILES= [('',['config.cfg'])]
OPTIONS={'iconfile':'cc.icns','argv_emulation': True,'plist':{'CFBundleShortVersionString':'1.0'}}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app']
)
我很欣赏你的建议。但是,terminal-notifier是安装在Ruby中的。脚本包含在Python代码中,因此不需要将其包含在Resources文件夹中。我的问题是,如何在py2app中包含终端通告器。 – nanda4
我不明白你的问题。正如我前面提到的,您可以将文件添加到data_files选项以将其包含在应用程序包中,但这显然不是您想要的。 Py2app不能在运行应用程序的机器上奇迹般地导致安装红宝石。 –
terminal-notifier安装在location/Library/Ruby中。现在的问题是如何通过py2app制作应用程序时包含这一点。 – nanda4