Re: [Pythonmac-SIG] pragma mark with python in xcode?

2008-08-12 Thread Mike Covill


On 11-Aug-08, at 11:10 AM, Daniel Ashbrook wrote:


Nehemiah Dacres wrote:
> What are u using a #pragma for in python? You See that POUND sign  
your
using, thats a COMPILER DIRECTIVE, python is an interpreted  
scripting language, no PREPROCESSING allowed , (except for the .pyc  
code but thats compiled if you want to get technical with me)

Am I misinterpreting you intentions?


Yes.

Xcode supports "#pragma mark foo" that puts "foo" into a dropdown  
menu above your code in the editor so you can quickly jump between  
sections.



dan



From Apple's "Xcode Workspace Guide:, chapter 6, section 2:

http://developer.apple.com/documentation/DeveloperTools/Conceptual/XcodeWorkspace/600-The_Text_Editor/chapter_6_section_2.html

you can use these inside a comment and the drop down will display them  
in bold, like the #pragma mark does in C code:


MARK:
TODO:
FIXME:
!!!:
???:

You can use "MARK:" just like you use "#pragma mark" in C code, and it  
("MARK:") will not show up in the drop down, just the comment  
following it.  The others will be included in the drop down item.


#MARK: Section 1
  displays as:   "Section 1"

#!!!: Look at this now!
  displays as:   "!!! Look at this now"

Mike

___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Yet another problem with path

2008-08-07 Thread Mike Covill


On 7-Aug-08, at 9:45 AM, Mike Covill wrote:


On 7-Aug-08, at 9:34 AM, Pascal Bompard wrote:

Returning to this 3 week old chestnut, (apologies for delay - my  
second child was born in the interim), and thanks to all who  
attempted to help, but I am still struggling with this issue.



Christopher Barker wrote:
If you have scripts you want to run from anywhere, make them  
executable:


This is exactly what I need to occur with this particular script


chmod a+x MyScript.py


permissions are set to 755 (i.e. full permissions)


and put:  #!usr/bin/env python   at the top.


yes, that is in place


Then either:

put them in a standard place that should be on your PATH, like:

/usr/local/bin

or put the path to your scripts in your PATH -- often people use:

~/bin


I actually have this in my PATH,
/Users/pascal/Documents/Python/Dev/myapp

and with all the above I get:

Administrator:~ pascal$ python test.py
/System/Library/Frameworks/Python.framework/Versions/2.5/Resources/ 
Python.app/Contents/MacOS/Python: can't open file 'test.py': [Errno  
2] No such file or directory


whereas calling the script from within it's parent directory does  
work.


What could I possibly be doing wrong here?


Your PATH is only used to find the executable (python), not the  
document (test.py).  The document must include either the relative  
path from where you are, or the absolute path.


You should be able to execute your script by typing just your script  
name from anywhere, leave out "python":


Administrator:~ pascal$ test.py

in this case test.py is the 'executable', and your system will look  
for it using your PATH setting.


Mike






do buy a book or surf the web for info about using the terminal on  
OS-X -- it's a great skill to have.


You're right. I have recently acquired a great book called "From  
Bash to Z-Shell", but it's tough to retain all the tricks when I  
use the terminal so seldom.





-Chris

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

[EMAIL PROTECTED]
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Yet another problem with path

2008-08-07 Thread Mike Covill

On 7-Aug-08, at 9:34 AM, Pascal Bompard wrote:

Returning to this 3 week old chestnut, (apologies for delay - my  
second child was born in the interim), and thanks to all who  
attempted to help, but I am still struggling with this issue.



Christopher Barker wrote:
If you have scripts you want to run from anywhere, make them  
executable:


This is exactly what I need to occur with this particular script


chmod a+x MyScript.py


permissions are set to 755 (i.e. full permissions)


and put:  #!usr/bin/env python   at the top.


yes, that is in place


Then either:

put them in a standard place that should be on your PATH, like:

