Edit: To future googlers abarnert's answer works giving a NSHIObject (from HIToolbox, HI standing for human interface), I can find little more documentation on this, the only mention on apple.com (there is ZERO, ZIP, NADA documentation on a class called NSHI object as of this point https://www.google.com/#q=%22NSHIObject%22+site%3Aapple.com&filter=0 ) is In object c if I have the following http://lists.apple.com/archives/webkitsdk-dev/2010/Sep/msg00007.html which doesn't work for this object the NSWindow isn't created. Yay for apples api documentation.
NSWindow.initWithWindowRef_(nshi_object)
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: Expecting instance of NSWindow as self, got one of NSHIObject
Original Question about loading the pointer given from wxPython
C Code
// our data
int a = 42;
// create a pointer to that data
int *p = &a;
// p now contains the address (say 1776) and that address has the integer 42
// get the data back
int ret_a = *p;
// now if we already have an address
int* manual_pointer = (int*) 1776;
int man_a = *manual_pointer;
printf("%d,%d\n", ret_a, man_a);
How do I do this syntax in pyobjc? I see it mentions here
More complex types can be represented using longer type strings:
a pointer to some type is _C_PTR followed by the type string of the pointed-to type.
So what do I do? This (if the object type is NSInt)?
arg = _C_PTR + "NSInt" + "1776"
Objective C Code (Added later) Please note you have to somehow inject this into the python process other wise it won't work
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
char line[2048];
// this will store are address
long adr;
printf("According to \n- http://forums.wxwidgets.org/viewtopic.php?f=23&t=31778\n- http://forums.wxwidgets.org/viewtopic.php?f=23&t=18645\n");
printf("This will prompt you for a pointer address; please paste in the long you received from GetHandle()\n");
printf("Please enter pointer address: ");
fgets(line, sizeof(line), stdin);
sscanf(line, "%ld", &adr);
printf("Using address: %ld\n", adr);
printf("Grabbing view...");
// our NSView
NSView *view = (__bridge NSView *)((void *)adr);
NSRect f = view.frame;
int w = f.size.width;
int h = f.size.height;
printf("Size(%d, %d)", w, h);
}
return 0;
}