Hi
win98, Py234, wxPy2515
I take a look at your project. If I undestand correctly, wxPRE
(wx Python Running Environment ???) is a runtime machine to run
Python scripts using wx without having Python and/or wxPython on
the user's platform. The goal is an easy deployment of wxPy
applications.
I only downloaded the script file and start testing.
1) Running wxPRE.py from the DOS prompt works fine.
python wxPRE.py application.py
2) May I suggest the .pth files may contains more than
one lines? See my version.
3) Thinks became more complicated when I created an
wxPRE.exe. wxPRE.exe -because it is frozen- does not
recognize its own path. Therefore it can not find the
.pth files. This is the main reason, why I started to
code my own test script. See my version.
4) Please add a coding info in the Pyhton script.
All users are not american.
o My test version (of course, the project is yours)
See code below. This basic version assumes only one
multiline .pth in the wxPRE directory.
o Creation of wxrun.exe
With py2exe
o Test of wxrun.exe
- In the wxrun.exe dir, I have a single .pth file
- Copy ..\site-packages\wx\*.* to c:\wx. I removed
all subdirs except \lib.
- c:\ is in my .pth file
- I renamed c:\python23 to c:\python23xxx
- Start playing with wxrun.exe from different dirs
having small.py in different test dirs.
- It works fine. (I have some problems with applications
searching for some files in their own homedir).
o small.py
A small application displaying the sys.path
o Open questions / proposals / comments
- It seems such a runtime machine is feasible.
- Should the runtime machine contains the wx part
only or also python?
- Vesioning? A runtime application for every wxPython/Python
couple version or a machine that tests Py/wxPy version.
- Ability to include/add .pth files and/or paths at the prompt.
- An application should be able to be run from the run time
machine and as a "normal way" without modifications.
- What should the distribution contain, dll, pyd, ...
Q. to Robin Dunn.
o My test scripts are below
Jean-Michel Fauth, Switzerland
#-*- coding: iso-8859-1 -*-
···
#-------------------------------------------------------------------
# wxrun.py
# win98, Py234, wxPy2515
# Jean-Michel Fauth, Switzerland
# 2 June 2004
#
# Based on the work of David Fraser and Stephen Emslie
# http://lists.wxwidgets.org/cgi-bin/ezmlm-cgi?11:mss:29180:200406:ebcedgebogcgmncmllim
#
#-------------------------------------------------------------------
import sys
import os
import os.path
#-------------------------------------------------------------------
def showsyspath(s):
r = sys.path
print '--' + s + '-------------------------'
print len(r), 'pathes'
i = 1
for e in r:
print i, ':', e
i += 1
print '-------------------------------'
#-------------------------------------------------------------------
if __name__ == '__main__':
msg = 'usage: [path]wxrun[.exe] [path]the-wx-app.py'
if len(sys.argv) > 1:
#~ showsyspath('at start'
#this is a .py script
scripttorun = os.path.abspath(sys.argv[1])
#as this file is an exe, add its path to sys.path
path = os.path.abspath(sys.argv[0])
homedir, homescript = os.path.split(path)
#~ print homedir
#~ print homescript
if homedir not in sys.path:
sys.path.append(homedir)
#check for the existence of a pth file
#for simplicity, I assume only one .pth file in the home dir,
#the wxrun.exe dir.
#however this .pth file may contain several path entries
hit = False
r = os.listdir(homedir)
for e in r:
if os.path.splitext(e)[1] == '.pth':
pthfilename = e
hit = True
#.pth file found
if hit:
#read file
pthfilename = os.path.join(homedir, pthfilename)
#~ print pthfilename
f = open(pthfilename, 'rU')
alllines = f.readlines()
f.close()
#add path to sys.path
for e in alllines:
sys.path.append(e.strip())
else:
print 'no .pth file found'
#~ showsyspath('at start'
#run the wxapp, defined as script
try:
execfile(scripttorun)
except:
print 'missing script name (.py file)'
print
print msg
print
raw_input('Press <enter> to quit')
else:
print msg
print
raw_input('Press <enter> to quit')
#eof-------------------------------------------------------------------
#-*- coding: iso-8859-1 -*-
#-------------------------------------------------------------------
# small.py
# win98, Py234, wxPy2515
# Frame + panel + différent widhgets
#-------------------------------------------------------------------
import sys
import wx
#-------------------------------------------------------------------
class MyFrame(wx.Frame):
def __init__(self, parent, id):
sty = wx.DEFAULT_FRAME_STYLE
#~ s = __file__
s = 'small'
wx.Frame.__init__(self, parent, id, s, (10, 10), (500, 500), style=sty)
self.statxt = wx.StaticText(self, 1001, 'asdf', wx.DefaultPosition, wx.DefaultSize, wx.ST_NO_AUTORESIZE)
self.statxt.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False))
self.statxt.SetBackgroundColour(wx.WHITE)
r = sys.path
r = '\n'.join(r)
self.statxt.SetLabel(r)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
def OnCloseWindow(self, event):
self.Destroy()
#-------------------------------------------------------------------
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, -1)
frame.Show(True)
self.SetTopWindow(frame)
return True
#-------------------------------------------------------------------
def main():
print 'main is running...'
app = MyApp(0)
app.MainLoop()
#-------------------------------------------------------------------
if __name__ == "__main__" :
main()
#eof-------------------------------------------------------------------