/usr/local/bin

or put the path to your scripts in your PATH -- often people use:

~/bin


I actually have this in my PATH,
/Users/pascal/Documents/Python/Dev/myapp

and with all the above I get:

Administrator:~ pascal$ python test.py
/System/Library/Frameworks/Python.framework/Versions/2.5/Resources/ 
Python.app/Contents/MacOS/Python: can't open file 'test.py': [Errno  
2] No such file or directory


whereas calling the script from within it's parent directory does  
work.


What could I possibly be doing wrong here?


Your PATH is only used to find the executable (python), not the  
document (test.py).  The document must include either the relative  
path from where you are, or the absolute path.


Mike




do buy a book or surf the web for info about using the terminal on  
OS-X -- it's a great skill to have.


You're right. I have recently acquired a great book called "From  
Bash to Z-Shell", but it's tough to retain all the tricks when I use  
the terminal so seldom.





-Chris

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

[EMAIL PROTECTED]
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] py2app- python code packed in clear ascii

2008-08-05 Thread Mike Covill

the shelter,

The last time I built an app bundle, the only source file from my code  
in plain ascii was my main.py file.  Everything else was precompiled  
and zipped up in a sub-folder.  So the strategy to hide all source  
code was to create a main.py file which simply imports another file  
containing what used to be in the main.py file, and run it from there.


Here are some py2app resources I found useful:

http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html
http://undefined.org/python/py2app.html

Mike


On 4-Aug-08, at 12:45 PM, the Shelter wrote:


Hi,

after a lot of python programming on linux and windows I have now  
taken up the task of converting/ adapting my apps (python/wxPython)  
to the mac.
I tried to bundle my apps w/ py2app but had to find out that it  
seems like it packs my sources in clear ascii and not in binary  
form- somewhat unusual after having worked w/ py2exe ...


Am I missing something?

Right now I am on 10.4 w/ latest python and py2app- all from  
python.org- not the Apple versions.


thanX



___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] [py2app] problems running .app built on 10.5 on standard 10.4

2008-07-31 Thread Mike Covill

On 31-Jul-08, at 12:33 PM, Christopher Barker wrote:


Mike Keith wrote:

are my problems down to the fact that i'm using apple's python 2.5 to
build the .app?


yes.


if so, any advice on how to proceed?


Install the python.org python ,and use that to built your app -- it  
should then run on all systems >= 10.3.9


-Chris




Corollary to installing python.org python (currently 2.5.2, I  
believe), how can I install and use the PyObjC version 2.0 for Leopard  
packages?  I have tried downloading the subversion copy of PyObjC at "http://svn.red-bean.com/pyobjc/trunk 
" and the script inside pyobjc fails (02-develop-all.sh).  Is this  
script working for everyone else?


Any hints would be appreciated, thanks.

Mike


___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] Trouble installing PyObjC 2.0 from source

2008-07-19 Thread Mike Covill
Can anyone give me some pointers on installing PyObjC 2.0 from  
source?  I have a fresh installation on my MacBookPro with Leopard  
10.5.4 of Python 2.5.2 in /Library/... , and nothing else.  I checked  
out the PyObjC source at "http://svn.red-bean.com/pyobjc/trunk"; and  
ran the "02-develop-all.sh" shell program in pyobjc/.  I got lots of  
errors, some of which were fixed by reverting back to svn 1.4.4.  But  
I am still getting errors like those shown below (first and last  
error).  My litmus test to see if installation was successful is to  
run python and try to import Foundation or objc in a new shell.


