how to make your python code into an application(which uses wx python-GUI program)

34 views
Skip to first unread message

sreeragh AR

unread,
May 18, 2015, 11:43:56 AM5/18/15
to wxpytho...@googlegroups.com
Pyinstaller was successful  for simple python programs
but when programs using wx python was used it doesnot work ..
The window(of GUI) is not appearing

Chris Norman

unread,
May 18, 2015, 1:03:25 PM5/18/15
to wxpytho...@googlegroups.com
Read pyinstaller --help, there's a switch for using a GUI.

If it's of any help, here's my (unfortunately cryptic) make.py file:

from shutil import rmtree, copytree, copy
from application import name as appName, version as appVersion
from os import system, rename, listdir, walk, path, mkdir, chdir, getcwd
import zipfile, plistlib
import sys

cwd = getcwd()

dels = [
 'dist',
 'build',
 '%s.app' % appName,
 appName
]

for d in dels:
 if d in listdir('.'):
  print 'Deleting %s...' % d
  rmtree(d)
 else:
  print 'Directory not found so not deleting: %s.' % d

if sys.platform.startswith('win'):
 system('pyinstaller -wy --clean --log-level WARN -n %s --distpath . main.py' % appName)
 output = appName
 xd = appName
elif sys.platform == 'darwin':
 system('py2applet main.py')
 n = '%s.app' % appName
 while 1:
  try:
   rename('main.app', n)
   break
  except OSError:
   continue
 output = n
 mkdir(path.join(n, 'Contents', 'Resources', 'English.lproj'))
 pf = path.join(n, 'Contents', 'Info.plist')
 p = plistlib.readPlist(pf)
 p.LSHasLocalizedDisplayName = True
 plistlib.writePlist(p, pf)
 with open(path.join(n, 'Contents', 'Resources', 'English.lproj', 'InfoPlist.strings'), 'w') as f:
  f.write('CFBundleName="%s";\nCFBundleDisplayName="%s";\n' % (appName, appName))
 xd = path.join(n, 'Contents', 'Resources')
else:
 quit("Don't know how to run on %s." % sys.platform)

for d in listdir('xtras'):
 origin = path.join('xtras', d)
 dest = path.join(xd, d)
 if path.isdir(origin):
  copytree(origin, dest)
 else:
  copy(origin, dest)
 print 'Copied %s.' % d

print 'Creating Zipfile...'
z = '%s-%s-%s.zip' % (appName, appVersion, sys.platform)
zf = zipfile.ZipFile(z, 'w')
for root, dirs, files in walk(output):
 for file in files:
  p = path.join(root, file)
  zf.write(p)
zf.close()
print 'Zip file created.'

HTH,
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages