pyobjc-dev Mailing List for PyObjC (Page 65)
Brought to you by:
ronaldoussoren
You can subscribe to this list here.
| 2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(9) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2001 |
Jan
(1) |
Feb
(2) |
Mar
(3) |
Apr
(30) |
May
(18) |
Jun
|
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2002 |
Jan
(7) |
Feb
(2) |
Mar
(1) |
Apr
|
May
|
Jun
(3) |
Jul
(13) |
Aug
|
Sep
(23) |
Oct
(180) |
Nov
(291) |
Dec
(95) |
| 2003 |
Jan
(338) |
Feb
(352) |
Mar
(97) |
Apr
(46) |
May
(226) |
Jun
(184) |
Jul
(145) |
Aug
(141) |
Sep
(69) |
Oct
(161) |
Nov
(96) |
Dec
(90) |
| 2004 |
Jan
(66) |
Feb
(87) |
Mar
(98) |
Apr
(132) |
May
(115) |
Jun
(68) |
Jul
(150) |
Aug
(92) |
Sep
(59) |
Oct
(52) |
Nov
(17) |
Dec
(75) |
| 2005 |
Jan
(84) |
Feb
(191) |
Mar
(133) |
Apr
(114) |
May
(158) |
Jun
(185) |
Jul
(62) |
Aug
(28) |
Sep
(36) |
Oct
(88) |
Nov
(65) |
Dec
(43) |
| 2006 |
Jan
(85) |
Feb
(62) |
Mar
(92) |
Apr
(75) |
May
(68) |
Jun
(101) |
Jul
(73) |
Aug
(37) |
Sep
(91) |
Oct
(65) |
Nov
(30) |
Dec
(39) |
| 2007 |
Jan
(24) |
Feb
(28) |
Mar
(10) |
Apr
(2) |
May
(18) |
Jun
(16) |
Jul
(21) |
Aug
(6) |
Sep
(30) |
Oct
(31) |
Nov
(153) |
Dec
(31) |
| 2008 |
Jan
(63) |
Feb
(70) |
Mar
(47) |
Apr
(24) |
May
(59) |
Jun
(22) |
Jul
(12) |
Aug
(7) |
Sep
(14) |
Oct
(26) |
Nov
(5) |
Dec
(5) |
| 2009 |
Jan
(10) |
Feb
(41) |
Mar
(70) |
Apr
(88) |
May
(49) |
Jun
(62) |
Jul
(34) |
Aug
(15) |
Sep
(55) |
Oct
(40) |
Nov
(67) |
Dec
(21) |
| 2010 |
Jan
(60) |
Feb
(17) |
Mar
(26) |
Apr
(26) |
May
(29) |
Jun
(4) |
Jul
(21) |
Aug
(21) |
Sep
(10) |
Oct
(12) |
Nov
(3) |
Dec
(19) |
| 2011 |
Jan
(3) |
Feb
(13) |
Mar
(8) |
Apr
(8) |
May
(17) |
Jun
(20) |
Jul
(21) |
Aug
(7) |
Sep
|
Oct
|
Nov
(9) |
Dec
(11) |
| 2012 |
Jan
(3) |
Feb
|
Mar
|
Apr
(5) |
May
(4) |
Jun
(14) |
Jul
(5) |
Aug
(2) |
Sep
(15) |
Oct
(2) |
Nov
(23) |
Dec
(1) |
| 2013 |
Jan
(8) |
Feb
(1) |
Mar
|
Apr
|
May
(5) |
Jun
(1) |
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(12) |
Nov
(10) |
Dec
(3) |
| 2014 |
Jan
(7) |
Feb
(14) |
Mar
(2) |
Apr
|
May
(2) |
Jun
(11) |
Jul
(10) |
Aug
(4) |
Sep
|
Oct
(8) |
Nov
(1) |
Dec
(2) |
| 2015 |
Jan
(9) |
Feb
(7) |
Mar
(1) |
Apr
|
May
(7) |
Jun
|
Jul
(5) |
Aug
(6) |
Sep
|
Oct
(1) |
Nov
(4) |
Dec
|
| 2016 |
Jan
(1) |
Feb
(1) |
Mar
(4) |
Apr
(2) |
May
(1) |
Jun
|
Jul
(6) |
Aug
(8) |
Sep
(21) |
Oct
(17) |
Nov
|
Dec
(36) |
| 2017 |
Jan
(6) |
Feb
(2) |
Mar
(4) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
(6) |
| 2018 |
Jan
(2) |
Feb
(3) |
Mar
(3) |
Apr
(14) |
May
(2) |
Jun
(2) |
Jul
(4) |
Aug
(3) |
Sep
(6) |
Oct
(16) |
Nov
(1) |
Dec
(6) |
| 2019 |
Jan
(3) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
(6) |
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(2) |
Jun
(1) |
Jul
(7) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
(2) |
Dec
(1) |
| 2021 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
(5) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
| 2023 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
|
From: James R E. <ea...@cc...> - 2008-02-20 06:00:12
|
I've been using the following decorator in PyObjC 1.4 without
problems, but now PyObjC 2.0 gives me a nice DeprecationWarning. Am I
doing something naughty and/or dangerous? If so, is there a safer way
to accomplish the same thing in PyObjC2?
First, the decorator:
def trap_exceptions(func):
''' Trap exceptions and prevent them from being passed along to
the ObjC runtime. '''
def trapper(self, *args, **kwargs):
try:
return func(self, *args, **kwargs)
except:
sys.stderr.write('Exception in %s: ' % (func.__name__))
traceback.print_exception(*sys.exc_info())
return trapper
Typical usage is on an Objective-C entrypoint. e.g.:
@trap_exceptions
def performDragOperation_(self, sender):
if self.delegate is not None \
and
self.delegate.respondsToSelector_('performDragOperation:'):
return self.delegate.performDragOperation_(sender)
return False
This worked fine pre-Leopard. When an exception was thrown somewhere
in (e.g.) performDragOperation_, I'd get a stack trace on the console
and everything would carry along as if nothing happened. In PyObjC2,
the decorator appears to behave as expected, but I also get this
warning for every @trap_exceptions'ed method (at NIB load time):
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/
python/PyObjC/PyObjCTools/NibClassBuilder.py:219: DeprecationWarning:
Not all Objective-C arguments are present in the Python argument-list
of <unbound selector observeValueForKeyPath:ofObject:change:context:
of CBIconView at 0x4f1fef0>
return metaClass(name, bases, methods)
Thanks!
James
PS: Thanks for all the work you've done on PyObjC 2.0. There are
lots of wonderful improvements here! I'm very much looking forward to
the Tiger backport. :-)
--
Doctors are sadists who like to play God and watch lesser people scream
-- Bren MacGuff in "Juno"
|
|
From: John H. <joh...@gm...> - 2008-02-20 00:02:55
|
I've been following the discussions concerning the wiimote wrapper
with interest as I have this insane dream of integrating head
tracking into my laser/pySight controlled video game in order to make
it even sillier than it currently is. Alas, I have encountered
problems along the way.
Working with some people that I've found on this list and the
darwiinremote project I've got something that works somewhat for
button presses and the irPointMovedX_Y_ method. My problem is that I
want to capture the raw IR data, and this portion of the code seem to
not work.
Here is the relevant information from the most recent WiiRemote.h file:
typedef struct {
int x, y, s;
} IRData;
@interface NSObject (WiiRemoteDelegate)
- (void) rawIRData: (IRData[4]) irData;
in python I have the following:
WiiRemoteDelegate = objc.informal_protocol(
"WiiRemoteDelegate",
[
objc.selector(None,
selector="irPointMovedX:Y:",
signature="v@:ff", isRequired=False),
objc.selector(None,
selector="rawIRData:",
signature="v@:[4{IRData=iii}]", isRequired=False)
...
def rawIRData_(self, *posargs, **kwdargs):
#def rawIRData_(self, irData):
#print 'rawIRData: %s' % (irData,)
for x in posargs:
print '%x' % (x)
No matter what I do I get the same data in my delegate, formatted as
hex here:
1322f2c
13
bfffe350
1313b20
1313b00
bfffe3a0
0
154c396
94aa0ca4
142b9c8
1322ed0
13
This looks to me like I'm not getting the ints that I would expect
but that I'm getting references to the IRData struct or something.
Is there something wrong with selector and/or signature? Do I need
to add method encodings to the signature? What would a properly
encoded signature look like? If these are pointers is there a way to
dereference them in python?
I've been banging my head against this for more time than I'd like to
admit and keep getting either bus errors or junk data.
Thanks!
John
|
|
From: Ronald O. <ron...@ma...> - 2008-02-19 14:30:11
|
On 19 Feb, 2008, at 13:58, Daniel Casimiro wrote: > > On Sat, 2008-02-16 at 11:03 -0500, Olivier Fedrigo wrote: >> Can somehow tell me how to install pyObjc 2.0 from the repository? > > Which version of Mac OS X are you using? PyObjC 2.0 is part of the > standard Apple installation of Leopard (10.5.x). I don't think that > PyObjC works on anything earlier, yet. That's right. I'll probably finish the port to Tiger in the near future, but I don't have a estimate on when that will happen. If you're running on Leopard you'd be better of using Apple's install of Python and the version of PyObjC that ships with that. Ronald > > > ~Dan > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
|
From: Ronald O. <ron...@ma...> - 2008-02-19 14:28:31
|
On 19 Feb, 2008, at 10:32, James Trankelson wrote: > Hello, > > I'm trying to augment my existing ObjectiveC application with some > embedded Python. I've got an embedded Python interpreter that can run > PyObjC, but what I would like to do is the following: > > In my ObjectiveC application, I'd like to get a pointer to an object > (an NSString, for example): > > NSString *tmpStr = [NSString stringWithString:@"Test"]; > > Then, I would like to pass this NSString pointer to a Python function, > so that I can use PyObjC to operate on the object in the normal PyObjC > fashion: > > def handler(s): > print "The length of the string is ", s.length() > > I would try to call the Python handler() procedure like so: > > PyObject* arg; // tmpStr > PyObject* method; // "handler" > PyObject_CallMethodObjArgs(_self , method, arg, NULL); > > I don't know how to go about obtaining PyObject*s from the > ObjectiveC types... > > Is this even possible? That's not impossible, but not the easiest way to do this. What I'd do is to define an (abstract) baseclass in Objective-C that defines the methods you want to call, use PyObjC to create a Python subclass of that baseclass which actually implements the functionality and then call those methods using normal Objective-C method calls. That way you don't have to write code to convert data from Objective-C to Python and back. Ronald > > > Thanks. > > -jim t > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
|
From: Daniel C. <cas...@np...> - 2008-02-19 13:03:34
|
On Sat, 2008-02-16 at 11:03 -0500, Olivier Fedrigo wrote: > Can somehow tell me how to install pyObjc 2.0 from the repository? Which version of Mac OS X are you using? PyObjC 2.0 is part of the standard Apple installation of Leopard (10.5.x). I don't think that PyObjC works on anything earlier, yet. ~Dan |
|
From: James T. <tra...@gm...> - 2008-02-19 09:32:42
|
Hello,
I'm trying to augment my existing ObjectiveC application with some
embedded Python. I've got an embedded Python interpreter that can run
PyObjC, but what I would like to do is the following:
In my ObjectiveC application, I'd like to get a pointer to an object
(an NSString, for example):
NSString *tmpStr = [NSString stringWithString:@"Test"];
Then, I would like to pass this NSString pointer to a Python function,
so that I can use PyObjC to operate on the object in the normal PyObjC
fashion:
def handler(s):
print "The length of the string is ", s.length()
I would try to call the Python handler() procedure like so:
PyObject* arg; // tmpStr
PyObject* method; // "handler"
PyObject_CallMethodObjArgs(_self , method, arg, NULL);
I don't know how to go about obtaining PyObject*s from the ObjectiveC types...
Is this even possible?
Thanks.
-jim t
|
|
From: Olivier F. <ofe...@du...> - 2008-02-16 18:00:59
|
Hi bill, thanks for your email. I am still struggling with this objc error. On Jan 28, 2008, at 6:40 PM, Bill Bumgarner wrote: > On Jan 28, 2008, at 10:38 AM, Olivier Fedrigo wrote: >> have anyone resolved this problem yet? >> I experience exactly the same issue. I've tried to reinstall xCode >> after removing the older python and it did not work (but maybe I >> forgot to delete some other aliases?) >> any suggestions? > > 1. test python on command line; what is its path? ['', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ python25.zip', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/plat-darwin', '/Library/Frameworks/Python.framework/Versions/ 2.5/lib/python2.5/plat-mac', '/Library/Frameworks/Python.framework/ Versions/2.5/lib/python2.5/plat-mac/lib-scriptpackages', '/Library/ Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk', '/ Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib- dynload', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages'] > > > 2. import objc from that version; what is its path? objc is absent So I am very confused at this point. it should be there. any idea? Thanks, Olivier > > > 3. add a bit of code to your main.py before the 'import objc' that > dumps the python path > > b.bum Olivier Fedrigo, Ph.D. Biology Dpt. and Institute for Genome Sciences & Policy Duke University 4235 French Family Science Durham, NC 27708-0338 T. 919.668.7634 F. 919.660.7293 www.acpub.duke.edu/~ofedrigo/ |
|
From: Olivier F. <ofe...@du...> - 2008-02-16 16:04:37
|
Can somehow tell me how to install pyObjc 2.0 from the repository? I am a newbie so a step by step info would be great. thanks, Olivier Olivier Fedrigo, Ph.D. Biology Dpt. and Institute for Genome Sciences & Policy Duke University 4235 French Family Science Durham, NC 27708-0338 T. 919.668.7634 F. 919.660.7293 www.acpub.duke.edu/~ofedrigo/ |
|
From: Ronald O. <ron...@ma...> - 2008-02-15 21:52:14
|
On 15 Feb, 2008, at 18:18, Daniel Casimiro wrote: > > On Fri, 2008-02-15 at 14:50 +0100, Ronald Oussoren wrote: >>> Is PyOpenGL part of the Apple supported Python/PyObjC 2 >> installation >>> on >>> Leopard? >> >> Yes. > > Where does it live? Whenever I try to import "OpenGL", the interpreter > claims that no such module exists. > > I am using a system where I installed 10.5.0 onto a brand new disk. I > upgraded to 10.5.1, and now to 10.5.2. Other Apple-installed modules, > like numpy, can be imported without any problems. You're right, OpenGL isn't present on my system either. That's rather annoying... You can build PyOpenGL from source though, using the version in the PyObjC repository. Ronald |
|
From: Daniel C. <cas...@np...> - 2008-02-15 17:23:25
|
On Fri, 2008-02-15 at 14:50 +0100, Ronald Oussoren wrote: > > Is PyOpenGL part of the Apple supported Python/PyObjC 2 > installation > > on > > Leopard? > > Yes. Where does it live? Whenever I try to import "OpenGL", the interpreter claims that no such module exists. I am using a system where I installed 10.5.0 onto a brand new disk. I upgraded to 10.5.1, and now to 10.5.2. Other Apple-installed modules, like numpy, can be imported without any problems. ~Dan |
|
From: Ronald O. <ron...@ma...> - 2008-02-15 16:10:05
|
On 14 Feb, 2008, at 23:24, Daniel Casimiro wrote: > Hi, > > I am little confused about which version I should use in Leopard. > > Is PyOpenGL part of the Apple supported Python/PyObjC 2 installation > on > Leopard? Yes. > > > What is different about the PyOpenGL-2.0.2.01* hosted in the PyObjC > subversion repository? Is this version tested/supported? The version in the repository is an OSX port of PyOpenGL 2.0.2.01. I still haven't managed to push the differences upstream, IIRC they have to do with including the right headers. The actual change was pretty small, but a source-tree diff is larger because the change affects a number of generated files. Ronald |
|
From: Daniel C. <cas...@np...> - 2008-02-14 22:29:46
|
Hi, I am little confused about which version I should use in Leopard. Is PyOpenGL part of the Apple supported Python/PyObjC 2 installation on Leopard? What is different about the PyOpenGL-2.0.2.01* hosted in the PyObjC subversion repository? Is this version tested/supported? * http://svn.red-bean.com/pyobjc/trunk/pyobjc/PyOpenGL-2.0.2.01/ Thanks, ~Dan |
|
From: Ronald O. <ron...@ma...> - 2008-02-13 19:19:23
|
On 12 Feb, 2008, at 5:58, Bruce Lichtenstein wrote: > Hello, > > Since I cannot find a way around the Pyobject_call error i mentioned > before, I am attempting to build a new pyobjc site-package. I only > just realized that I get a massive number of errors during > installation, which makes me suspect that something isn't right: my > errors start here: Are you running on PPC? If so, the test_methods.py and test_methods2.py failures for "bool" arguments (such as the ones below) are expected failures. This isn't usually not a problem because Apple's frameworks don't use that type (bool is not the same type as BOOL). Ronald |
|
From: Bruce L. <lic...@gm...> - 2008-02-12 04:58:35
|
Hello,
Since I cannot find a way around the Pyobject_call error i mentioned
before, I am attempting to build a new pyobjc site-package. I only
just realized that I get a massive number of errors during
installation, which makes me suspect that something isn't right: my
errors start here:
======================================================================
FAIL: testcallboolArg (objc.test.test_methods2.ObjCToPy)
----------------------------------------------------------------------
Traceback (most recent call last):
File "build/lib.macosx-10.3-fat-2.5/objc/test/test_methods2.py",
line 22266, in testcallboolArg
self.assertEquals(r, YES)
AssertionError: False != True
======================================================================
FAIL: testinvokeBOOLAndboolArg (objc.test.test_methods2.ObjCToPy)
----------------------------------------------------------------------
Traceback (most recent call last):
File "build/lib.macosx-10.3-fat-2.5/objc/test/test_methods2.py",
line 23864, in testinvokeBOOLAndboolArg
self.assertEquals(r[1], YES)
AssertionError: False != True
======================================================================
FAIL: testinvokeNSPointAndboolArg (objc.test.test_methods2.ObjCToPy)
----------------------------------------------------------------------
Traceback (most recent call last):
File "build/lib.macosx-10.3-fat-2.5/objc/test/test_methods2.py",
line 48680, in testinvokeNSPointAndboolArg
self.assertEquals(r[1], YES)
AssertionError: False != True
....
....
....
and end here:
======================================================================
FAIL: testImplementFormalProtocol
(objc.test.test_protocol.TestFormalOCProtocols)
----------------------------------------------------------------------
Traceback (most recent call last):
File "build/lib.macosx-10.3-fat-2.5/objc/test/test_protocol.py",
line 80, in testImplementFormalProtocol
self.fail()
AssertionError
----------------------------------------------------------------------
Ran 2581 tests in 588.678s
FAILED (failures=96)
Is this normal?
Bruce
|
|
From: Bruce L. <lic...@gm...> - 2008-02-11 23:56:41
|
You see this error with Leopard due to the fact that the operating system is hard coded into python (for some reason). There is a fix at: http://jessenoller.com/2007/12/14/pyobjc-2-leopard-python-251-and-you/ Hope this helps, Bruce |
|
From: Greg E. <gre...@ca...> - 2008-02-11 23:30:45
|
Koen Bok wrote: >> src/_Authorization.c:1:2: error: #error Do not use this file, it is the >> result of a failed Pyrex compilation. I don't think this is your fault -- it looks like the package has been distributed in a broken form. You'll have to take it up with the author. -- Greg |
|
From: Koen B. <ko...@ma...> - 2008-02-11 22:51:42
|
Hey all, I was trying to install Bob's Authorization package (Authorization-0.1.tar.gz) but I ran into compiler errors. I've seen this before, but I'm not a GCC guy at all. If anyone can hint me what to look for to solve it I would be really grateful. Bye, Koen > Doerak:Authorization-0.1 koen$ python setup.py install > running install > running build > running build_py > creating build > creating build/lib.macosx-10.3-fat-2.5 > creating build/lib.macosx-10.3-fat-2.5/Authorization > copying lib/__init__.py -> build/lib.macosx-10.3-fat-2.5/Authorization > copying lib/Authorization.py -> build/lib.macosx-10.3-fat-2.5/ > Authorization > copying lib/Enumerators.py -> build/lib.macosx-10.3-fat-2.5/ > Authorization > copying lib/util.py -> build/lib.macosx-10.3-fat-2.5/Authorization > running build_ext > building 'Authorization._Authorization' extension > creating build/temp.macosx-10.3-fat-2.5 > creating build/temp.macosx-10.3-fat-2.5/src > 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 > src/_Authorization.c -o build/temp.macosx-10.3-fat-2.5/src/ > _Authorization.o > src/_Authorization.c:1:2: error: #error Do not use this file, it is > the > result of a failed Pyrex compilation. > src/_Authorization.c:1:2: error: #error Do not use this file, it is > the > result of a failed Pyrex compilation. > lipo: can't figure out the architecture type of: > /var/folders/tv/tvHCNfmDFUOXvP6jOP9nAk+++TI/-Tmp-//cc77OMaW.out > error: command 'gcc' failed with exit status 1 |
|
From: Ian B. <ian...@ya...> - 2008-02-11 15:06:13
|
I discovered the syntax error is related to "inconsistent use of tabs and spaces in indentation" but still don't know where to find the offending file. Ian Bloom |
|
From: Ronald O. <ron...@ma...> - 2008-02-11 11:13:04
|
On Monday, February 11, 2008, at 10:29AM, "Arnar Birgisson" <ar...@gm...> wrote: >Thank you Ronald, > >On Feb 11, 2008 9:11 AM, Ronald Oussoren <ron...@ma...> wrote: >> The tool for this is pyobjc-metadata in the pyobjc repository. There is little to no documentation at the moment. >> >> I have to wrap another 3th party framework in the near future, and will use that opportunity to write some documentation and push pyobjc-metadata to pypi (making it easier to install). In theory, a working wrapper is just one script invocation away, although the tool uses a regex-based parser to scan header files and that parser might be easy to confuse. > >Very good. Have you thought about using a more sophisticated parser, >perhaps based on ANTLR or similar? I have thought about it, but don't have any plans to work on that. The "clang" frontend for llvm might also be a better way to get a good parser, especially because you might be able to extract more information from the parse tree that way without compiling and running small C programs (which my current tool and Apple's tool do). > >In the meantime, I figured out the bus errors. My selectors were >wrong, I was missing the names of the parameters (which I guess in >Obj-C are part of the method name). Now I'm dealing with some >commnication errors that I'm sure are more related to the Wiimote >library than the objc-bridge. Objective-C has a non-traditional way to name methods, which it inherited from Smalltalk. A method name can contain several parts, with arguments in between the parts. A method like "-initWithFrame:(NSRect)frame andColor:(NSColor*)color" might look like a method with keyword arguments, but is actually a method with a segemented name, the entire name is initWithFrame:andColor: (including the colons), which you can access in Python as initWithFrame_andColor_ (that is, replace colons by underscores). Ronald > >thanks, >Arnar > > |
|
From: Arnar B. <ar...@gm...> - 2008-02-11 09:39:38
|
Folks,
On Feb 11, 2008 9:29 AM, Arnar Birgisson <ar...@gm...> wrote:
> In the meantime, I figured out the bus errors. My selectors were
> wrong, I was missing the names of the parameters (which I guess in
> Obj-C are part of the method name). Now I'm dealing with some
> commnication errors that I'm sure are more related to the Wiimote
> library than the objc-bridge.
I figured out the last bit. I'm posting the code here in case anyone
(in the present or the future) is trying to connect the WiiMote on
OS-X to their python app.
The code is based on an example from John Stoner.
cheers,
Arnar
import objc
objc.loadBundle("WiiRemote", globals(), bundle_path="WiiRemote.framework")
from Foundation import *
from AppKit import *
from PyObjCTools import AppHelper
IRData = objc.createStructType("IRData", "iii", ["x", "y", "s"])
WiiRemoteDiscoveryDelegate = objc.informal_protocol(
"WiiRemoteDiscoveryDelegate",
[
objc.selector(None,
selector="WiiRemoteDiscovered:",signature="v@:@",isRequired=0),
objc.selector(None, selector="WiiRemoteDiscoveryError:",
signature="v@:i",isRequired=0)
])
WiiRemoteDelegate = objc.informal_protocol(
"WiiRemoteDelegate",
[
objc.selector(None, selector="irPointMovedX:Y:wiiRemote:",
signature="v@:ff@", isRequired=False),
objc.selector(None, selector="rawIRData:wiiRemote:",
signature="v@:[4{IRData=iii}]@", isRequired=False),
objc.selector(None,
selector="buttonChanged:isPressed:wiiRemote:", signature="v@:Sc@",
isRequired=False),
objc.selector(None,
selector="accelerationChanged:accX:accY:accZ:wiiRemote:",
signature="v@:SCCC@", isRequired=False),
objc.selector(None,
selector="joyStickChanged:tiltX:tiltY:wiiRemote:",
signature="v@:SCC@", isRequired=False),
objc.selector(None,
selector="analogButtonChanged:amount:wiiRemote:", signature="v@:SI@",
isRequired=False),
objc.selector(None, selector="wiiRemoteDisconnected:",
signature="v@:@", isRequired=False),
])
wii = None
class wii_remote_discovery_delegate(NSObject):
def WiiRemoteDiscovered_(self, wiimote):
wd.stop()
global wii
wii = wiimote.retain()
print "discovered"
delegate = wii_remote_delegate.new()
wii.setDelegate_(delegate)
print "set delegate"
wii.setLEDEnabled1_enabled2_enabled3_enabled4_(True, False, True, False)
wii.setMotionSensorEnabled_(True)
def WiiRemoteDiscoveryError_(self, code):
print "not discovered, error ", code
AppHelper.stopEventLoop()
class wii_remote_delegate(NSObject):
def irPointMovedX_Y_wiiRemote_(self, px, py, wiiRemote):
print 'irPointMovedX:Y:wiiRemote:'
def rawIRData_wiiRemote_(self, irData, wiiRemote):
print 'rawIRData:wiiRemote:'
def buttonChanged_isPressed_wiiRemote_(self, type, isPressed, wiiRemote):
print 'buttonChanged:isPressed:wiiRemote:'
def accelerationChanged_accX_accY_accZ_wiiRemote_(self, type,
accX, accY, accZ, wiiRemote):
print 'accelerationChanged:accX:accY:accZ:wiiRemote:', type,
accX, accY, accZ
def joyStickChanged_tiltX_tiltY_wiiRemote_(self, type, tiltX,
tiltY, wiiRemote):
print 'joyStickChanged:tiltX:tiltY:wiiRemote:'
def analogButtonChanged_amount_wiiRemote_(self, type, press, wiiRemote):
print 'analogButtonChanged:amount:wiiRemote:'
def wiiRemoteDisconnected_(self, device):
print 'wiiRemoteDisconnected:'
wd = WiiRemoteDiscovery.new()
x = wii_remote_discovery_delegate.new()
wd.setDelegate_(x)
wd.start()
try:
AppHelper.runConsoleEventLoop(installInterrupt=True)
except KeyboardInterrupt:
print "Ctrl-C received, quitting."
AppHelper.stopEventLoop()
|
|
From: Arnar B. <ar...@gm...> - 2008-02-11 09:29:48
|
Thank you Ronald, On Feb 11, 2008 9:11 AM, Ronald Oussoren <ron...@ma...> wrote: > The tool for this is pyobjc-metadata in the pyobjc repository. There is little to no documentation at the moment. > > I have to wrap another 3th party framework in the near future, and will use that opportunity to write some documentation and push pyobjc-metadata to pypi (making it easier to install). In theory, a working wrapper is just one script invocation away, although the tool uses a regex-based parser to scan header files and that parser might be easy to confuse. Very good. Have you thought about using a more sophisticated parser, perhaps based on ANTLR or similar? In the meantime, I figured out the bus errors. My selectors were wrong, I was missing the names of the parameters (which I guess in Obj-C are part of the method name). Now I'm dealing with some commnication errors that I'm sure are more related to the Wiimote library than the objc-bridge. thanks, Arnar |
|
From: Ronald O. <ron...@ma...> - 2008-02-11 09:11:56
|
On Sunday, February 10, 2008, at 06:23PM, "Arnar Birgisson" <ar...@gm...> wrote: >One more thing, > >On Feb 10, 2008 5:10 PM, Ronald Oussoren <ron...@ma...> wrote: >> Yes to both, but that's not really necessary. Both PyObjC 1.x and >> PyObjC 2.x (shipping with Leopard) have tools to automaticly create a >> python wrapper from header files. Those are a bit tuned to the way >> Apple writes headers, but with some luck work with the WiiRemote >> headers as well. > >Where can I find these tools? I'm running Leopard (and still using the >bundled Python distribution). I'd also appreciate links to >documentation. The tool for this is pyobjc-metadata in the pyobjc repository. There is little to no documentation at the moment. I have to wrap another 3th party framework in the near future, and will use that opportunity to write some documentation and push pyobjc-metadata to pypi (making it easier to install). In theory, a working wrapper is just one script invocation away, although the tool uses a regex-based parser to scan header files and that parser might be easy to confuse. Ronald |
|
From: Ian B. <ian...@ya...> - 2008-02-10 22:55:10
|
My apologies if this is the wrong list for this type
of question.
I'm having difficulties building my first pyObjc
program in XCode. I think it may be related to
versioning,
I have python2.4
I installed pyobjc-1.3.7-py2.4-macosx10.3
I'm running Tiger 10.4.11
I get this syntax error.
/usr/bin/env
/Users/ian_m_bloom/Documents/RedTrip/setup.py py2app
--alias
running py2app
Traceback (most recent call last):
File
"/Users/ian_m_bloom/Documents/RedTrip/setup.py", line
59, in ?
setup(**setup_options)
File
"/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/distutils/core.py",
line 149, in setup
dist.run_commands()
File
"/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/distutils/dist.py",
line 946, in run_commands
self.run_command(cmd)
File
"/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/distutils/dist.py",
line 966, in run_command
cmd_obj.run()
File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/py2app/py2app/build_app.py",
line 342, in run
self.initialize_plist()
File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/py2app/py2app/build_app.py",
line 415, in initialize_plist
plist = self.get_default_plist()
File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/py2app/py2app/build_app.py",
line 294, in get_default_plist
version = find_version(target.script)
File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/py2app/py2app/util.py",
line 13, in find_version
ast = compiler.parseFile(fn)
File
"/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/compiler/transformer.py",
line 48, in parseFile
return parse(src)
File
"/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/compiler/transformer.py",
line 52, in parse
return Transformer().parsesuite(buf)
File
"/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/compiler/transformer.py",
line 129, in parsesuite
return self.transform(parser.suite(text))
File "<string>", line 628
else:
^
SyntaxError: invalid syntax
Trying to figure it out, thinking I need to recompile
some .pyc
But I'm really a newb, I don't even know where to find
File "<string>"
or how it could have a syntax error.
Many thanks,
Ian Bloom
Ian Bloom
Director of Photography
New York, NY
Office: 646.257.2462
Cell: 336.986.0663
ia...@ia...
http://www.ianbloom.com
http://www.redhax.net
|
|
From: Arnar B. <ar...@gm...> - 2008-02-10 17:23:19
|
One more thing, On Feb 10, 2008 5:10 PM, Ronald Oussoren <ron...@ma...> wrote: > Yes to both, but that's not really necessary. Both PyObjC 1.x and > PyObjC 2.x (shipping with Leopard) have tools to automaticly create a > python wrapper from header files. Those are a bit tuned to the way > Apple writes headers, but with some luck work with the WiiRemote > headers as well. Where can I find these tools? I'm running Leopard (and still using the bundled Python distribution). I'd also appreciate links to documentation. cheers, Arnar |
|
From: Arnar B. <ar...@gm...> - 2008-02-10 17:17:58
|
Hi there,
On Feb 10, 2008 5:10 PM, Ronald Oussoren <ron...@ma...> wrote:
> > Can I use it from a custom extension module (written in C)?
> > Can I write a Python extension module in Objective-C?
>
> Yes to both, but that's not really necessary. Both PyObjC 1.x and
> PyObjC 2.x (shipping with Leopard) have tools to automaticly create a
> python wrapper from header files. Those are a bit tuned to the way
> Apple writes headers, but with some luck work with the WiiRemote
> headers as well.
Thanks Ronald. I figured out how to talk with the framework and
specify delegates in C with the help of another member of this list
(John Stoner). Didn't know about this tool, will look at that.
Currently I'm dealing with "Bus errors" which I don't know if they are
my fault (i.e. incorrect specification of the informal interfaces) or
something with the WiiRemote framework. I suspect the former.
I'm pasting the code I have now below if anyone's interested.
thanks,
Arnar
import objc
objc.loadBundle("WiiRemote", globals(), bundle_path="WiiRemote.framework")
from Foundation import *
from AppKit import *
from PyObjCTools import AppHelper
wd = WiiRemoteDiscovery.new()
IRData = objc.createStructType("IRData", "iii", ["x", "y", "s"])
WiiRemoteDiscoveryDelegate = objc.informal_protocol(
"WiiRemoteDiscoveryDelegate",
[
objc.selector(None,
selector="WiiRemoteDiscovered:",signature="v@:@",isRequired=0),
objc.selector(None, selector="WiiRemoteDiscoveryError:",
signature="v@:i",isRequired=0)
])
WiiRemoteDelegate = objc.informal_protocol(
"WiiRemoteDelegate",
[
objc.selector(None, selector="irPointMovedX:",
signature="v@:ff@", isRequired=False),
objc.selector(None, selector="rawIRData:",
signature="v@:[4{IRData=iii}]@", isRequired=False),
objc.selector(None, selector="buttonChanged:",
signature="v@:Sc@", isRequired=False),
objc.selector(None, selector="accelerationChanged:",
signature="v@:SCCC@", isRequired=False),
objc.selector(None, selector="joyStickChanged:",
signature="v@:SCC@", isRequired=False),
objc.selector(None, selector="analogButtonChanged:",
signature="v@:SI@", isRequired=False),
objc.selector(None, selector="wiiRemoteDisconnected:",
signature="v@:@", isRequired=False),
])
wii = None
class wii_remote_discovery_delegate(NSObject):
def WiiRemoteDiscovered_(self, wiiRemote):
self.wiiRemote = wiiRemote
global wii
wii = wiiRemote.retain()
print "discovered"
delegate = wii_remote_delegate.new()
wii.setDelegate_(delegate)
print "set delegate"
wii.setLEDEnabled1_enabled2_enabled3_enabled4_(True, False, True, False)
#wii.setMotionSensorEnabled_(True)
def WiiRemoteDiscoveryError_(self, returnCode):
print "not discovered, error ", returnCode
AppHelper.stopEventLoop()
class wii_remote_delegate(NSObject):
def irPointMovedX_Y_wiiRemote_(self, px, py, wiiRemote):
print 'irPointMovedX:Y:wiiRemote:'
def rawIRData_wiiRemote_(self, irData, wiiRemote):
print 'rawIRData:wiiRemote:'
def buttonChanged_isPressed_wiiRemote_(self, type, isPressed, wiiRemote):
print 'buttonChanged:isPressed:wiiRemote:'
def accelerationChanged_accX_accY_accZ_wiiRemote_(self, type,
accX, accY, accZ, wiiRemote):
print 'accelerationChanged:accX:accY:accZ:wiiRemote:'
def joyStickChanged_tiltX_tiltY_wiiRemote_(self, type, tiltX,
tiltY, wiiRemote):
print 'joyStickChanged:tiltX:tiltY:wiiRemote:'
def analogButtonChanged_amount_wiiRemote_(self, type, press, wiiRemote):
print 'analogButtonChanged:amount:wiiRemote:'
def wiiRemoteDisconnected_(self, device):
print 'wiiRemoteDisconnected:'
x = wii_remote_discovery_delegate.new()
wd.setDelegate_(x)
wd.start()
try:
AppHelper.runConsoleEventLoop(installInterrupt=True)
except KeyboardInterrupt:
print "Ctrl-C received, quitting."
AppHelper.stopEventLoop()
"""
The informal interfaces from WiiRemote's headers:
@interface NSObject( WiiRemoteDiscoveryDelegate )
- (void) WiiRemoteDiscovered:(WiiRemote*)wiimote;
- (void) WiiRemoteDiscoveryError:(int)code;
@end;
@interface NSObject( WiiRemoteDelegate )
- (void) irPointMovedX:(float)px Y:(float)py wiiRemote:(WiiRemote*)wiiRemote;
- (void) rawIRData: (IRData[4])irData wiiRemote:(WiiRemote*)wiiRemote;
- (void) buttonChanged:(WiiButtonType)type isPressed:(BOOL)isPressed
wiiRemote:(WiiRemote*)wiiRemote;
- (void) accelerationChanged:(WiiAccelerationSensorType)type
accX:(unsigned char)accX accY:(unsigned char)accY accZ:(unsigned
char)accZ wiiRemote:(WiiRemote*)wiiRemote;
- (void) joyStickChanged:(WiiJoyStickType)type tiltX:(unsigned
char)tiltX tiltY:(unsigned char)tiltY wiiRemote:(WiiRemote*)wiiRemote;
- (void) analogButtonChanged:(WiiButtonType)type
amount:(unsigned)press wiiRemote:(WiiRemote*)wiiRemote;
- (void) wiiRemoteDisconnected:(IOBluetoothDevice*)device;
//- (void) dataChanged:(unsigned short)buttonData accX:(unsigned
char)accX accY:(unsigned char)accY accZ:(unsigned char)accZ
mouseX:(float)mx mouseY:(float)my;
@end
"""
|