First error:
gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk - 
fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd  
-fno-common -dynamic -DNDEBUG -g -O3 -I/Library/Frameworks/ 
Python.framework/Versions/2.5/include/python2.5 -c Modules/objc/ 
bundle-variables.m -o build/temp.macosx-10.3-i386-2.5/Modules/objc/ 
bundle-variables.o -DPyObjC_STRICT_DEBUGGING -DMACOSX -no-cpp- 
precomp -Wno-long-double -g -fexceptions -O1 -Wall -Wstrict- 
prototypes -Wmissing-prototypes -Wformat=2 -W -Wshadow -Wpointer- 
arith -Wmissing-declarations -Wnested-externs -Wno-long-long -Wno- 
import -I/usr/include/libxml2 -Ibuild/codegen/ -Ilibffi-src/include - 
Ilibffi-src/powerpc
Modules/objc/bundle-variables.m: In function  
‘PyObjC_loadBundleFunctions’:
Modules/objc/bundle-variables.m:221: error: ‘_localHandler’  
undeclared (first use in this function)
Modules/objc/bundle-variables.m:221: error: (Each undeclared  
identifier is reported only once
Modules/objc/bundle-variables.m:221: error: for each function it  
appears in.)
Modules/objc/bundle-variables.m: In function  
‘PyObjC_loadBundleFunctions’:
Modules/objc/bundle-variables.m:221: error: ‘_localHandler’  
undeclared (first use in this function)
Modules/objc/bundle-variables.m:221: error: (Each undeclared  
identifier is reported only once
Modules/objc/bundle-variables.m:221: error: for each function it  
appears in.)
lipo: can't figure out the architecture type of: /var/tmp// 
ccehSa3x.out

error: command 'gcc' failed with exit status 1


... 24000 lines ...

Last error:

running develop
running egg_info
creating Lib/pyobjc_framework_XgridFoundation.egg-info
writing requirements to Lib/pyobjc_framework_XgridFoundation.egg- 
info/requires.txt

writing Lib/pyobjc_framework_XgridFoundation.egg-info/PKG-INFO
writing top-level names to Lib/pyobjc_framework_XgridFoundation.egg- 
info/top_level.txt
writing dependency_links to Lib/pyobjc_framework_XgridFoundation.egg- 
info/dependency_links.txt
writing manifest file 'Lib/pyobjc_framework_XgridFoundation.egg-info/ 
SOURCES.txt'
writing manifest file 'Lib/pyobjc_framework_XgridFoundation.egg-info/ 
SOURCES.txt'

running build_ext
Creating /Library/Frameworks/Python.framework/Versions/2.5/lib/ 
python2.5/site-packages/pyobjc-framework-XgridFoundation.egg-link  
(link to Lib)

Adding pyobjc-framework-XgridFoundation 2.0 to easy-install.pth file

Installed /Users/mcovill/projects/pyobjc/pyobjc/pyobjc-framework- 
XgridFoundation/Lib

Processing dependencies for pyobjc-framework-XgridFoundation==2.0
Searching for pyobjc-framework-Cocoa>=2.0
Reading http://pypi.python.org/simple/pyobjc-framework-Cocoa/
Couldn't find index page for 'pyobjc-framework-Cocoa' (maybe  
misspelled?)

Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
No local packages or download links found for pyobjc-framework- 
Cocoa>=2.0
error: Could not find suitable distribution for  
Requirement.parse('pyobjc-framework-Cocoa>=2.0')


Thanks,
Mike Covill


___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] NSDistributedNotificationCenter

2007-11-09 Thread Mike Covill
On 2007-Nov-09, at 00:32, Ronald Oussoren wrote:

