pyobjc-dev Mailing List for PyObjC (Page 55)
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: Nico W. <nic...@gm...> - 2009-02-01 04:00:46
|
Hi, I want to load a font from a ttf file and then draw some text using this font, and I want to do that in Python using the PyObjC bridge. My program already does some drawing; it uses NSBitmapImageReps and NSGraphicsContext for that. The font I'm trying to load is http://damieng.com/blog/2008/05/26/envy-code-r-preview-7-coding-font-released . If someone has an idea how I could get this to work, please speak up. Here's what I tried so far: 1.) Activate the font through ATS, then load it through NSFont through its postscript name. This is what most programs written in ObjC do – they call ATSFontActivateFromFileReference to load a ttf file and then can use NSFont to load the font given its postscript name. The problem is that there seems to be no built-in python binding for ATS. This fails: import ATS Now, ATS.framework is a subframework in the ApplicationServices framework, but this fails as well: import ApplicationServices Fair enough. The pyobjc documentation shows how to write your own wrapper: import objc b = objc.loadBundle("ApplicationServices", globals(), bundle_path=objc.pathForFramework(u'/System/Library/Frameworks/ ApplicationServices.framework/')) For reasons I don't quite understand, this doesn't load the ATS subframework methods, though (might be related that there is no ATS.bridgesupport in /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/ Versions/A/Resources/BridgeSupport). I tried to create the bridgesupport file on my own, using gen_bridge_metadata -f /System/Library/Frameworks/ ApplicationServices.framework/Frameworks/ATS.framework -o ATS.bridgesupport This gave some linking errors, and didn't work. `man gen_bridge_metadata` even says that there might be problems if you want to create bridgesupport files for subframeworks of umbrella frameworks, but doesn't really say how to work around them. I tried explicitly setting special compiler flags with gen_bridge_metadata -f /System/Library/Frameworks/ ApplicationServices.framework/Frameworks/ATS.framework -o ATS.bridgesupport -c ' -F /System/Library/Frameworks/ ApplicationServices.framework/Frameworks/ATS.framework -framework ApplicationServices' , but in vain. Now, pyobjc has a `loadBundleFunctions` function that can be used to load functions from a bundle. One of the examples in /Developer/ Examples/Python/PyObjC/Cocoa/AppKit/PyObjCLauncher/LaunchServices.py does use this function to load a specific function from a bundle. So I tried loading ATSFontActivateFromFileReference thusly (in its own file `myfile.py`): import objc __bundle__ = objc.loadBundle("ApplicationServices", globals(), bundle_path=objc.pathForFramework(u'/System/Library/ Frameworks/ApplicationServices.framework/')) functions = [( u'ATSFontActivateFromFileReference', 's^{FSRef=[80C]}II^vIo^I' )] objc.loadBundleFunctions(__bundle__, globals(), functions) (See http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/chapter_7_section_1.html for how the type encodings work; you can use `NSLog(@"FSRef*: %s", @encode(FSRef*));` to let gcc show you the type encoding for a given type). To some extent, this even worked. After `import myfile`, I can call ATSFontActivateFromFileReference on the `myfile` module. Cool. Now I need an FSRef of my font to pass it to the function. I tried: from Cocoa import * from CoreFoundation import * import myfile url = NSURL.fileURLWithPath_(u'Envy Code R Bold.ttf') status, fsref = CFURLGetFSRef(url, None) kATSFontContextLocal = 2 kATSFontFormatUnspecified = 0 kATSOptionFlagsDefault = 0 print myfile.ATSFontActivateFromFileReference(fsref, kATSFontContextLocal, kATSFontFormatUnspecified, None, kATSOptionFlagsDefault, None) However, this fails with the error message "# ValueError: depythonifying 'pointer', got 'Carbon.File.FSRef'". The problem is that I claimed that ATSFontActivate... takes a '^{FSRef=[80C]}' ("pointer to a struct FSRef which is 80 bytes"), but CFURLGetFSRef returns a Carbon.File.FSRef object instead (which, as far as I understand, is something from the days before pyobjc). Now, this object has a `.data()` function that returns the raw 80 bytes that make up the FSRef as a str, but there seems to be no way to pass raw data to a function that was loaded through loadBundleFunctions – so I have a reference to the function and all data I need to call it, but I can't get my data through the bridge. Looks like a dead end (and http://osdir.com/ml/python.pyobjc.devel/2006-12/msg00024.html seems to agree. Then again, that is a pre-Leopard post). 2.) Load the font through CoreGraphics, then convert it to a CoreText CTFont, which is toll-free bridged to NSFont, and use that for drawing. CoreGraphics provides a function to load a font from a file, which I can then convert to a CTFont, which is toll-free bridged to an NSFont. So I should be able to load a font this way and then use Cocoa's normal drawInRect_withAttributes_ function to draw it. I tried: from CoreGraphics import * from CoreText import * fontDataProvider = CGDataProviderCreateWithFilename('Envy Code R.ttf') customFont = CGFontCreateWithDataProvider(fontDataProvider) print customFont # looks good so far! ctFont = CTFontCreateWithGraphicsFont(customFont, 12.0, None, None) print CTFontCopyPostScriptName(ctFont) # looks still good print ctFont However, printing the ctFont or using it as an NSFont gives the error message "<Error>: can't find font object for font id 13828539." – and after that, even printing the postscript name returns "(null)". This does also happen when I call the same functions in an Objective-C program, so this is a limitation of the Cocoa runtime. Another dead end. 3.) Load the font through CoreGraphics, and also draw the text through CoreGraphics It's possible to get a CoreGraphics context from an NSGraphicsContext. Then I can set the current font of the cg context to the font I loaded from the ttf file. The first few steps even work: from CoreGraphics import * from CoreText import * # contains CGContextSetFont for some reason fontDataProvider = CGDataProviderCreateWithFilename('Envy Code R.ttf') customFont = CGFontCreateWithDataProvider(fontDataProvider) cgContext = NSGraphicsContext.currentContext().graphicsPort() CGContextSetFont(cgContext, customFont) Now, CG has a function CGContextShowTextAtPoint that draws a given string (char*) at a given position into a cg context. Sounds great, but as it turns out this function doesn't work for fonts loaded from a file – it only works for activated system fonts loaded through CGContextSelectFont (source: http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_text/chapter_18_section_4.html ). There is a function CGContextShowGlyphsAtPoint that works, but it takes a list of glyphs (indices into the font's glyph table – which glyph corresponds to which character is font-dependent!). There is no official function that converts a string to a list of glyphs for a given font, however. But there is an undocumented function: CGFontGetGlyphsForUnichars. As this function is undocumented, we have to load it ourselves again: # CoreGraphics is part of the ApplicationServices umbrella framework functions = [ # bool CGFontGetGlyphsForUnichars(CGFontRef, unichar[], CGGlyph[], size_t); ( u'CGFontGetGlyphsForUnichars', 'B^{CGFont=}^So^SI'), ] # This gives a bus error btw: #import CoreGraphics #objc.loadBundleFunctions(CoreGraphics, globals(), functions) AppServices = objc.loadBundle("ApplicationServices", globals(), bundle_path=objc.pathForFramework(u'/System/Library/ Frameworks/ApplicationServices.framework/')) objc.loadBundleFunctions(AppServices, globals(), functions) Now, let's try to call it: print CGFontGetGlyphsForUnichars(customFont, 'py', None, 2) This gives "ValueError: depythonifying 'pointer', got 'str'" as error. I couldn't figure out how to pass python text to a function that takes `unichar*`. This is probably possible somehow, but since this needs undocumented functions anyways, I'm not too happy with this approach anyway. 4.) Give up, write a small C-based module that calls ATSFontActivateFromFileReference given an string, call that from Python, and call it a day That's what I ended up doing. It works, but it is strange that this seems necessary for such mundane a task. Thanks, Nico |
|
From: Darran E. <da...@ed...> - 2009-01-31 03:14:06
|
Re our search for python developers for the Australian museum project ... Just a clarification that people definitely don't need to be located in Australia to work on this project. Our lead developer is actually in the Czech Republic, and we have others working in the UK, Singapore, US and elsewhere. Please don't let the distance dissuade you from making contact. Cheers, Darran |
|
From: Matthew A. <man...@gm...> - 2009-01-31 01:17:52
|
Hi --
After much hunting with google and through the content on the pyobjc
website, I was unable to find documentation on how one creates a class
method. I was, in particular, wanting to add a class method to an
existing Foundation class (for use only on the Python side of the
bridge, though I can imagine wanting to have access from the
Objective-C runtime as well). Is there an official, approved of way
of doing this?
After some experimentation and poking at source code, I did get this to work:
>>> def foo(arg, *args):
... print arg, args
...
>>> foo = objc.selector(foo)
>>> NSObject.__class__.foo = foo
>>> NSObject.foo()
<objective-c class NSObject at 0xa06bdcc0> ()
>>> NSObject.foo(1, 2, 3)
<objective-c class NSObject at 0xa06bdcc0> (1, 2, 3)
I'm unsure if setting attributes of a class's __class__ attribute is
frowned upon for some reason, or if there were a better way. Note, I
haven't tried to access any such function from Objective-C code. If
someone knows, after doing the above, would it work?
The hunt to figure this out came out of a desire to have an alternate
'syntax' to call objective-C methods from python code. Instead of:
>>> d = NSMutableDictionary.alloc().init()
>>> d.setObject_forKey_(5, "foo")
I wanted the option of saying something more like:
>>> d = NSMutableDictionary.alloc().init()
>>> d.call( "setObject:", 5,
"forKey:", "foo")
Mostly for aesthetic/readibility (and sane line wrapping in the editor) reasons.
I was able to write such a function "call", and with modest testing,
it seems to work just fine. I'm wondering a few things:
* is there some facility that I missed that already allows for
something like this?
* is this a bad and/or insane idea? if so, why? what sort of gotchas
are lurking out there if I were to add a "call" function to NSObject
(both instance and class method) and then use it in my code?
* if this is not an insane idea, and there is no facility like this
already in place, should there / could there be something like this
available in pyobjc?
My little proof of concept code is below.
Thanks,
Matt Anderson
======================================================================
#!/usr/bin/env python
from Foundation import *
import objc
def call(self, *arg):
if len(arg) == 0:
return None
elif len(arg) == 1:
sel = arg[0]
return getattr(self,sel)()
elif len(arg) % 2 == 0:
sel = "".join(arg[::2]).replace(":","_")
callargs = arg[1::2]
return getattr(self,sel)(*callargs)
else:
raise Exception("selector plus arguments must be even in number!")
call = objc.selector(call)
NSObject.call = call
NSObject.__class__.call = call
d = NSMutableDictionary.alloc().init()
d.call( "setObject:", 5,
"forKey:", "foo")
print d
# prints {
# foo = 5;
#}
print d.call("valueForKey:", "foo")
# prints 5
print d.call("className")
# prints NSCFDictionary
print NSUserDefaults.call('standardUserDefaults')
# prints <NSUserDefaults: 0x355870>
o = NSObject.alloc().init()
print NSObject.call("description")
# prints NSObject
print o.call("description")
# prints <NSObject: 0x361810>
|
|
From: Darran E. <da...@ed...> - 2009-01-30 14:51:54
|
Hi All,
We are working on a large museum project in Australia and need some good
python programmers to help us realise the outcome. On the digital side,
the 10,000 square foot gallery features
- a 14-screen touch "table" interactive
- a wraparound wall of community voices/faces
- touch interactives that solicit visiter opinions on museum content
- RFID-enabled passes that, among other things, provide content for
non-English speakers and accessibility to vision impaired visitors.
- roughly 45 short films spread over 20 different viewing areas
If this sounds interesting and you,
- are a savvy python programmer with pyObjC experience
- can work as part of globally-distributed team (museum is set up
with network cameras for remote access)
- are committed to unit testing (ideally test-driven-development)
- are available to work between half and full-time from Feb-April/May.
then please contact me directly at da...@ed.... Please provide
an indication of your experience, your availability, and your
saught-after hourly rate.
Cheers,
Darran
P.S. Apologies if the above "job posting" isn't welcome on the list; I
looked but couldn't find any restrictions in this regard.
|
|
From: Daniel A. <an...@cc...> - 2009-01-27 17:01:34
|
How can I catch NSUnknownKeyException? It's thrown by valueForUndefinedKey_, but appears to be somehow dynamically defined in the pyobjc code...? Thanks, dan |
|
From: Barron S. <li...@ba...> - 2009-01-20 22:47:21
|
On Jan 20, 2009, at 3:16 PM, Diez B. Roggisch wrote: > Barron Snyder schrieb: >> Hello, >> Can decorators with descriptors be used with pyobjc? >> I'm getting the error: >> * File "/Users/barron/Projects/Python/Relations/build/Debug/ >> Relations.app/Contents/Resources/Person.py", line 22, in Person* >> * @givenNames.setter* >> *AttributeError: 'property' object has no attribute 'setter'* >> *2009-01-17 09:45:26.140 Relations[1476:10b] *** Terminating app >> due to uncaught exception * >> Here's my class: >> class Person(NSObject): >> def __init__(self, givenNames, surname): >> self.givenNames = givenNames >> self.surname = surname >> @property >> def givenNames(self): >> return self.givenNames >> @givenNames.setter >> def givenNames(self, givenNames): >> self.givenNames = givenNames >> @property >> def surname(self): >> return self.surname >> @surname.setter >> def surname(self, surname): >> self.surname = surname >> Does pyobjc require a different way to do getters/setters than the >> Guido recommended way?: >> http://mail.python.org/pipermail/python-dev/2007-November/075182.html > > AFAIK that's python2.6-property-descriptor. You sure you are using > 2.6? > > Diez (sheepish grin) Well no, I'm using 2.5.1. Sorry, I'm new to all this and didn't know it was a new feature. Thanks for enlightening me. - Barron |
|
From: Will L. <le...@gm...> - 2009-01-20 20:50:19
|
Diez, I realize this is a very incomplete answer, but you can build XCode projects from the command line using 'xcodebuild', as described here http://developer.apple.com/documentation/Darwin/Reference/Manpages/man1/xcodebuild.1.html . (You could, if you like unnecessarily complex systems, also create an Automator workflow using the 'Build Xcode Project' action, and then run that workflow using /usr/bin/automator . :) Best, Will On Jan 20, 2009, at 3:31 PM, Diez B. Roggisch wrote: > Hi, > > after developing quite a few nice apps in pyobjc 1.4 under > Panther/Tiger, I finally started wetting my feet using 2.0 > > To be brutally honest: it hasn't been a smooth ride, to say the least. > > Will Larson's tutorial helped to explain quite a few things. Thanks > for > that, the donation is under way. > > But I can't stop noticing that *a lot* of things have become more > cumbersome. That begins with the need to decorate methods and to > explicit declare outlets. > > It continues with the existence of *.m-files that require a C- > compiler. > Granted, I have that, but nontheless... > > And Will mentions in part two that methods with underscores in them > confuse the system. Have to experience that myself, as I'd rather not > use CamelCase... > > But what seems to me a rather big issue is that one does not work with > setup.py/py2app anymore. The reason that bugs me is that I'm a heavy > PDB-user, and my coding is done using Emacs. > > So I used the py2app -A functionality to create an aliased project > that > I could modify the source in place, and potentially debug in the > console. > > Now I need to run build from XCode?!? Is there *any* way around > that? I > know one can invoke xcode from the commandline somehow, so far I never > did that... > > Or is there any chance I could continue to use 1.4? Or that the old > py2app-powers somehow return? > > Please don't take this as an insult to a truly great system. > > Hoping for the best, > > > Diez > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
|
From: Diez B. R. <de...@we...> - 2009-01-20 20:31:34
|
Hi, after developing quite a few nice apps in pyobjc 1.4 under Panther/Tiger, I finally started wetting my feet using 2.0 To be brutally honest: it hasn't been a smooth ride, to say the least. Will Larson's tutorial helped to explain quite a few things. Thanks for that, the donation is under way. But I can't stop noticing that *a lot* of things have become more cumbersome. That begins with the need to decorate methods and to explicit declare outlets. It continues with the existence of *.m-files that require a C-compiler. Granted, I have that, but nontheless... And Will mentions in part two that methods with underscores in them confuse the system. Have to experience that myself, as I'd rather not use CamelCase... But what seems to me a rather big issue is that one does not work with setup.py/py2app anymore. The reason that bugs me is that I'm a heavy PDB-user, and my coding is done using Emacs. So I used the py2app -A functionality to create an aliased project that I could modify the source in place, and potentially debug in the console. Now I need to run build from XCode?!? Is there *any* way around that? I know one can invoke xcode from the commandline somehow, so far I never did that... Or is there any chance I could continue to use 1.4? Or that the old py2app-powers somehow return? Please don't take this as an insult to a truly great system. Hoping for the best, Diez |
|
From: Barron S. <li...@ba...> - 2009-01-17 15:18:57
|
Hello,
Can decorators with descriptors be used with pyobjc?
I'm getting the error:
File "/Users/barron/Projects/Python/Relations/build/Debug/
Relations.app/Contents/Resources/Person.py", line 22, in Person
@givenNames.setter
AttributeError: 'property' object has no attribute 'setter'
2009-01-17 09:45:26.140 Relations[1476:10b] *** Terminating app due to
uncaught exception
Here's my class:
class Person(NSObject):
def __init__(self, givenNames, surname):
self.givenNames = givenNames
self.surname = surname
@property
def givenNames(self):
return self.givenNames
@givenNames.setter
def givenNames(self, givenNames):
self.givenNames = givenNames
@property
def surname(self):
return self.surname
@surname.setter
def surname(self, surname):
self.surname = surname
Does pyobjc require a different way to do getters/setters than the
Guido recommended way?:
http://mail.python.org/pipermail/python-dev/2007-November/075182.html
Thanks,
Barron |
|
From: p. m. <rik...@gm...> - 2009-01-08 22:07:48
|
Hi I need to get some info about a file - it's MIME type, and list of applications (or default application) that can open given file. I've checked fileAttributes of NSFileWrapper but it doesn't help me. Can it be done in PyObjc? |
|
From: Ian B. <ia...@on...> - 2009-01-01 17:19:09
|
Hey folks,
I'm running into trouble with a feature/limitation of the PyObjC
bridge and could use help figuring out how to work around it. I am
currently implementing a Cocoa plugin in pure Python using PyObjC,
py2app, and the default Leopard Python frameworks. The application
I'm plugging into expects to be able to send this message to any
classes that I create:
- (BOOL)performActionWithContext:(id)context error:(NSError **)outError
Because NSError pointers don't translate directly to Python, I've
coded my class method as follows:
def performActionWithContext_error_(self, context):
Objective-C sends the message just fine, and the Python code executes
correctly (the application's document reflects the changes after I
activate the plugin). However, when I run it I get an uncaught
exception error ("Uncaught system exception: signal 11") and the
program crashes. Best I can tell, this is because of the NSError**
stuff. All the examples I can find about using NSError** talk about
calling functions that use it from Python, and handling the tuple
return with Python. I haven't been able to find any resources about
sending a message with NSError** from Objective-C to Python. Is there
something specific I need to do to get this working? Any suggestions
for how to debug the problem?
If I've got things set up the way they should be, please let me know
that, too. It's possible that this error is located in the
application itself, which is currently in early beta.
I've tried setting up various signatures for the method, accepting an
argument as a placeholder for the pointer, and so forth, but nothing
changes the uncaught system exception. For example:
@objc.signature('B@:@:^^@')
def performActionWithContext_error_(self, context, outError):
Works identically to the version lacking the outError argument, as
does this:
@objc.signature('B@:@@')
def performActionWithContext_error_(self, context, outError):
Thanks for any pointers you can give me! (Sorry, couldn't resist the
pun.)
Ian
|
|
From: Andy M. <nzm...@gm...> - 2008-12-31 00:50:26
|
I'm using the OpenGl library (successfully) with an __init__ that looks
like:
import objc as _objc
import sys
__bundle__ = _objc.initFrameworkWrapper("CGL",
frameworkIdentifier="com.apple.opengl",
frameworkPath=_objc.pathForFramework(
"/System/Library/Frameworks/OpenGL.framework"),
globals=globals())
However there is a function that takes an opaque pointer that I'm struggling
to wrap.
The opaque pointer is CGLPixelFormatObj and it's defined as
typedef struct _CGLPixelFormatObject *CGLPicelFormatObj;
The function I need to use is CGLChoosePixelFormat defined as
CGLError CGLChoosePixelFormat ( const CGLPixelFormatAttribute *attribs,
CGLPixelFormatObj *pix, GLint *npix )
The ChoosePixelFormat function uses the Attributes (which I can create OK)
to modify the PixelFormatObj pointer to point to a newly created Object as
well as modifying npix to represent the number of screens..
First problem is that I am unable to create a CGLPixelFormatObj - get a
TypeError: Cannot create CGLPixelFormatObj objects. I've tried using
createOpaquePointerType without any success.. How do I get this pointer
creates - -and then once I do that I presume I'll need to tweak the calling
signature of ChoosePixelFormat to return the modified 'pix' and 'npix' ?
Thanks
Andy
|
|
From: Mic P. <mic...@gm...> - 2008-12-30 10:25:06
|
Hi, I'm looking at the possiblity of using Pyglet in a PyObjC application, but I think I may have come across an issue when reading up about PyObjC on the internet and I'm looking for a little clarification. Pyglet uses methods like the following to allow you to override and handle different window events ... @window.event def on_draw(): or @window.event def on_key_press(symbol, modifiers): But as I understand it, you cannot name your standard Python methods in this way (using the underscore) or PyObjC will cause an error? Is this the case ? Can I use Pyglet from a PyObjC applications (or any other Python library for that matter) ? If so, how ? Thanks -Mic |
|
From: Ian B. <ian...@ya...> - 2008-12-20 18:23:38
|
I'm doing some exploratory coding with subclassing NSOutlineView.
I want to override a method from NSView so I tried the code:
from Foundation import *
from AppKit import *
from PyObjCTools import NibClassBuilder
class CrimsonOutlineView(NibClassBuilder.AutoBaseClass):
# NSView
def adjustScroll_(self, proposedRect):
returnVal = super(CrimsonOutlineView, self).adjustScroll_(proposedRect)
print str(self)+" proposedRect_("+str(proposedRect) +") returns "+str(returnVal)
return returnVal
Pretty simple it just passes everything and prints the results to the console. But this causes a hard crash.
I know this has to do with NSRect being a basic struct and not an NSObject but I have no idea how to make it work.
Many thanks in advance and warm regards,
IBloom
|
|
From: Mani G. <ma...@tu...> - 2008-12-03 23:08:55
|
Hi all,
I have continued to tinker with this, and have the following to report:
I can invoke "setAlphaValue:" by using the performSelector: message, i.e.
---
anim = window.animator()
anim.performSelector_('setAlphaValue:')
---
This will make the window go fully transparent, since I can't pass in
any values and I guess it's just assuming nil or 0. But at least it
does so smoothly. :)
(Yes, I know about performSelector_withObject_ but the parameter for
setAlphaValue: is not an NSObject so it doesn't work).
This still doesn't answer the original question, but hopefully it
sheds some light. I'm sure this has to do with KVC stuff, which I am
admittedly quite unfamiliar with. Is my only option to start digging
into NSInvocation and figure out a different way to invoke the
setAlphaValue method?
Thanks in advance.
Regards,
Mani
On Wed, Dec 3, 2008 at 10:29 AM, Mani Ghasemlou <ma...@tu...> wrote:
> Hi all,
>
> Attempting to use proxy animations
> (http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/NSAnimatablePropertyContainer_protocol/Introduction/Introduction.html)
> on an NSWindow object causes a segmentation fault in my application.
> I've read the documentation over and over, and I must still be missing
> something!
>
> Here's how I'm trying to do it (this is a code snippet of my app
> delegate's instance method):
>
> [CODE]
> def fadeOut(self, window):
> window.animator().setAlphaValue_(0.0)
> window.orderOut_(self)
> [/CODE]
>
> calling fadeOut with an NSWindow instance as input, causes the
> application to crash. I tried the same code, without the animation
> proxy:
>
> [CODE]
> def fadeOut(self, window):
> window.setAlphaValue_(0.0)
> window.orderOut_(self)
> [/CODE]
>
> ... and it works just fine.
>
> Any ideas what I might be doing wrong here? (Fingers crossed that it's
> not something embarrassingly obvious...)
>
> Kind regards,
> Mani
>
|
|
From: Mani G. <ma...@tu...> - 2008-12-03 16:02:27
|
Hi all, Attempting to use proxy animations (http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/NSAnimatablePropertyContainer_protocol/Introduction/Introduction.html) on an NSWindow object causes a segmentation fault in my application. I've read the documentation over and over, and I must still be missing something! Here's how I'm trying to do it (this is a code snippet of my app delegate's instance method): [CODE] def fadeOut(self, window): window.animator().setAlphaValue_(0.0) window.orderOut_(self) [/CODE] calling fadeOut with an NSWindow instance as input, causes the application to crash. I tried the same code, without the animation proxy: [CODE] def fadeOut(self, window): window.setAlphaValue_(0.0) window.orderOut_(self) [/CODE] ... and it works just fine. Any ideas what I might be doing wrong here? (Fingers crossed that it's not something embarrassingly obvious...) Kind regards, Mani |
|
From: Frederik De B. <fre...@pa...> - 2008-11-25 19:03:20
|
After some more digging, I found out that XCode munges the original file hierarchy of your libraries. If you look inside Twite.app/ Contents/Resources, you'll see that scanner.py is in the root folder, although it should be inside of the simplejson folder. Here's the solution: 1. Download a new simplejson version from http://pypi.python.org/pypi/simplejson , and replace the old copy. Also, make sure there are no simplejson.py files in the root of your project. 2. Delete the folder reference to simplejson in your XCode project, and do a Resources > Right click > add existing files... > [ your new simplejson folder] > Create folder references. This last step is very important, and makes sure the package hierarchy is maintained. 3. Somewhere in your project was a reference to Scanner, with a capital 'S'. Replace that with a lowercase 's'. 3. Do a clean build of your project, so no extraneous simplejson.py files clutter up the system. Here's a version that includes the above changes: http://www.megaupload.com/?d=FOPDBQVI Kind regards, Frederik |
|
From: Alejandro N. <ale...@gm...> - 2008-11-25 18:18:00
|
Hello List! I´m a spanish python lover who wanted to develop for his loving aluminium Mac. My application tries to make a bridge between Tumblr and Twitter, making my last Tumblr post to appear in my Twitter timeline. I´m a user of both systems and this makes my life easier. I made a gui with with 3 textform, one for Tumblr feed and two for Twitter data. If a build this on my machine all works great, but if my source is built in other machine (same XCode 3.0 and Leopard version 10.5.2, and Mac of course) a import error appear. And I´m unable to build using py2app :/ A friendly hand will be welcome, You can download source from http://www.megaupload.com/es/?d=NTIO0580 Best Regards, Alex |
|
From: Ronald O. <ron...@ma...> - 2008-11-19 07:08:56
|
On 18 Nov, 2008, at 22:15, Luc Heinrich wrote: > On 12 nov. 08, at 21:17, Luc Heinrich wrote: > >> So I try to regenerate the ExceptionHandling framework bridgesupport >> file using gen_bridge_metadata but I'm not sure what to do with the >> result. > > So, I've made some progress on my own. > > Manually generating the metadata for the ExceptionHandling framework > (for example) in a PyObjC.bridgesupport file which I put in pyobjc- > framework-ExceptionHandling/Lib/ExceptionHandling allows the tests > to pass. Installing this and then using it works fine but ONLY with > alias builds (py2app -A). Using a bundled build fails with the same > error than without the bridgesupport file. > > So now what ? :) Have you checked if py2app copies the bridgesupport files into the application bundle? I'm currently (very) slowly adding unittest for the pyobjc-framework-* projects, after having ran into some issues with some API's that used to work but stopped doing so when I wasn't paying atttention to them. When that's finished I'll have some time to work on py2app and actually doing a release again. Porting PyObjC to OSX 10.4 has very low priority at the moment, I don't need that support myself and basicly won't have time to work on that in the forseeable future. Ronald |
|
From: Luc H. <lu...@ho...> - 2008-11-18 21:15:27
|
On 12 nov. 08, at 21:17, Luc Heinrich wrote: > So I try to regenerate the ExceptionHandling framework bridgesupport > file using gen_bridge_metadata but I'm not sure what to do with the > result. So, I've made some progress on my own. Manually generating the metadata for the ExceptionHandling framework (for example) in a PyObjC.bridgesupport file which I put in pyobjc- framework-ExceptionHandling/Lib/ExceptionHandling allows the tests to pass. Installing this and then using it works fine but ONLY with alias builds (py2app -A). Using a bundled build fails with the same error than without the bridgesupport file. So now what ? :) -- Luc Heinrich - lu...@ho... |
|
From: Luc H. <lu...@ho...> - 2008-11-12 20:40:37
|
Greetings, The PyObjC application I'm working on has to run on 10.4 and 10.5, which currently forces me to use PyObjC 1.4 on 10.4 to build the app, which recently started to cause some very weird performance issues so I would *really* like to use PyObjC 2 now. I'm trying to build the latest sources from trunk on 10.4 and I get errors with pyobjc-framework-Cocoa because: - NSUInteger does not exist on 10.4. - _CoreFoundation_CFBinaryHeap.m defines an NSObject category with no name, which gcc does not seem to like. Locally fixing these problems allows me to build pyobjc-framework- Cocoa, all the other pyobjc-framework that I want to use building just fine. But then I'm having the incomplete bridgesupport files problem. For example, this wouldn't work: from ExceptionHandling import NSLogAndHandleEveryExceptionMask So I try to regenerate the ExceptionHandling framework bridgesupport file using gen_bridge_metadata but I'm not sure what to do with the result. What should I do to be able to have a compilable and running PyObC 2 on 10.4 at this point? -- Luc Heinrich - lu...@ho... |
|
From: Paul T. <spo...@ma...> - 2008-10-25 21:15:28
|
Apologies, I found the problem in a different object in the same dictionary that wasn't ObjC derived On 25 Oct 2008, at 21:57, Paul Thomas wrote: > |
|
From: Paul T. <spo...@ma...> - 2008-10-25 20:57:57
|
I'm sending a dictionary from Python to an ObjC method and one of the values is a number. Trouble is, I keep getting this error: ValueError: NSInvalidArgumentException - Class OC_PythonObject: no such selector: isNSString__ The following are trimmed down from the real code and I can't get simple examples to fail the way my code does. This implies that it's a problem in my code of course, but I'm hoping against hope that someone has seen just this error before or can at least tell me what the problem might be. The really strange thing (strange to me with my level of understanding) is that I found one case where it does work - and that is passing the index value returned by enumerate(<seq>). assume 'v' comes from enumerate(): myobj.sendDictionary_(dict(version=v)) # works x=v myobj.sendDictionary_(dict(version=x)) # works #all these fail... myobj.sendDictionary_(dict(version=v)) myobj.sendDictionary_(dict(version=v+1)) x=v+1 myobj.sendDictionary_(dict(version=x)) myobj.sendDictionary_(dict(version=int(v+1)) myobj.sendDictionary_(dict(version=NSNumber.numberWithInt_(v+1))) I mean, what could the difference be between the proxy objects created in the different cases? Paul. |
|
From: Johannes S. <lgo...@go...> - 2008-10-25 16:46:33
|
I am trying to advance an NSProgressIndicator from a thread, therefor
i am using performSelectorOnMainThread_withObject_waitUntilDone_
to have the incrementBy call done from the main thread.
However while just calling progress_indicator.incrementBy_(some_value)
works just as expected,
progress_indicator.
performSelectorOnMainThread_withObject_waitUntilDone_("incrementBy:",
some_value, True)
just does not seem to do anything. See the code below for an simple
example.
from Foundation import *
import objc
class controller(NSObject):
progress_indicator = objc.IBOutlet()
@objc.IBAction
def go_(self, sender):
# WORKS
self.performSelectorOnMainThread_withObject_waitUntilDone_("test:",
25, True)
# DOES NOT SEEM TO WORK
self
.progress_indicator
.performSelectorOnMainThread_withObject_waitUntilDone_("incrementBy:",
25.0, True)
def test_(self, x):
print 'yaye', x
What am I doing wrong?
Regards,
Johannes
|
|
From: Dav C. <da...@al...> - 2008-10-18 23:44:54
|
Hi there, I spent quite a bit of time scouring the internet for answers, and there don't seem to be any... so now I put these to you: 1) The pyobjc website says Leopard users should install from svn trunk. Why? What (bad) happens if I use pyobjc 1.4 + python 2.5.2 (Framework, non-System) + Leopard (OSX 10.5.x)? 2) Is there anything that's simply an amazing improvement in 2.0 (for existing code that already works with 1.4)? 3) How the heck to I build 2.x PyObjC from the trunk. I've found threads where other's asked about this, but they never ended in an answer... FWIW - I'm interested in getting pyobjc into the Enthought Python Distribution - which requires compatibility with 10.4. So another angle on the above would be 4) Could I build pyobjc (mpkg or egg or what have you) that would work on both 10.4 and 10.5? Thanks! Dav |