471,338 Members | 1,489 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,338 software developers and data experts.

wxPython - py2app setup script for simple app

46
Hey guys

I have just created a gui version of a script with wxpython and it seems to work properly when I run it from a shell.
(All my script does is create a set of folders with a bunch of subfolders)

I then used py2app to try build a standalone/distributable version of it. Once built the app runs and when I hit the "go" button it seems to work.

But it does not create any of the folders.

That is probably a poor explanation of what is going on - hopefully it makes some sense.

Any ideas?

Cheers!

Here is my script that I build with py2app:


Expand|Select|Wrap|Line Numbers
  1.  
  2. #!/usr/bin/python
  3.  
  4. # newjob.py
  5. # version 1.0 June 24 
  6.  
  7. import wx
  8. import os
  9. import sys
  10.  
  11. class MyFrame(wx.Frame):
  12.     def __init__(self, parent, id, title):
  13.         wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(400, 200))
  14.  
  15.         panel = wx.Panel(self, -1)
  16.  
  17.         self.bitmap = wx.Bitmap('/Volumes/HD2/adam/job_structure/gui/newjob/finito.jpg')
  18.         wx.EVT_PAINT(self, self.OnPaint)
  19.  
  20.  
  21.         wxID_ENTERJOBNAME = wx.NewId()
  22.         wxID_JOBNAME = wx.NewId()
  23.         wxID_ENTERSHOTNAME = wx.NewId()
  24.         wxID_shotAmount = wx.NewId()
  25.         wxID_QUITBUTTON = wx.NewId()
  26.         wxID_GOBUTTON = wx.NewId()
  27.  
  28.  
  29.         self.Approot = os.path.dirname(sys.argv[0]) 
  30.  
  31.  
  32.         self.EnterJobname = wx.StaticText(panel, wxID_ENTERJOBNAME, 'Enter a job name:', (10, 20), style=wx.ALIGN_LEFT)
  33.         self.JobName = wx.TextCtrl(panel, wxID_JOBNAME, '', (25,50), (200, -1))
  34.  
  35.         self.EntershotAmount = wx.StaticText(panel, wxID_ENTERSHOTNAME, 'Enter number of shots:', (10, 80), style=wx.ALIGN_LEFT)        
  36.         self.NumberOfShots = wx.TextCtrl(panel, wxID_shotAmount, '', (25,110), (85, -1))
  37.  
  38.         self.QuitButton = wx.Button(panel, wxID_QUITBUTTON, "Quit", (10,145))
  39.         self.QuitButton.Bind(wx.EVT_BUTTON, self.OnClose, id=wxID_QUITBUTTON)
  40.  
  41.         self.GoButton = wx.Button(panel, wxID_GOBUTTON, "GO!!!", (200,145))
  42.         self.GoButton.Bind(wx.EVT_BUTTON, self.OnCreateJob, id=wxID_GOBUTTON)
  43.  
  44.  
  45.     def OnPaint(self, event):
  46.         dc = wx.PaintDC(self)
  47.         dc.DrawBitmap(self.bitmap, 240, 20)
  48.  
  49.  
  50.     def OnClose(self, event):
  51.         self.Close(True)
  52.  
  53.  
  54.     def OnCreateJob(self, event):
  55.  
  56.         jobFolderName = self.JobName.GetValue()
  57.         shotAmount = int( self.NumberOfShots.GetValue())
  58.  
  59.         jobroot = self.Approot
  60.  
  61.         def GLOBALSDIR():
  62.  
  63.             os.mkdir( "global")
  64.  
  65.             os.mkdir( "global/2d")
  66.             os.mkdir( "global/2d/ae")
  67.             os.mkdir( "global/2d/ae/render")
  68.             os.mkdir( "global/2d/ae/script")
  69.             os.mkdir( "global/2d/ai")
  70.             os.mkdir( "global/2d/ai/project")    
  71.             os.mkdir( "global/2d/ai/export")
  72.             os.mkdir( "global/2d/motion")
  73.             os.mkdir( "global/2d/motion/scripts")
  74.             os.mkdir( "global/2d/motion/render")
  75.             os.mkdir( "global/2d/psd")
  76.             os.mkdir( "global/2d/psd/project")
  77.             os.mkdir( "global/2d/psd/export")
  78.             os.mkdir( "global/2d/shk")
  79.             os.mkdir( "global/2d/shk/script")
  80.             os.mkdir( "global/2d/shk/render")
  81.             os.mkdir( "global/2d/output")
  82.  
  83.             os.mkdir( "global/3d")
  84.             os.mkdir( "global/3d/boujou")
  85.             os.mkdir( "global/3d/maya")
  86.             os.mkdir( "global/3d/max")
  87.             os.mkdir( "global/3d/syntheyes")
  88.             os.mkdir( "global/3d/output")
  89.  
  90.             os.mkdir( "global/color")
  91.  
  92.             os.mkdir( "global/output")
  93.             os.mkdir( "global/output/dvd")
  94.             os.mkdir( "global/output/dvd/projects")
  95.             os.mkdir( "global/output/dvd/builds")
  96.             os.mkdir( "global/output/quicktime")
  97.  
  98.             os.mkdir( "global/edit")
  99.             os.mkdir( "global/edit/audio")
  100.             os.mkdir( "global/edit/fcp")
  101.             os.mkdir( "global/edit/fcp/projects")
  102.             os.mkdir( "global/edit/graphics")
  103.             os.mkdir( "global/edit/edl")
  104.             os.mkdir( "global/edit/xml")
  105.  
  106.             os.mkdir( "global/plates")
  107.             os.mkdir( "global/ref")
  108.  
  109.  
  110.         def SUBFOLDERS():
  111.  
  112.             os.mkdir( "2d")
  113.             os.mkdir( "2d/ae")
  114.             os.mkdir( "2d/ae/render")
  115.             os.mkdir( "2d/ae/script")
  116.             os.mkdir( "2d/ai")
  117.             os.mkdir( "2d/ai/project")    
  118.             os.mkdir( "2d/ai/export")
  119.             os.mkdir( "2d/motion")
  120.             os.mkdir( "2d/motion/scripts")
  121.             os.mkdir( "2d/motion/render")
  122.             os.mkdir( "2d/psd")
  123.             os.mkdir( "2d/psd/project")
  124.             os.mkdir( "2d/psd/export")
  125.             os.mkdir( "2d/shk")
  126.             os.mkdir( "2d/shk/render")
  127.             os.mkdir( "2d/shk/script")
  128.             os.mkdir( "2d/output")
  129.  
  130.             os.mkdir( "3d")
  131.             os.mkdir( "3d/boujou")
  132.             os.mkdir( "3d/maya")
  133.             os.mkdir( "3d/max")
  134.             os.mkdir( "3d/syntheyes")
  135.             os.mkdir( "3d/output")
  136.  
  137.             os.mkdir( "plates")
  138.  
  139.             os.chdir( "../")
  140.  
  141.  
  142.         #CREATE JOB DIRECTORY
  143.         os.mkdir( jobFolderName)
  144.  
  145.         #CREATE OFFLINE & CHANGE INTO OFFLINE DIRECTORY TO CREATE ALL THE SHOT DIRECTORIES & GLOBALS
  146.         os.mkdir( jobFolderName + "/offline")
  147.         os.chdir( jobFolderName + "/offline")
  148.         GLOBALSDIR()
  149.  
  150.         #CREATE SHOT DIRECTORY AND AND SUB-DIRECTORIES
  151.  
  152.         for i in range(1, shotAmount + 1):
  153.             shotname = '%03d' % (i)
  154.             os.mkdir( shotname)
  155.             os.chdir( shotname)
  156.             SUBFOLDERS()
  157.  
  158.         #GO BACK ONE DIRECTORY INTO THE JOB FOLDER
  159.  
  160.         os.chdir( "../")
  161.  
  162.         #CREATE ONLINE & CHANGE INTO ONLINE DIRECTORY TO CREATE GLOBAL DIRECTORY
  163.  
  164.         os.mkdir( "online")
  165.         os.chdir( "online")
  166.  
  167.         GLOBALSDIR()
  168.  
  169.         #CREATE SHOT DIRECTORY AND AND SUB-DIRECTORIES
  170.  
  171.         for i in range(1, shotAmount + 1):
  172.             shotname = '%03d' % (i)
  173.             os.mkdir( shotname)
  174.             os.chdir( shotname)
  175.             SUBFOLDERS()
  176.  
  177.         dlg = wx.MessageDialog(self, 'Sweet! ', 'The job directory "' + jobFolderName + '" has been created', wx.OK|wx.ICON_INFORMATION)
  178.         dlg.ShowModal()
  179.         dlg.Destroy()
  180.  
  181.         self.Close(True)
  182.  
  183.  
  184. class MyApp(wx.App):
  185.     def OnInit(self):
  186.         frame = MyFrame(None, -1, 'Finito Films - Create New Job')
  187.         frame.Show(True)
  188.         frame.Centre()
  189.         return True
  190.  
  191. app = MyApp(0)
  192. app.MainLoop()
  193.  
  194.  
Jun 25 '07 #1
5 3239
bartonc
6,596 Expert 4TB
Of course, The wxPython part looks fine.
Someone with Mac experience would be interested in the setup script contents.
I went to the py2app site; it's even more cryptic than the py2exe info that I've been able to gather. I'll include the link anyway: py2applet .
I don't know if a py2exe script example will be much help (finding out if p2e uses setuptools would answer some of that). There are p2e examples in the Articles section of this group.

Sorry to not be of more help.
Jun 25 '07 #2
ateale
46
:) Thanks for looking!
I haven't had any luck resolving the problem yet.

Can you recommend any other ways to create standalone python apps?

Thanks a lot!



Of course, The wxPython part looks fine.
Someone with Mac experience would be interested in the setup script contents.
I went to the py2app site; it's even more cryptic than the py2exe info that I've been able to gather. I'll include the link anyway: py2applet .
I don't know if a py2exe script example will be much help (finding out if p2e uses setuptools would answer some of that). There are p2e examples in the Articles section of this group.

Sorry to not be of more help.
Jun 25 '07 #3
bartonc
6,596 Expert 4TB
:) Thanks for looking!
I haven't had any luck resolving the problem yet.

Can you recommend any other ways to create standalone python apps?

Thanks a lot!
This is old, but looks interesting. It seems that you may have an example setup script in the distro somewhere.
Jun 25 '07 #4
bartonc
6,596 Expert 4TB
This is old, but looks interesting. It seems that you may have an example setup script in the distro somewhere.
Here is a current link.
Jun 25 '07 #5
ateale
46
thanks, that's what I had been working from to get py2app going - but I can't find anything in there to answer why my app doesn't "do its thing"

Thanks for looking around!
Jun 26 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Austin | last post: by
1 post views Thread by timothy.williams | last post: by
reply views Thread by Bob Swerdlow | last post: by
reply views Thread by Richard Taylor | last post: by
reply views Thread by Durumdara | last post: by
6 posts views Thread by zdp | last post: by
2 posts views Thread by James Stroud | last post: by
3 posts views Thread by AdamGr | last post: by
reply views Thread by Stef Mientki | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.