>
> On 8 Nov, 2007, at 20:55, Mike Covill wrote:
>
>> I wanted to try using the NSDistributedNotificationCenter to pass
>> messages between two separate python programs running simultaneously,
>> so to learn about doing this I created this class:
>>
>> FILE: listener.py
>> - 
>> ---
>> -
>> import Foundation
>>
>> class GetNotes(object):
>>
>> def __init__(self):
>> '''register for an NSNotification'''
>> nc =  
>> Foundation.NSDistributedNotificationCenter.defaultCenter()
>> nc.addObserver_selector_name_object_(self, 'getMyNotes:',
>> 'myNote', None)
>>
>> def getMyNotes_(self, note):
>> print 'got a note!:', note.object
>> - 
>> ---
>> -
>>
>> then I created an instance of this class and tried sending a
>> notification via the command line, expecting to see a print statement
>> that the notification was received:
>>
>> import Foundation as F
>> import listener
>> gn = listener.GetNotes()
>> nc = F.NSDistributedNotificationCenter.defaultCenter()
>> nc.postNotificationName_object_('myNote', None)
>>
>> So far, no such luck.  Any suggestions?
>
> The delivery of notifications uses the runloop, it is basically  
> just another source of events.
>
> In a command-line tool you'll have to run the loop yourself,  
> something like:
>
>   loop = F.NSRunLoop.currentRunLoop()
>   loop.run()
>
> (That last call will run the eventloop and therefore "block" your  
> script. It will also cause the notification to be delivered).
>
> Ronald
>

Works great.  Thanks Ronald.

Mike


>> Thanks,
>> Mike
>> ___
>> Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
>> http://mail.python.org/mailman/listinfo/pythonmac-sig
>
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] NSDistributedNotificationCenter

2007-11-08 Thread Mike Covill
I wanted to try using the NSDistributedNotificationCenter to pass  
messages between two separate python programs running simultaneously,  
so to learn about doing this I created this class:

FILE: listener.py
 
-
import Foundation

class GetNotes(object):

 def __init__(self):
 '''register for an NSNotification'''
 nc = Foundation.NSDistributedNotificationCenter.defaultCenter()
 nc.addObserver_selector_name_object_(self, 'getMyNotes:',  
'myNote', None)

 def getMyNotes_(self, note):
 print 'got a note!:', note.object
 
-

then I created an instance of this class and tried sending a  
notification via the command line, expecting to see a print statement  
that the notification was received:

import Foundation as F
import listener
gn = listener.GetNotes()
nc = F.NSDistributedNotificationCenter.defaultCenter()
nc.postNotificationName_object_('myNote', None)

So far, no such luck.  Any suggestions?

Thanks,
Mike
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] Launching a python app with an associated document

2006-06-30 Thread Mike Covill
Does anyone have experience creating a pure python app (no Cocoa integration) which is associated with a document extension?We would like to be able to launch our application by double-clicking an associated document (associated using CFBundleDocumentTypes in the info.plist) and having the data in the document loaded into the python app.  I have added the following code to our setup.py file:plist = dict(    CFBundleDocumentTypes = [        dict(            CFBundleTypeExtensions=["madf",],            CFBundleTypeName="myApp Data File",            CFBundleTypeRole="Editor",            CFBundleTypeIconFile='myAppDocument.icns',        ),    ])py2app_options = dict(...,                      plist=plist,                     )the application now launches when we double-click on the document, but I have yet to find how we might feed the contents of the document to an appropriate reader function inside our app.  We had a look at the sys.argv list passed in to main.py thinking the name of the document might be in there but this doesn't seem to be the case.  We also checked os.environ.Thanks for any help or pointers to relevant info,Mike___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] Building apps with hardcoded options using py2app

2006-04-17 Thread Mike Covill
I would like to package up different versions of our application  
which we normally specify on the command line with different command  
line options.  For
example:
myapp.py
or
myapp.py -sim

Can I use py2app to make different 'double-clickable' applications  
that would give us the same functionality?  If so, how?  Where would  
I specify the options?

Or should I make different versions of my main.py file for each  
configuration.

Thanks,
Mike

___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] 50-un_commentLines.py

2006-03-07 Thread Mike Covill
Does anyone know what happened to or have a copy of
50-un_commentLines.py ('A Python version of the Apple-provided "Un-Comment" 
script to be Python-aware.')

referenced on:
http://pythonmac.org/wiki/XcodeIntegration ?

When I click on the link I just get the message:
"No attachments stored for XcodeIntegration"

Thanks, 
Mike Covill

___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig