From gr281 at cam.ac.uk Fri Apr 8 15:11:12 2005 From: gr281 at cam.ac.uk (Gerhard Reitmayr) Date: Fri Apr 8 15:16:27 2005 Subject: [PythonCE] where is win32process or win32system ? Message-ID: <425682F0.4010209@cam.ac.uk> Hi, I'm using the PythonCE 2.3.4 for PPC 2203 version from sourceforge.net (http://sourceforge.net/projects/pythonce/). Now I'm trying to start iexplore.exe from a python program and found the mails on osce.py. Subsequently I managed to track down that file, but it turns out that the module win32process is missing. Similarly I found win32system in some example files on the net, which also might provide the missing CreateProcess call (???). But I couldn't find any module in the distribution or any additional dll that implement either win32process or win32system. where can I find one of these and do I have to switch to another distribution ? thanks, Gerhard Reitmayr From gr281 at cam.ac.uk Sat Apr 9 13:56:37 2005 From: gr281 at cam.ac.uk (Gerhard Reitmayr) Date: Sat Apr 9 16:58:19 2005 Subject: [PythonCE] PyWin32 compiled for Windows CE ? Message-ID: <4257C2F5.8070706@cam.ac.uk> Hi, I figured out that I need PyWin32 compiled for WinCe. Is there a compiled package somewhere that works with the PythonCE 2.3.4 for PPC 2003 version from sourceforge.net http://sourceforge.net/projects/pythonce/ ? thanks for any help, Gerhard Reitmayr From angelpeream at gmail.com Mon Apr 11 14:25:54 2005 From: angelpeream at gmail.com (Angel Perea) Date: Mon Apr 11 14:25:59 2005 Subject: [PythonCE] generating graphics in PPCs Message-ID: <7d022006050411052517246411@mail.gmail.com> I'm looking for a way of generating graphic files dinamically with PocketPython. As far as I know, there is no ported library to do so, so I'm starting to think about porting / recompiling parts of PIL (Python image library) to get my work done. * Is there any ongoing effort with any library? * Could anybody give me some advice / clue / hints / guidelines on the topic "porting python libraries to pocket pc"????? From michaelmurdock at gmail.com Tue Apr 12 22:16:06 2005 From: michaelmurdock at gmail.com (Michael Murdock) Date: Tue Apr 12 22:16:09 2005 Subject: [PythonCE] How to execute a scipt on Python startup Message-ID: Hello, I have a Python script that I import in every script that I write that imports sys and then calls sys.path.append() to set up a few locations where I keep everything on my Axim (some stuff on storage card, some in My Documents, etc.). Is there a way to have a Python script executed whenever Python starts up? Thanks, ~Michael. From mdoukidis at gmail.com Wed Apr 13 03:10:43 2005 From: mdoukidis at gmail.com (Mark Doukidis) Date: Wed Apr 13 03:10:50 2005 Subject: [PythonCE] How to execute a scipt on Python startup In-Reply-To: References: Message-ID: <8d851104050412181024bb2b87@mail.gmail.com> Try placing your code inside "sitecustomize.py". This is run every time python is started. On 4/13/05, Michael Murdock wrote: > Hello, > > I have a Python script that I import in every script that I write that > imports sys and then calls sys.path.append() to set up a few locations > where I keep everything on my Axim (some stuff on storage card, some > in My Documents, etc.). > > Is there a way to have a Python script executed whenever Python starts up? > > Thanks, > > ~Michael. > _______________________________________________ > PythonCE mailing list > PythonCE@python.org > http://mail.python.org/mailman/listinfo/pythonce > From michaelmurdock at gmail.com Wed Apr 13 20:42:07 2005 From: michaelmurdock at gmail.com (Michael Murdock) Date: Wed Apr 13 20:42:10 2005 Subject: [PythonCE] How to execute a scipt on Python startup In-Reply-To: <8d851104050412181024bb2b87@mail.gmail.com> References: <8d851104050412181024bb2b87@mail.gmail.com> Message-ID: On 4/13/05, Michael Murdock wrote: > Is there a way to have a Python script executed whenever Python starts up? On 4/12/05, Mark Doukidis wrote: >> Try placing your code inside "sitecustomize.py". >> This is run every time python is started. Thanks, Mark! This works fine. I was surprised when I found that my sitecustomize.py script imports sys but sys isn't defined when I ask about it at the python prompt, so I have to import it again. Why is that? Thanks again, ~Michael. From michaelmurdock at gmail.com Thu Apr 14 00:51:07 2005 From: michaelmurdock at gmail.com (Michael Murdock) Date: Thu Apr 14 00:51:17 2005 Subject: [PythonCE] My PythonCE Directories Message-ID: Hello, I've been playing around with PythonCE on my WinMobile 2003 Dell Axim. I have created directory structures that I have tried to render down below this message. Things seem to work fine with my scripts that use Tkinter and pysqlite and so I'm a happy camper. But I have the following questions: 1. Are my 4 directory structures a pretty standard setup? 2. Is my sitecustomize.py script the best way to set up my paths? 3. What do I have to do to move tcl8.4.3 from the root out onto my storage card? Thanks! ~Michael. --------------- #1 Python Distribution on Storage Card ------ \ | Storage Card | +- Python | +- Lib | +- python.exe | +- python23.zip | +- python23.dll, pywintypes.dll and all the other python distribution files | +- sitecustomize.py | +- site-packages (This is where I put other people's scripts that I import) | + IdleCE.py | +- sqlite ------------- #2 Tcl/Tk in Root -------------------- \ | tcl8.4.3 | +- library | +- tk8.4 ---------- #3 Various DLLs in Windows --------------- \ | Windows | +- celib.dll | +- tk8.4.dll | +- tcl8.4.dll | +- sqlite_dll.dll -------- #4 My scripts Directory ------------ \ | | My Documents | +- PyScripts | +- All my own scripts This is my sitecustomize.py file: # --------------------------------------------------- import sys sys.path = [] sys.prefix = "\\Storage Card\\Python\\Lib" sys.path = [sys.prefix, \ sys.prefix + "\\python23.zip", \ sys.prefix + "\\python23.zip\\lib-tk", \ sys.prefix + "\\site-packages", \ "\\My Documents\\PyScripts"] # ---------------------------------------------------- Side Note: If I don't manually set sys.prefix then when I fire up Python and ask for the value of sys.path: >> import sys >> sys.prefix The value returned is: '' If I do manually set sys.prefix as shown above in the sitecustomize.py, and then ask for the value of sys.path: >> import sys >> sys.prefix The value returned is: '\\Storage Card\\Python\\Lib' But I don't know if it matters much what sys.prefix is set to. From stewart.midwinter at gmail.com Thu Apr 14 01:13:42 2005 From: stewart.midwinter at gmail.com (Stewart Midwinter) Date: Thu Apr 14 01:13:45 2005 Subject: [PythonCE] My PythonCE Directories In-Reply-To: References: Message-ID: Michael, FWIW my setup is similar to yours, except I was importing a pythonrc.py module that set my paths. That was ok, except if I moved my code to the PC, I'd get an error since I didn' t have or need a pythonrc module there. I like the idea of using sitecustomize better. I too have my Tcl files in main memory, in c:\\Program Files\\tcl8.4.3, so I can't help you with moving that out to the card. S -- Stewart Midwinter stewart@midwinter.ca stewart.midwinter@gmail.com Skype: midtoad From mike at pcblokes.com Thu Apr 14 10:13:23 2005 From: mike at pcblokes.com (mike@pcblokes.com) Date: Thu Apr 14 10:14:01 2005 Subject: [PythonCE] How to execute a scipt on Python startup In-Reply-To: References: <8d851104050412181024bb2b87@mail.gmail.com> Message-ID: <1113466425.425e263904f96@www.pcblokes.com> Quoting Michael Murdock : > On 4/13/05, Michael Murdock wrote: > > Is there a way to have a Python script executed whenever Python starts > up? > > On 4/12/05, Mark Doukidis wrote: > >> Try placing your code inside "sitecustomize.py". > >> This is run every time python is started. > > Thanks, Mark! This works fine. > > I was surprised when I found that my sitecustomize.py script imports > sys but sys isn't defined when I ask about it at the python prompt, so > I have to import it again. Why is that? > You'll *probably* find that sitecustomize.py is run by being *imported*. This means that when sys is imported in ``sitecustomize.py`` a reference to the sys module is held - inside the sitecustomize namespace. The amendments you make to sys.path then affect anything else that *subsequently* uses sys.path. See if the interpreter holds a reference to ``sitecustomize``. (Can't test right now - sorry). If it *does* you'll be able to access sys through ``sitecustomize.sys`` - which is pointless, but shows you how namespaces work. Best Regards, Fuzzy http://www.voidspace.org.uk/python > Thanks again, > > ~Michael. > _______________________________________________ > PythonCE mailing list > PythonCE@python.org > http://mail.python.org/mailman/listinfo/pythonce > From brian at cococorp.com Fri Apr 22 18:52:12 2005 From: brian at cococorp.com (Brian Retford) Date: Fri Apr 22 18:52:15 2005 Subject: [PythonCE] wxPython for CE Message-ID: <308cac23b73d6623215db5bec2d5fba7@cococorp.com> It's that time again - I've made a lot of progress on reducing the footprint of my wxPython CE port, I'm working on getting the source code integrated to the mainline, here's an x-post from the wxPython dev list - any interest? Some people may remember this from many months ago, but I've ported wxPython to WinCE and we've been using it very successfully for a couple of months. There have been a lot of challenges that have come up. I'd like to get all of my changes into some form that would be useful to the community (right now it is not much more than a large collection of hacks). What would the best way to do this be? Some of my concerns: WinCE has a retarded memory architecture: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ dncenet/html/advmemmgmt.asp It wastes approx. 32kb of a 32mb virtual address space per dll loaded. Because of this and obvious memory concerns, I collapsed my wxPython back into one module, _core.pyd. The changes necessary to do so were not too hard and I think they could be integrated into the mainline (-monolithic or something). I have a verison of setup.h from wxwidgets that strips out a ton of stuff (each user might want a different set) so I modified the .i's to have #if's for most of wxwidgets features - is this something you (Robin) would be interested in integrating? Distutils - I have a totally hacked copy of distutils to support eVC instead of MSW, I'd need to get this in some better form and then? redistribute with wxpy? not sure here... I also have some binaries I'd be happy to release, but some people might find them lacking (no jpeg support (only png), missing lots of advanced wx controls (no wx html, etc)). If there's interest I'll gladly put it up somewhere. It's similar to what I released many months ago, but much reduced in footprint. Brian Retford Chief Architect Coco Communications From kimo at ollivier.co.nz Sat Apr 23 02:59:59 2005 From: kimo at ollivier.co.nz (Kim Ollivier) Date: Sat Apr 23 03:05:16 2005 Subject: [PythonCE] Python 2.3.4 for StrongARM Pocket PC 2003 Message-ID: <6.1.0.6.2.20050423125241.029fe1e0@pop3.internet.co.nz> I have downloaded this and have got some parts working. I can get IDLE to run tkinter-test and sometimes my own hello world script. I am confused about what to expect in Wince compared to Windows. I have trouble getting from IDLE to the shell and back without a long route through the settings/memory/running programs/activate. I cannot see how to get a shell without IDLE. What might be needed is an updated FAQ for beginners with a few screen shots. I have seen an old FAQ that has not been updated for a couple of years. Perhaps I could help write one. Where should it go? Can we have a "sticky" FAQ appearing. It seems that there is no support for sys.argv[], so how does one add parameters? As an exercise I thought it would be fun to port "fortune". Not much success so far. _________________________________ Kim Ollivier Ollivier & Company Corax for Cadastral Data PO Box 34 861 North Shore City kimo@ollivier.co.nz http://www.ollivier.co.nz Office +64 9 418 2220 Fax 09 480 2254 Kim 021 593 769 Jenny 025 593 769 From mike at pcblokes.com Sat Apr 23 10:29:56 2005 From: mike at pcblokes.com (Michael Foord) Date: Sat Apr 23 10:30:35 2005 Subject: [PythonCE] wxPython for CE In-Reply-To: <308cac23b73d6623215db5bec2d5fba7@cococorp.com> References: <308cac23b73d6623215db5bec2d5fba7@cococorp.com> Message-ID: <426A0784.7070904@pcblokes.com> Brian Retford wrote: > It's that time again - I've made a lot of progress on reducing the > footprint of my wxPython CE port, I'm working on getting the source > code integrated to the mainline, here's an x-post from the wxPython > dev list - any interest? > It sounds very interesting. Is it only compiled for Windows Mobile 2003, or can it be made to work for PocketPC 2002 ? Best Regards, Fuzzy http://www.voidspace.org.uk/python > Some people may remember this from many months ago, but I've ported > wxPython to WinCE and we've been using it very successfully for a > couple of months. There have been a lot of challenges that have come > up. I'd like to get all of my changes into some form that would be > useful to the community (right now it is not much more than a large > collection of hacks). What would the best way to do this be? Some of > my concerns: > > WinCE has a retarded memory architecture: > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ > dncenet/html/advmemmgmt.asp > > It wastes approx. 32kb of a 32mb virtual address space per dll > loaded. Because of this and obvious memory concerns, I collapsed my > wxPython back into one module, _core.pyd. The changes necessary to do > so were not too hard and I think they could be integrated into the > mainline (-monolithic or something). > > I have a verison of setup.h from wxwidgets that strips out a ton of > stuff (each user might want a different set) so I modified the .i's > to have #if's for most of wxwidgets features - is this something you > (Robin) would be interested in integrating? > > Distutils - I have a totally hacked copy of distutils to support eVC > instead of MSW, I'd need to get this in some better form and then? > redistribute with wxpy? not sure here... > > I also have some binaries I'd be happy to release, but some people > might find them lacking (no jpeg support (only png), missing lots of > advanced wx controls (no wx html, etc)). If there's interest I'll > gladly put it up somewhere. It's similar to what I released many > months ago, but much reduced in footprint. > > Brian Retford > Chief Architect > Coco Communications > > _______________________________________________ > PythonCE mailing list > PythonCE@python.org > http://mail.python.org/mailman/listinfo/pythonce > > > From mike at pcblokes.com Sat Apr 23 10:39:32 2005 From: mike at pcblokes.com (Michael Foord) Date: Sat Apr 23 10:40:16 2005 Subject: [PythonCE] Python 2.3.4 for StrongARM Pocket PC 2003 In-Reply-To: <6.1.0.6.2.20050423125241.029fe1e0@pop3.internet.co.nz> References: <6.1.0.6.2.20050423125241.029fe1e0@pop3.internet.co.nz> Message-ID: <426A09C4.8000603@pcblokes.com> Kim Ollivier wrote: >I have downloaded this and have got some parts working. I can get IDLE to run tkinter-test and sometimes my own hello world script. > >I am confused about what to expect in Wince compared to Windows. I have trouble getting from IDLE to the shell and back without a long route through the settings/memory/running programs/activate. I cannot see how to get a shell without IDLE. > > If you're having to use `settings/memory/running programs/activate` to swap the active screen, you probably need a utility like 'PocketNav' to make it easier. The IDLE for pocketpc is a bit different from the 'normal IDLE' - and is developed separately from the actual port of python for windows ce. If you just run `python.exe`, you should get a python shell. >What might be needed is an updated FAQ for beginners with a few screen shots. I have seen an old FAQ that has not been updated for a couple of years. >Perhaps I could help write one. Where should it go? Can we have a "sticky" FAQ appearing. > > > What do you mean by 'sticky FAQ' - I've not heard that term before ? >It seems that there is no support for sys.argv[], so how does one add parameters? As an exercise I thought it would be fun to port "fortune". >Not much success so far. > > > Rats.. I can't help on this at the minute. My memory card broke and I'm waiting for the supplier to replace it. I didn't realise that sys.argv didn't work - but then I've never tried to use it on my PDA :-) Best Regards, Fuzzy http://www.voidspace.org.uk/python >_________________________________ >Kim Ollivier Ollivier & Company >Corax for Cadastral Data PO Box 34 861 > North Shore City >kimo@ollivier.co.nz http://www.ollivier.co.nz >Office +64 9 418 2220 Fax 09 480 2254 >Kim 021 593 769 Jenny 025 593 769 > > >_______________________________________________ >PythonCE mailing list >PythonCE@python.org >http://mail.python.org/mailman/listinfo/pythonce > > > > > From orionrobots at gmail.com Sun Apr 24 13:56:18 2005 From: orionrobots at gmail.com (danny staple) Date: Sun Apr 24 13:56:21 2005 Subject: [PythonCE] wxPython for CE In-Reply-To: <308cac23b73d6623215db5bec2d5fba7@cococorp.com> References: <308cac23b73d6623215db5bec2d5fba7@cococorp.com> Message-ID: <3ec53b3f050424045627eec758@mail.gmail.com> I am most definately interested. I tried to get this to run some time ago, and my PocketPC just didnt seem to have the memory to cope with it - so I would love to try it again. And yes - I do agree Windows CE has a retarded memory architecture. While I appretiate the raw processing power I have in my PDA rivals a 5 year old desktop, the OS on these things is really backwards - i hate it, but then bear in mind it was designed for storing phone numbers... I really appretiate the opportunity to use Python to get some interesting stuff running on it. My fear now is that one python and wx are loaded - it does not leave alot of memory for the apps to run in it. I have been working on a rather complex multi-platform python app, which I would like to see running on my PocketPC. Danny -- http://orionrobots.co.uk - Build Robots On 4/22/05, Brian Retford wrote: > It's that time again - I've made a lot of progress on reducing the > footprint of my wxPython CE port, I'm working on getting the source > code integrated to the mainline, here's an x-post from the wxPython dev > list - any interest? > > Some people may remember this from many months ago, but I've ported > wxPython to WinCE and we've been using it very successfully for a > couple of months. There have been a lot of challenges that have come > up. I'd like to get all of my changes into some form that would be > useful to the community (right now it is not much more than a large > collection of hacks). What would the best way to do this be? Some of my > concerns: > > WinCE has a retarded memory architecture: > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ > dncenet/html/advmemmgmt.asp > > It wastes approx. 32kb of a 32mb virtual address space per dll loaded. > Because of this and obvious memory concerns, I collapsed my wxPython > back into one module, _core.pyd. The changes necessary to do so were > not too hard and I think they could be integrated into the mainline > (-monolithic or something). > > I have a verison of setup.h from wxwidgets that strips out a ton of > stuff (each user might want a different set) so I modified the .i's to > have #if's for most of wxwidgets features - is this something you > (Robin) would be interested in integrating? > > Distutils - I have a totally hacked copy of distutils to support eVC > instead of MSW, I'd need to get this in some better form and then? > redistribute with wxpy? not sure here... > > I also have some binaries I'd be happy to release, but some people > might find them lacking (no jpeg support (only png), missing lots of > advanced wx controls (no wx html, etc)). If there's interest I'll > gladly put it up somewhere. It's similar to what I released many months > ago, but much reduced in footprint. > > Brian Retford > Chief Architect > Coco Communications > > _______________________________________________ > PythonCE mailing list > PythonCE@python.org > http://mail.python.org/mailman/listinfo/pythonce From james.burkert at gmail.com Mon Apr 25 05:23:39 2005 From: james.burkert at gmail.com (James Burkert) Date: Mon Apr 25 05:23:44 2005 Subject: [PythonCE] Performance of Linux OS vs WinCE In-Reply-To: <3ec53b3f050424045627eec758@mail.gmail.com> References: <308cac23b73d6623215db5bec2d5fba7@cococorp.com> <3ec53b3f050424045627eec758@mail.gmail.com> Message-ID: <42aeae22050424202319fb5542@mail.gmail.com> Hey everyone, I've got a somewhat memory-intensive app in Python, and I'm trying to figure out if linux or WinCE would be speedier on my iPAQ 2200, any thoughts? James From kimo at ollivier.co.nz Mon Apr 25 14:25:40 2005 From: kimo at ollivier.co.nz (Kim Ollivier) Date: Mon Apr 25 14:30:49 2005 Subject: [PythonCE] WinCE environment for Python? Message-ID: <6.1.0.6.2.20050425234245.02a3e4c8@pop3.internet.co.nz> I would like some help in what I should have after installing Python and IdleCE. I do not know if I should be setting more defaults. Some of my problems may just be me not understanding the limits of Pocket PC 2003 so I apologise if I really need a training course on "WinCE Disappointments". Just in case I miss some detail I have put Python 2.3.4 on an IPAQ 3970 which has been upgraded to Pocket PC 2003. ... and just reloaded after I let the battery expire and I found that the backup did not have "save exe files" checked. I have IdleCE 0.7 working well, complete with a little shortcut from the Windows Wave. It will import a script and run it once, but then I'm in trouble because if I want to view the output, I lose the Idle screen. The output looks like an interactive shell. (>>> appears) and I can type into it, but it will not execute. Perhaps this is really the py-stdout file I see has appeared in My Device. A python shell does indeed appear if I double click on python.exe. I have tweaked the registry with the excellent Pocket Tweak to make this happen, after running Setup-Registry and putting the files on my storage card. I then copied Python/Lib to Program files. Once this shell is running, then Idle will not open, I just get the shell active. I would like to know how to add a shortcut to Programs so that I did not have to mess around with "File Explorer". Cannot find any help for this. I did find that you can add a simple html file for a program that gets opened when the program is running. That would be a good place to put a readme note. On my sys.argv[] problem. I cannot see how to add any user input to a script, only on a filetype double click for a program. Not applicable to a script. Do I have to use tkinter? The tkinter-test works just fine from Idle. Hurray, well done. But I have other exercises that are simpler that just take a single parameter. eg DayofWeek: enter a date and print the day. There are some other auto-tests that I get no response from. _________________________________ Kim Ollivier Ollivier & Company Corax for Cadastral Data PO Box 34 861 North Shore City kimo@ollivier.co.nz http://www.ollivier.co.nz Office +64 9 418 2220 Fax 09 480 2254 Kim 021 593 769 Jenny 025 593 769 From mike at pcblokes.com Mon Apr 25 15:02:47 2005 From: mike at pcblokes.com (Michael Foord) Date: Mon Apr 25 15:03:42 2005 Subject: [PythonCE] WinCE environment for Python? In-Reply-To: <6.1.0.6.2.20050425234245.02a3e4c8@pop3.internet.co.nz> References: <6.1.0.6.2.20050425234245.02a3e4c8@pop3.internet.co.nz> Message-ID: <426CEA77.4000505@pcblokes.com> A very quick and partial response Kim, Yes - Tkinter is the only reliable way of getting user input on PythonCE. There are floating around some old routines that mimic stdin, they probably *could* be used to make a ``raw_input`` work.. but I don't think anyone has done the work on this. Best Regards, Fuzzy http://www.voidspace.org.uk/python Kim Ollivier wrote: >I would like some help in what I should have after installing Python and IdleCE. >I do not know if I should be setting more defaults. Some of my problems may >just be me not understanding the limits of Pocket PC 2003 so I apologise if I >really need a training course on "WinCE Disappointments". >Just in case I miss some detail I have put Python 2.3.4 on an IPAQ 3970 which has been upgraded to Pocket PC 2003. ... and just reloaded after I let the battery expire and I found that the backup did not have "save exe files" checked. > > >I have IdleCE 0.7 working well, complete with a little shortcut from the Windows Wave. It will import a script and run it once, but then I'm in trouble because if I want to view the output, I lose the Idle screen. The output looks like an interactive shell. (>>> appears) and I can type into it, but it will not execute. Perhaps this is really the py-stdout file I see has appeared in My Device. > >A python shell does indeed appear if I double click on python.exe. I have tweaked the registry with the excellent Pocket Tweak to make this happen, >after running Setup-Registry and putting the files on my storage card. I then >copied Python/Lib to Program files. >Once this shell is running, then Idle will not open, I just get the shell active. >I would like to know how to add a shortcut to Programs so that I did not have to >mess around with "File Explorer". Cannot find any help for this. I did find that you can add a simple html file for a program that gets opened when the program is running. That would be a good place to put a readme note. > >On my sys.argv[] problem. I cannot see how to add any user input to a script, only on a filetype double click for a program. Not applicable to a script. Do I have to use tkinter? The tkinter-test works just fine from Idle. Hurray, well done. But I have other exercises that are simpler that just take a single parameter. eg DayofWeek: enter a date and print the day. > >There are some other auto-tests that I get no response from. > > >_________________________________ >Kim Ollivier Ollivier & Company >Corax for Cadastral Data PO Box 34 861 > North Shore City >kimo@ollivier.co.nz http://www.ollivier.co.nz >Office +64 9 418 2220 Fax 09 480 2254 >Kim 021 593 769 Jenny 025 593 769 > > >_______________________________________________ >PythonCE mailing list >PythonCE@python.org >http://mail.python.org/mailman/listinfo/pythonce > > > > > From michaelmurdock at gmail.com Mon Apr 25 22:24:26 2005 From: michaelmurdock at gmail.com (Michael Murdock) Date: Mon Apr 25 22:24:28 2005 Subject: [PythonCE] Re: PythonCE Digest, Vol 21, Issue 6 In-Reply-To: <20050423100048.32FF41E400E@bag.python.org> References: <20050423100048.32FF41E400E@bag.python.org> Message-ID: >It seems that there is no support for sys.argv[], so how does one add parameters? Somewhat related to your question, this is a really lame class that I use. It's (over) documented below. But basically if you're writing a program that requires passed-in arguments and you want to run it by double-clicking on it (as opposed to running it from the command line), then import this class and declare an instance of it. It will pop up a Tkinter Entry box asking for your args. One of the instance's methods returns a list of typed-in strings, the other method returns one of the typed-in arguments but converts it to an integer or float, if necessary. Like I said, It's pretty lame. But I use it a lot on my Axim. ~Michael. # --------------------------------------------------------------------------- # cmdline.py # Michael Murdock # # This code uses Tkinter's Entry box, so it imports Tkinter. # # Public Methods: # # GetArgs() - Returns a list of strings. Each string is one of the args. # GetArg(idx) - Returns the specified argument. # # Here's how I use this code: # # 1. I import this code into my PyCE app that requires passed-in # command line arguments. # # 2. At or near the start of my program's main() I create an # instance of the ccmdline class and pass into the class constructor # my program's usage string: # # cLine = ccmdline("filename numItems verboseFlag") # # 3. When this line of code is executed, a modal dialog box is displayed # asking for your program's arguments. When you enter the arguments and # press the 'OK' button, the dialog box will go away and the next line # in your program after the constructor will proceed with execution. # # 4. I then use one of this class's public methods, GetArgs(), which # returns a list with the first list element containing the program # name and the subsequent elements containing the white-space-delimited # words that were typed in the Entry box. Note that each item in this # list is a string. Example: # # cLineList = cLine.GetArgs() # # 5. Alternatively, I can use the other public method, GetArg, # specifiying a zero-based index, to request one of the typed-in # command line arguments. # # progName = cLine.GetArg(0) # firstArg = cLine.GetArg(1) # # However, the list element returned from GetArg is different from what # is returned with GetArgs. If the requested item is an integer (according # to the String method isdigit()), then that string is converted to an # integer before it is returned. If the requested item is a float (according # to my own private method), then that string is converted to a float before # it is returned. # # --------------------------------------------------------------------------- from Tkinter import * import os # -------------------------------------------------------------------------- # ccmdline - # A program creates an instance of this class (which uses a Tkinter Entry # box) if it wants to elicit its command line arguments from the program's # user. # # When the program calls this class's constructor, a modal dialog box is # created and displayed until the user presses the OK button. # # I use an underscore before a variable name as a notational reminder # to help me remember which members are private. # -------------------------------------------------------------------------- class ccmdline: def __init__(self, UsageString): self._root = Tk() self._progName = os.path.basename(sys.argv[0]) self._root.title(self._progName) self._frame = Frame(self._root) self._frame.pack() self._label = Label(self._frame,text=UsageString) self._label.pack() self._entry = Entry(self._frame) self._entry.pack() self._button = Button(self._frame,text="OK",fg="red",command=self._SaveText) self._button.pack() self._root.mainloop() # ------------------------------------------------------- # GetArgs - Public Method. # Called by client to get the argument list, including # calling program, which is zeroth item in list. # ------------------------------------------------------- def GetArgs(self): return self._args # --------------------------------------------------------- # GetArg - Public Method. # Called by client with a 0-based index to get one of the # typed-in command line arguments. If the item is an int, # it is converted from a string to an integer. Ditto with # a type-in floating point number. # --------------------------------------------------------- def GetArg(self,elementIdx): # Is this arg an integer? if self._args[elementIdx].isdigit(): self._args[elementIdx] = int(self._args[elementIdx]) # Is this arg a floating point? elif self._IsFloat(self._args[elementIdx]): self._args[elementIdx] = float(self._args[elementIdx]) return self._args[elementIdx] # -------------------------------------------------------- # _SaveText - Private Method. # Called when user presses the OK button to save the # user-typed text string into private list, _args. # -------------------------------------------------------- def _SaveText(self): self._args = self._entry.get().split() self._args.insert(0,self._progName) self._root.destroy() # -------------------------------------------------------- # _IsFloat - Private Method. # Used as part of process of converting a typed-in float # from a string to a floating point number. # -------------------------------------------------------- def _IsFloat(self, str): answer = False try: float(str) answer = True finally: return answer From isrgish at fastem.com Tue Apr 26 17:05:16 2005 From: isrgish at fastem.com (Isr Gish) Date: Tue Apr 26 17:04:22 2005 Subject: [PythonCE] Python 2.3.4 for StrongARM Pocket PC 2003 Message-ID: <20050426150421.D9AD21E4002@bag.python.org> Michael Foord wrote >Kim Ollivier wrote: >>It seems that there is no support for sys.argv[], so how does one add parameters? As an exercise I thought it would be fun to port "fortune". >>Not much success so far. >> >> >> >Rats.. I can't help on this at the minute. My memory card broke and I'm >waiting for the supplier to replace it. I didn't realise that sys.argv >didn't work - but then I've never tried to use it on my PDA :-) As far as I know it works. But you may need to setup the registry for it This is how its setup on my device (You would have to subbsitute your python path) HKEY_CLASSES_ROOT\.py "Default"="PySource" HKEY_CLASSES_ROOT\.pyc "Default"="PySource" HKEY_CLASSES_ROOT\PySource\DefaultIcon "Default"="\\Storage_Card\\Misc\\Programing\\Python\\lib\\python.exe, 0" HKEY_CLASSES_ROOT\PySource\shell\open\command "Default"="\"\\Storage_Card\\Misc\\Programing\\Python\\lib\\python.exe\" \"%1\" %*" All the best, Isr