Pack Syncplay in a single .app file for macOS distribution

This commit is contained in:
alby128 2017-09-07 15:11:39 +02:00
parent 65e51c201d
commit 214fa45759
4 changed files with 51 additions and 1 deletions

32
buildPy2app.py Normal file
View File

@ -0,0 +1,32 @@
"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""
from setuptools import setup
from glob import glob
import syncplay
APP = ['syncplayClient.py']
DATA_FILES = [
('resources', glob('resources/*.png')),
]
OPTIONS = {
'iconfile':'resources/icon.icns',
'plist': {
'CFBundleName':'Syncplay',
'CFBundleShortVersionString':syncplay.version,
'CFBundleIdentifier':'pl.syncplay.Syncplay',
'NSHumanReadableCopyright': '@ 2017 Syncplay All Rights Reserved'
}
}
setup(
app=APP,
name='Syncplay',
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)

BIN
resources/icon.icns Normal file

Binary file not shown.

View File

@ -1342,6 +1342,10 @@ class MainWindow(QtGui.QMainWindow):
# Help menu
window.helpMenu = QtGui.QMenu(getMessage("help-menu-label"), self)
if sys.platform.startswith('darwin'):
window.about = window.helpMenu.addAction("&About")
window.about.triggered.connect(self.openAbout)
window.userguideAction = window.helpMenu.addAction(QtGui.QIcon(self.resourcespath + 'help.png'),
getMessage("userguide-menu-label"))
window.userguideAction.triggered.connect(self.openUserGuide)
@ -1353,6 +1357,15 @@ class MainWindow(QtGui.QMainWindow):
if not sys.platform.startswith('darwin'):
window.mainLayout.setMenuBar(window.menuBar)
def openAbout(self):
AboutMsgBox = QtGui.QMessageBox.about(self,"Syncplay","Syncplay v" + version)
# AboutMsgBox = QtGui.QMessageBox()
# AboutMsgBox.setText("Test text")
# AboutMsgBox.setStandardButtons(0)
# AboutMsgBox.setModal(True)
# AboutMsgBox.exec_()
def addMainFrame(self, window):
window.mainFrame = QtGui.QFrame()
window.mainFrame.setLineWidth(0)
@ -1618,6 +1631,9 @@ class MainWindow(QtGui.QMainWindow):
self.resourcespath = utils.findWorkingDir() + u"\\resources\\"
else:
self.resourcespath = utils.findWorkingDir() + u"/resources/"
if sys.platform.startswith('darwin'):
self.setWindowFlags(self.windowFlags())
else:
self.setWindowFlags(self.windowFlags() & Qt.AA_DontUseNativeMenuBar)
self.setWindowTitle("Syncplay v" + version)
self.mainLayout = QtGui.QVBoxLayout()

View File

@ -124,6 +124,8 @@ def findWorkingDir():
path = os.path.dirname(os.path.dirname(__file__))
elif frozen in ('dll', 'console_exe', 'windows_exe'):
path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
elif frozen in ('macosx_app'):
path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))))
else:
path = ""
return path