Thread: [Pyobjc-dev] FYI: Open Source Scripting Layer For Cocoa
Brought to you by:
ronaldoussoren
From: Dinu G. <gh...@da...> - 2003-06-06 09:33:19
|
Might be of interest (if only as something to compare with), haven't looked deep inside, though... Dinu """ Open Source Scripting Layer For Cocoa Philippe Mougin writes "F-Script is a lightweight object-oriented interactive and scripting layer specifically designed for Mac OS X object system (i.e. Cocoa). F-Script version 1.2.4 greatly enhances the integration between F-Script and Cocoa, and comes with extended documentation. http://www.macslash.org/articles/03/06/05/1446248.shtml """ -- Dinu C. Gherman ...................................................................... "Never advice anyone to go to war or to marry." (Spanish Proverb) |
From: Jack J. <Jac...@cw...> - 2003-06-06 11:47:46
|
On Friday, Jun 6, 2003, at 11:35 Europe/Amsterdam, Dinu Gherman wrote: > Open Source Scripting Layer For Cocoa > > Philippe Mougin writes "F-Script is a lightweight object-oriented > interactive and scripting layer specifically designed for Mac OS X > object system (i.e. Cocoa). F-Script version 1.2.4 greatly enhances > the integration between F-Script and Cocoa, and comes with extended > documentation. > > http://www.macslash.org/articles/03/06/05/1446248.shtml I had a look at it, uhm, half a year ago. It is only half a bridge, i.e. F-Script can use ObjC but not the other way around. The main advantage it has over PyObjC is that it has an object/class browser and an interactive window. It's a bit clunky, but it gets you there quickly. A second advantage is that it should be easy to incorporate in your ObjC program, according to their website. And a final one, for ObjC programmers, is that the smalltalk dialect they use is closer to ObjC than Python is. I think that if we want to think of using PyObjC to rule the world F-Script would be a good target. If we can incorporate the same functionality as it has it would make PyObjC useful to more people. I'll post a separate mail on the class browser in a minute. -- Jack Jansen, <Jac...@cw...>, http://www.cwi.nl/~jack If I can't dance I don't want to be part of your revolution -- Emma Goldman |
From: Ronald O. <ous...@ci...> - 2003-06-08 14:55:08
|
On Friday, Jun 6, 2003, at 13:49 Europe/Amsterdam, Jack Jansen wrote: > > On Friday, Jun 6, 2003, at 11:35 Europe/Amsterdam, Dinu Gherman wrote: > >> Open Source Scripting Layer For Cocoa >> >> Philippe Mougin writes "F-Script is a lightweight object-oriented >> interactive and scripting layer specifically designed for Mac OS X >> object system (i.e. Cocoa). F-Script version 1.2.4 greatly enhances >> the integration between F-Script and Cocoa, and comes with extended >> documentation. >> >> http://www.macslash.org/articles/03/06/05/1446248.shtml > > I had a look at it, uhm, half a year ago. It is only half a bridge, > i.e. F-Script can use ObjC but not the other way around. > > The main advantage it has over PyObjC is that it has an object/class > browser and an interactive window. It's a bit clunky, but it gets you > there quickly. Both should be doable with PyObjC, the class browser has already been written at least twice and I think their is also an object browser in the mailinglist archives :-). The archives also contain a hack that allows you to write PyObjC based extension bundles, combine all these and you get something *very* interesting. > > A second advantage is that it should be easy to incorporate in your > ObjC program, according to their website. Python is not too hard to integrate into your ObjC programs. If you add some ObjC-sauce integrating Python would be as easy as integrating F-script. Ronald |
From: Jack J. <Jac...@cw...> - 2003-06-08 16:31:16
|
On zondag, jun 8, 2003, at 16:53 Europe/Amsterdam, Ronald Oussoren wrote: >> A second advantage is that it should be easy to incorporate in your >> ObjC program, according to their website. > > Python is not too hard to integrate into your ObjC programs. If you > add some ObjC-sauce integrating Python would be as easy as integrating > F-script. I know that it's not too hard, but what I think we really need is "dead easy". What I'd prefer is a useful bit of functionality, such as the recently mentioned class browser (which, incidentally, I missed??!? I only saw the followups to Just's original message) or an object browser, packaged in such a way that an ObjC programmer with no Python knowledge can easily plug it in his/her existing program. Alternatively, we should provide an example, probably in tutorial style. Hmm, idea: how about taking the currency converter ObjC tutorial as a start, and in the tutorial we add Python code to lookup actual exchange rates at oanda or x-rates or one of such sites, generating the right query and parsing the resulting HTML? Hmm, too bad: all top currency converters I looked at explicitly forbid this in the policy statements:-( Any other ideas for something that is much simpler in Python than in ObjC? -- - Jack Jansen <Jac...@or...> http://www.cwi.nl/~jack - - If I can't dance I don't want to be part of your revolution -- Emma Goldman - |
From: Just v. R. <ju...@le...> - 2003-06-09 07:48:25
|
Jack Jansen wrote: > [ ... ] such as the > recently mentioned class browser (which, incidentally, I missed??!? I > only saw the followups to Just's original message) Hm, that was from today, and since you also appeared to have missed an earlier attachment I posted I'm beginning to think you simply don't receive mime attachments from this list. Possible? I'll send you the code off-list... > or an object > browser, packaged in such a way that an ObjC programmer with no Python > knowledge can easily plug it in his/her existing program. Can we reach ivars from objects who's class is not defined in Python, from Python? Just |
From: Ronald O. <ous...@ci...> - 2003-06-09 08:04:00
|
On Sunday, Jun 8, 2003, at 18:39 Europe/Amsterdam, Just van Rossum wrote: > Jack Jansen wrote: > >> or an object >> browser, packaged in such a way that an ObjC programmer with no Python >> knowledge can easily plug it in his/her existing program. > > Can we reach ivars from objects who's class is not defined in Python, > from Python? We could somewhere between 0.6 and 0.7, but then I noticed that instance variables often have the same name as the getter method for that variable. All machinery is still there, it would not be too hard to add 'obj.pyobjc_instanceVariables' as special notation to allow access to instance variables (just like we do for methods). I'm going to dust off my code for writing a Python based plugin bundle, that should make it possible to inspect any Cocoa program that supports plugins :-) Ronald |
From: Ronald O. <ous...@ci...> - 2003-06-09 14:21:02
|
On Monday, Jun 9, 2003, at 10:02 Europe/Amsterdam, Ronald Oussoren wrote: > > I'm going to dust off my code for writing a Python based plugin > bundle, that should make it possible to > inspect any Cocoa program that supports plugins :-) I've checked in a module that allows you to build Python based preference panes, as well as an example that makes use of this: A 1 function calculator PreferencePane :-) I think we now have everything thats needed to build a plugin that allows full inspection of running programs. If someone wants to write such a beast I'd be more than willing to add this to our repository! Ronald |
From: Michael H. <mw...@py...> - 2003-06-09 11:37:24
|
Jack Jansen <Jac...@cw...> writes: > Any other ideas for something that is much simpler in Python than in > ObjC? I would have thought anything network-y that's in Python standard library would be a candidate... using XML-RPC to read someone's advogato diary or something like that? Of course, I don't know how hard that would be in ObjC, but it's falling-off-a-log easy in Python. Cheers, M. -- Ya, ya, ya, except ... if I were built out of KSR chips, I'd be running at 25 or 50 MHz, and would be wrong about ALMOST EVERYTHING almost ALL THE TIME just due to being a computer! -- Tim Peters, 30 Apr 97 |
From: <bb...@ma...> - 2003-06-09 20:44:56
|
>> Any other ideas for something that is much simpler in Python than in >> ObjC? XML-RPC and similar. XML processing is often easier in Python. File parsing/grepping/filtering. Image manipulation via something like PIL. Subprocess/task control -- someone ought to wrap pexpect into a Cocoa/Python app that would produce droplets or something. |
From: Bob I. <bo...@re...> - 2003-06-09 21:48:37
|
On Monday, Jun 9, 2003, at 16:44 America/New_York, bb...@ma... wrote: >>> Any other ideas for something that is much simpler in Python than in >>> ObjC? > > XML-RPC and similar. > > XML processing is often easier in Python. > > File parsing/grepping/filtering. > > Image manipulation via something like PIL. > > Subprocess/task control -- someone ought to wrap pexpect into a > Cocoa/Python app that would produce droplets or something. Networking code. Numerical code (Numpy). Anything that uses lists (list comprehensions, slices, etc). |
From: Just v. R. <ju...@le...> - 2003-06-10 20:51:11
|
Bob Ippolito wrote: > >>> Any other ideas for something that is much simpler in Python than > >>> in ObjC? > > > > XML-RPC and similar. > > > > XML processing is often easier in Python. > > > > File parsing/grepping/filtering. > > > > Image manipulation via something like PIL. > > > > Subprocess/task control -- someone ought to wrap pexpect into a > > Cocoa/Python app that would produce droplets or something. > > Networking code. > > Numerical code (Numpy). > > Anything that uses lists (list comprehensions, slices, etc). Regular expressions. Big ints (Python long ints). Handling email (the email package, poplib, smtplib, etc.). AppleEvents (Jack's aetools and the gensuite stuff). Unit testing (unittest). Indeed lists, but also dicts; both are just infinitely more convenient to work with in Python. And recently I noticed what an incredible boon it is that PyObjC automatically converts Python numbers to and from C ints *or* NSNumber objects as needed. ObjC code that uses NSNumbers becomes a *lot* simpler when translated into Python: you simply don't see them. But I guess I'm getting too far from what Jack is after... Just |
From: Jack J. <Jac...@cw...> - 2003-06-11 09:48:13
|
On Tuesday, Jun 10, 2003, at 22:49 Europe/Amsterdam, Just van Rossum wrote: > But I guess I'm getting too far from what Jack is after... Yes, sort of:-) Note that the list of things that are easier in Python than ObjC is useful by itself, we should at some point have an "introduction to PyObjC for ObjC programmers" that could list it, but what I'm after at the moment is one feature that (a) requires very little Python code and (b) has a large "WOW!" factor. Something along the lines of "map of" in the address book is what I'm thinking of in terms of wow-factor. And it should somehow integrate with one of Apple's introductory ObjC examples. -- Jack Jansen, <Jac...@cw...>, http://www.cwi.nl/~jack If I can't dance I don't want to be part of your revolution -- Emma Goldman |
From: Michael H. <mw...@py...> - 2003-06-11 10:50:33
|
Jack Jansen <Jac...@cw...> writes: > On Tuesday, Jun 10, 2003, at 22:49 Europe/Amsterdam, Just van Rossum > wrote: >> But I guess I'm getting too far from what Jack is after... > > Yes, sort of:-) > > Note that the list of things that are easier in Python than ObjC is > useful by itself, we should at some point have an "introduction to > PyObjC for ObjC programmers" that could list it, but what I'm after at > the moment is one feature that (a) requires very little Python code > and (b) has a large "WOW!" factor. > > Something along the lines of "map of" in the address book is what I'm > thinking of in terms of wow-factor. And it should somehow integrate > with one of Apple's introductory ObjC examples. Well, if none of the online currency exchange rate sites let you scrape the going rate, you could always fake one that returns a random rate within some range and scrape that. Not as good as the Real Thing, but it might do. Cheers, M. -- QNX... the OS that walks like a duck, quacks like a duck, but is, in fact, a platypus. ... the adventures of porting duck software to the platypus were avoidable this time. -- Chris Klein, alt.sysadmin.recovery |
From: <bb...@ma...> - 2003-06-11 18:15:46
|
On Wednesday, Jun 11, 2003, at 06:50 US/Eastern, Michael Hudson wrote: > Well, if none of the online currency exchange rate sites let you > scrape the going rate, you could always fake one that returns a random > rate within some range and scrape that. Not as good as the Real > Thing, but it might do. See the demo services at..... http://xmethods.com/ .... as any of them could easily be wrapped by a Cocoa/Python app. |
From: Jack J. <Jac...@cw...> - 2003-06-12 20:00:24
|
On woensdag, jun 11, 2003, at 20:13 Europe/Amsterdam, bb...@ma... wrote: > On Wednesday, Jun 11, 2003, at 06:50 US/Eastern, Michael Hudson wrote: >> Well, if none of the online currency exchange rate sites let you >> scrape the going rate, you could always fake one that returns a random >> rate within some range and scrape that. Not as good as the Real >> Thing, but it might do. > > See the demo services at..... > > http://xmethods.com/ > > .... as any of them could easily be wrapped by a Cocoa/Python app. Ah, brilliant! There's a currency converter in there. Now the problem has been replaced by a new one: does anyone here know how to talk to a soap service from Python, and do we have all the necessary tools available in a standard Python installation? -- - Jack Jansen <Jac...@or...> http://www.cwi.nl/~jack - - If I can't dance I don't want to be part of your revolution -- Emma Goldman - |
From: Bob I. <bo...@re...> - 2003-06-12 23:21:32
|
On Thursday, Jun 12, 2003, at 15:59 America/New_York, Jack Jansen wrote: > > On woensdag, jun 11, 2003, at 20:13 Europe/Amsterdam, bb...@ma... > wrote: > >> On Wednesday, Jun 11, 2003, at 06:50 US/Eastern, Michael Hudson wrote: >>> Well, if none of the online currency exchange rate sites let you >>> scrape the going rate, you could always fake one that returns a >>> random >>> rate within some range and scrape that. Not as good as the Real >>> Thing, but it might do. >> >> See the demo services at..... >> >> http://xmethods.com/ >> >> .... as any of them could easily be wrapped by a Cocoa/Python app. > > Ah, brilliant! There's a currency converter in there. > > Now the problem has been replaced by a new one: does anyone here know > how to talk to a soap service from Python, and do we have all the > necessary tools available in a standard Python installation? Python does not come with any SOAP stuff. However, Twisted also does SOAP and there's also a couple blocking implementations at: http://pywebsvcs.sourceforge.net/ With SOAPpy (which I think bbum used, perhaps an earlier version) you would do something like this: >>> from SOAPpy import WSDL >>> proxy = WSDL.Proxy("http://www.xmethods.net/sd/2001/ CurrencyExchangeService.wsdl") # this blocks >>> print proxy.getRate(country1='us', country2='canada') # so does this 0.7414 -bob |
From: Jack J. <Jac...@cw...> - 2003-06-13 08:49:52
|
On Friday, Jun 13, 2003, at 01:21 Europe/Amsterdam, Bob Ippolito wrote: >>>> Well, if none of the online currency exchange rate sites let you >>>> scrape the going rate, you could always fake one that returns a >>>> random >>>> rate within some range and scrape that. Not as good as the Real >>>> Thing, but it might do. >>> >>> See the demo services at..... >>> >>> http://xmethods.com/ >>> >>> .... as any of them could easily be wrapped by a Cocoa/Python app. >> >> Ah, brilliant! There's a currency converter in there. >> >> Now the problem has been replaced by a new one: does anyone here know >> how to talk to a soap service from Python, and do we have all the >> necessary tools available in a standard Python installation? > > Python does not come with any SOAP stuff. However, Twisted also does > SOAP and there's also a couple blocking implementations at: > http://pywebsvcs.sourceforge.net/ Ok, that's nice for a more involved example, but not for "embedding Python in ObjC 101". Too ba, I'll try and come up with something else:-) -- Jack Jansen, <Jac...@cw...>, http://www.cwi.nl/~jack If I can't dance I don't want to be part of your revolution -- Emma Goldman |
From: Ronald O. <ous...@ci...> - 2003-06-13 09:09:50
|
On Friday, Jun 13, 2003, at 10:51 Europe/Amsterdam, Jack Jansen wrote: > > On Friday, Jun 13, 2003, at 01:21 Europe/Amsterdam, Bob Ippolito wrote: > >>>>> Well, if none of the online currency exchange rate sites let you >>>>> scrape the going rate, you could always fake one that returns a >>>>> random >>>>> rate within some range and scrape that. Not as good as the Real >>>>> Thing, but it might do. >>>> >>>> See the demo services at..... >>>> >>>> http://xmethods.com/ >>>> >>>> .... as any of them could easily be wrapped by a Cocoa/Python app. >>> >>> Ah, brilliant! There's a currency converter in there. >>> >>> Now the problem has been replaced by a new one: does anyone here >>> know how to talk to a soap service from Python, and do we have all >>> the necessary tools available in a standard Python installation? >> >> Python does not come with any SOAP stuff. However, Twisted also does >> SOAP and there's also a couple blocking implementations at: >> http://pywebsvcs.sourceforge.net/ > > Ok, that's nice for a more involved example, but not for "embedding > Python in ObjC 101". Too ba, I'll try and come up with something > else:-) There is an XML-RPC library in 2.2 and 2.3, xmlrpc.org lists a number of public services (from a currentTime function at Userland to Meercat at O'Reilly). Ronald |
From: Just v. R. <ju...@le...> - 2003-06-13 09:26:00
|
Ronald Oussoren wrote: > > Ok, that's nice for a more involved example, but not for "embedding > > Python in ObjC 101". Too ba, I'll try and come up with something > > else:-) > > There is an XML-RPC library in 2.2 and 2.3, xmlrpc.org lists a number > of public services (from a currentTime function at Userland to Meercat > at O'Reilly). The WebServicesTool example demonstrates xmlrpc already quite well. However, it's a rather elaborate demo, so a simpler one would be very useful as well. That said, I feel quite strongly that any networking Cocoa app should either use asynchronous I/O or threads, which complicates the matter quite a bit. It's possible to run a twisted reactor (= twisted event loop) in a different thread (I've briefly played with that, works like a charm). It *might* be possible to build a twisted reactor that's integrated with the main Cocoa event loop, but that is likely quite hard. The WebServicesTool demo uses xmlrpclib in a worker thread (in CVS at least, I recently did a lot of work on it), but the complicatated thing about it is that as soon as you use Cocoa stuff from a different thread, you have to deal with autorelease pools. I've found it impossible to do even the simplest Cocoa things (eg obj.performSelectorOnMainThread_etc.) in PyObjC without implicitly creating autoreleased objects, so you don't really get around wrapping your code in NSAutoreleasePool.pyobjcPushPool() / NSAutoreleasePool.pyobjcPopPool() blocks. See WebServicesTool for how that's done. Just |
From: Jack J. <Jac...@cw...> - 2003-06-13 12:01:14
|
Okay, a wholly different idea from the currency one: take the SimpleComboBox example from /Developer/Examples/Appkit. This demonstrates a combo-box, but what we use is the fact that the application pretends to be a CD collection note taking tool. We could add a button "Ask iTunes", which would fire up Python code that uses Python's OSA stuff to ask iTunes for the currently playing artist and album. Cons: I'm not sure the Python OSA stuff will work in a Cocoa app, won't work easily under 2.2 (no gensuitemodule, probably bugs in Carbon.AE too), the gensuitemodule song-and-dance may be a bit involved. Pro: shows off OSA stuff too. Comments? -- Jack Jansen, <Jac...@cw...>, http://www.cwi.nl/~jack If I can't dance I don't want to be part of your revolution -- Emma Goldman |
From: Bob I. <bo...@re...> - 2003-06-13 13:28:29
|
On Friday, Jun 13, 2003, at 05:25 America/New_York, Just van Rossum wrote: > That said, I feel quite strongly that any networking Cocoa app should > either use asynchronous I/O or threads, which complicates the matter > quite a bit. Me too, it makes Python/PyObjC look really bad if we offer spinning beach balls with an unresponsive UI. > > It's possible to run a twisted reactor (= twisted event loop) in a > different thread (I've briefly played with that, works like a charm). > It > *might* be possible to build a twisted reactor that's integrated with > the main Cocoa event loop, but that is likely quite hard. The > WebServicesTool demo uses xmlrpclib in a worker thread (in CVS at > least, > I recently did a lot of work on it), but the complicatated thing about > it is that as soon as you use Cocoa stuff from a different thread, you > have to deal with autorelease pools. I've found it impossible to do > even > the simplest Cocoa things (eg obj.performSelectorOnMainThread_etc.) in > PyObjC without implicitly creating autoreleased objects, so you don't > really get around wrapping your code in > NSAutoreleasePool.pyobjcPushPool() / NSAutoreleasePool.pyobjcPopPool() > blocks. See WebServicesTool for how that's done. I've been meaning to develop a CFRunLoop reactor for Twisted for months now. Basically, you would be replacing the select() mechanism with something that used CFRunLoop, CFSocket (can probably use the existing functionality and just have the CFSocket use the fileno from them), and CFTimer. Unfortunately, not all of this stuff is wrapped in PyObjC or Python 2.3 yet so I'm expecting it to entail a fair amount of pain-in-the-ass C code with lots of structures and callbacks into Python (yay CFSocket). That said, if I find the time in the near future, it should be in a late release of Twisted 1.0.X or an early release of Twisted 1.1.X. I'll make a post to this list when it's in Twisted CVS in case anyone wants to play with it. If anyone wants to wrap more of CoreFoundation for Python in the meantime, I surely wouldn't complain :) -bob |
From: Ronald O. <ous...@ci...> - 2003-06-13 13:42:06
|
On Friday, Jun 13, 2003, at 15:28 Europe/Amsterdam, Bob Ippolito wrote: > > I've been meaning to develop a CFRunLoop reactor for Twisted for > months now. Basically, you would be replacing the select() mechanism > with something that used CFRunLoop, CFSocket (can probably use the > existing functionality and just have the CFSocket use the fileno from > them), and CFTimer. Unfortunately, not all of this stuff is wrapped > in PyObjC or Python 2.3 yet so I'm expecting it to entail a fair > amount of pain-in-the-ass C code with lots of structures and callbacks > into Python (yay CFSocket). If you're going to wrap CFSocket/CFRunLoop you may want to check how Jack uses bgen and use that. Ronald |
From: Just v. R. <ju...@le...> - 2003-06-13 13:42:16
|
Bob Ippolito wrote: > I've been meaning to develop a CFRunLoop reactor for Twisted for > months now. Basically, you would be replacing the select() mechanism > with something that used CFRunLoop, CFSocket (can probably use the > existing functionality and just have the CFSocket use the fileno from > them), and CFTimer. Unfortunately, not all of this stuff is wrapped > in PyObjC or Python 2.3 yet so I'm expecting it to entail a fair > amount of pain-in-the-ass C code with lots of structures and > callbacks into Python (yay CFSocket). I don't know anything about how twisted reactors work internally, but since Cocoa has pretty decent support for async I/O, wouldn't it be an option to use this instead of going all the way down to CFRunLoop? I'm thinking of these NSFileHandle methods: - acceptConnectionInBackgroundAndNotify - readInBackgroundAndNotify - readToEndOfFileInBackgroundAndNotify - waitForDataInBackgroundAndNotify and the notifications that go with them. Using any of the above will actually cause a thread to be spawned, but that's not visible from user code. I wonder though, does Cocoa spawn a new thread for each NSFileHandle, or will it use _one_ (possibly select-based) thread for all of them? Just |