pyobjc-dev Mailing List for PyObjC (Page 74)
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: Ronald O. <ron...@ma...> - 2007-11-10 16:51:29
|
On 10 Nov, 2007, at 17:40, Koen Bok wrote:
> Hi all,
>
> Is it possible to redirect all errors and exceptions to a python
> logging object instead of stdout?
There is no explicit support for doing that, beyond what Python
already offers. You can redirect sys.stdout and sys.stderr to
somewhere else and that should cause all output to appear somewhere
else.
That won't redirect the C-level stdout/stderr streams though, the
output of NSLog will still appear on default location. You can
redirect that to a different file as well though by unix-y trickery.
Something like:
import os, sys
sys.stdout.flush()
sys.stderr.flush()
fd = os.open('/tmp/mylogfile.txt', os.O_WRONLY|os.O_CREAT|os.O_APPEND)
os.dup2(fd, 2)
os.dup2(fd, 1)
os.close(fd)
This will replace the file descriptors for stdout/stderr by ones that
write to a logfile, and should work for all output (although I haven't
checked if it works for NSLog as well, Apple might have introduced a
different mechanism for that).
Ronald
>
>
> I have noticed the console in Leopard is not 'live' anymore, sometimes
> it takes a few seconds to spit out data. That is confusing as I'm
> using it as my main debug tool :-)
>
> Kindest regards,
>
> Koen Bok
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a
> browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Pyobjc-dev mailing list
> Pyo...@li...
> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
|
|
From: Koen B. <ko...@ma...> - 2007-11-10 16:40:24
|
Hi all, Is it possible to redirect all errors and exceptions to a python logging object instead of stdout? I have noticed the console in Leopard is not 'live' anymore, sometimes it takes a few seconds to spit out data. That is confusing as I'm using it as my main debug tool :-) Kindest regards, Koen Bok |
|
From: Ronald O. <ron...@ma...> - 2007-11-10 15:24:31
|
On 10 Nov, 2007, at 9:58, Uliano Guerrini wrote: > Hi, > this code: > > cf=Foundation.CFDataCreate(None,string,len) > > works as expected, while: > > cf=Foundation.CFDataCreateWithBytesNoCopy(None,string,len,None) > > generates crap data. How can I fix this? both seem to work as expected. What might bite you is that you must make sure that 'string' is kept alive as long as you might access 'cf', Python's garbage collector doesn't (and cannot) know that CFDataCreateWithBytesNoCopy sneeks a reference to part of a Python object in the object it creates. Could you please create a demo program that demonstrates the problem you're having? Ronald > > > cheers, > > uliano > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a > browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
|
From: Uliano G. <gue...@gm...> - 2007-11-10 08:58:02
|
Hi, this code: cf=Foundation.CFDataCreate(None,string,len) works as expected, while: cf=Foundation.CFDataCreateWithBytesNoCopy(None,string,len,None) generates crap data. How can I fix this? cheers, uliano |
|
From: Ronald O. <ron...@ma...> - 2007-11-09 16:06:43
|
On 9 Nov, 2007, at 15:44, Yaniv Aknin wrote: > As I'm using Tiger, sounds to me like I might be better off writing > the code which deals with DiskArbitration in C, and using that in my > Python program using a C API. What would you do in my case? I'd write a wrapper in Objective-C and wrap that using PyObjC. That's likely to be a lot less work than writing a Python C extension. Well, to be honest I wouldn't do that either, I'd extend PyObjC to deal with this framework as well. But I'm the PyObjC maintainer after all :-) Ronald > > > On 11/9/07, Ronald Oussoren <ron...@ma...> wrote: > > On Friday, November 09, 2007, at 08:59AM, "Yaniv Aknin" <ya...@ak... > > wrote: > >Hello list, > > > >I'm trying to wrap the DiskArbitration ( > >http://developer.apple.com/documentation/Darwin/Reference/DiscArbitrationFramework/index.html#/ > /apple_ref/doc/framework/diskarb ) > >framework using PyObjC. This is the first time I'm using PyObjC and > I'm not > >sure I have everything understood correctly. > > > >After: > >>>> import objc > >>>> d = {} > >>>> b = objc.loadBundle('DiskArbitration', d, bundle_path= > >objc.pathForFramework > >(u'/System/Library/Frameworks/DiskArbitration.framework')) > >>>> > > > >Now what? I've seen nothing related to DiskArbitration in b or d. I > know > >that for wrapping some methods I'll have to use > setSignatureForSelector(), > >but I thought this is only for methods, not for unbound functions > like > >DAApprovalSessionCreate (which I'd like to use). > > > >Any help will be greatly appreciated. > > DiskArbitration is a C-based (CoreFoundation) framework, hence > you'll have to do more work than just loading the header files. > > Are you on Tiger or Leopard? If you are on Leopard you can use the > BrigeSupport tools (see the manpage for gen_bridge_metadata) to > generate an XML file that describes the API. You'll probably have to > work with "exception" files to describe some details of the API, but > the tools should for the most part do the right thing. When you have > a bridgesupport file PyObjC2 can load that to automagicly wrap > global functions and CoreFoundation-based types as well. > > On Tiger live is not so easy, PyObjC2 doesn't work there yet and > PyObjC 1.x doesn't support CoreFoundation based types. I'm hoping to > port PyObjC2 to Tiger in the near future, but want to work on other > changes before I do that. > > Ronald > > > > > - Yaniv > > > |
|
From: Yaniv A. <ya...@ak...> - 2007-11-09 15:47:25
|
As I'm using Tiger, sounds to me like I might be better off writing the code which deals with DiskArbitration in C, and using that in my Python program using a C API. What would you do in my case? On 11/9/07, Ronald Oussoren <ron...@ma...> wrote: > > > On Friday, November 09, 2007, at 08:59AM, "Yaniv Aknin" <ya...@ak...> > wrote: > >Hello list, > > > >I'm trying to wrap the DiskArbitration ( > > > http://developer.apple.com/documentation/Darwin/Reference/DiscArbitrationFramework/index.html#//apple_ref/doc/framework/diskarb > ) > >framework using PyObjC. This is the first time I'm using PyObjC and I'm > not > >sure I have everything understood correctly. > > > >After: > >>>> import objc > >>>> d = {} > >>>> b = objc.loadBundle('DiskArbitration', d, bundle_path= > >objc.pathForFramework > >(u'/System/Library/Frameworks/DiskArbitration.framework')) > >>>> > > > >Now what? I've seen nothing related to DiskArbitration in b or d. I know > >that for wrapping some methods I'll have to use > setSignatureForSelector(), > >but I thought this is only for methods, not for unbound functions like > >DAApprovalSessionCreate (which I'd like to use). > > > >Any help will be greatly appreciated. > > DiskArbitration is a C-based (CoreFoundation) framework, hence you'll have > to do more work than just loading the header files. > > Are you on Tiger or Leopard? If you are on Leopard you can use the > BrigeSupport tools (see the manpage for gen_bridge_metadata) to generate an > XML file that describes the API. You'll probably have to work with > "exception" files to describe some details of the API, but the tools should > for the most part do the right thing. When you have a bridgesupport file > PyObjC2 can load that to automagicly wrap global functions and > CoreFoundation-based types as well. > > On Tiger live is not so easy, PyObjC2 doesn't work there yet and PyObjC > 1.x doesn't support CoreFoundation based types. I'm hoping to port PyObjC2 > to Tiger in the near future, but want to work on other changes before I do > that. > > Ronald > > > > > - Yaniv > > > |
|
From: Ronald O. <ron...@ma...> - 2007-11-09 10:54:52
|
On Friday, November 09, 2007, at 08:59AM, "Yaniv Aknin" <ya...@ak...> wrote: >Hello list, > >I'm trying to wrap the DiskArbitration ( >http://developer.apple.com/documentation/Darwin/Reference/DiscArbitrationFramework/index.html#//apple_ref/doc/framework/diskarb) >framework using PyObjC. This is the first time I'm using PyObjC and I'm not >sure I have everything understood correctly. > >After: >>>> import objc >>>> d = {} >>>> b = objc.loadBundle('DiskArbitration', d, bundle_path= >objc.pathForFramework >(u'/System/Library/Frameworks/DiskArbitration.framework')) >>>> > >Now what? I've seen nothing related to DiskArbitration in b or d. I know >that for wrapping some methods I'll have to use setSignatureForSelector(), >but I thought this is only for methods, not for unbound functions like >DAApprovalSessionCreate (which I'd like to use). > >Any help will be greatly appreciated. DiskArbitration is a C-based (CoreFoundation) framework, hence you'll have to do more work than just loading the header files. Are you on Tiger or Leopard? If you are on Leopard you can use the BrigeSupport tools (see the manpage for gen_bridge_metadata) to generate an XML file that describes the API. You'll probably have to work with "exception" files to describe some details of the API, but the tools should for the most part do the right thing. When you have a bridgesupport file PyObjC2 can load that to automagicly wrap global functions and CoreFoundation-based types as well. On Tiger live is not so easy, PyObjC2 doesn't work there yet and PyObjC 1.x doesn't support CoreFoundation based types. I'm hoping to port PyObjC2 to Tiger in the near future, but want to work on other changes before I do that. Ronald > > - Yaniv > |
|
From: Yaniv A. <ya...@ak...> - 2007-11-09 07:59:12
|
Hello list, I'm trying to wrap the DiskArbitration ( http://developer.apple.com/documentation/Darwin/Reference/DiscArbitrationFramework/index.html#//apple_ref/doc/framework/diskarb) framework using PyObjC. This is the first time I'm using PyObjC and I'm not sure I have everything understood correctly. After: >>> import objc >>> d = {} >>> b = objc.loadBundle('DiskArbitration', d, bundle_path= objc.pathForFramework (u'/System/Library/Frameworks/DiskArbitration.framework')) >>> Now what? I've seen nothing related to DiskArbitration in b or d. I know that for wrapping some methods I'll have to use setSignatureForSelector(), but I thought this is only for methods, not for unbound functions like DAApprovalSessionCreate (which I'd like to use). Any help will be greatly appreciated. - Yaniv |
|
From: Barry W. <bar...@gm...> - 2007-11-09 00:13:16
|
Thanks! I'm no threading expert, but if I will see what I can do re unittests. Thanks, Barry On Nov 6, 2007 9:05 AM, Barry Wark <bar...@gm...> wrote: > Is it possible to use the mutex created by the Objective-C > @synchronized statement from with in PyObjC? I haven't been Here's the > use case I have in mind: I have an NSObject subclass created in > python. I would like to be able to synchronize access to a block from > within python like > self._mutex_.lock() > try: > #special code here > finally: > self._mutex_.unlock() > > where self._mutex_ is the mutex created for the for the Objective-C > @synchronized(self) statement. IIRC, this mutex is created only when a > @synchronized statment is used, so I suppose I need to be able to > create this mutex from Python as well. > > Any pointers appreciated. > > Barry > |
|
From: Barry W. <bar...@gm...> - 2007-11-09 00:10:48
|
Given recent traffic on the pythonmac-sig, it sounds like the system python on Leopard goes out of its way to put the site-packages directory in /Library last on the sys.path. So, if we want to write python apps that use newer versions of, e.g., numpy than those that shipped with Leopard, we're SOL unless we want to go through some PYTHONPATH contortions. The easy solution is to install MacPython into /Library/Frameworks. Then the system python and the user-updated python can be easily separated. I've so far been unable to install pyobjc2 on Leopard using MacPython 2.5.1. It sounds like I'm having similar problems to the OP (output of ./02-develop-all.sh is included; is 02-develop-all.sh the correct way to build/install the entire package?). As Ronald mentioned, it looks like this is because the 10.4u SDK is being used. Is there a way to specify building using the 10.5 SDK and will this build work with the MacPython 2.5.1 (dowloaded as a DMG from python.org) which is presumably built with the 10.4u SDK? thanks, Barry On Nov 7, 2007 11:19 PM, Ronald Oussoren <ron...@ma...> wrote: > > On 8 Nov, 2007, at 7:14, Seungchan Oh wrote: > > > Hello, > > > > I'm having a difficulty to install PyObjC2.0 at Leopard with MacBook > > Pro. > > I haven't tried building on 10.4 for a while (which is what you're > basicly trying to do because you're using the 10.4 SDK). Appearently > there are some issues there. > > Note that PyObjC 2.0 definitely requires some work to be useful on > Tiger systems because Tiger doesn't ship with bridgesupport files and > PyObjC 2 requires those files to provide full bindings. Generating > bridgesupport files is easy enough, but not a priority for me right > now because building them takes a lot of time (for the computer, the > task barely requires interaction with a human) and I'm currently > thinking about some changes that would require rebuilding the > bridgesupport files anyway. > > BTW. You do know that Leopard ships with a perfectly fine copy of > Python 2.5 and PyObjC 2.0? At this point in time it would be easier to > use that instead of trying to rebuild PyObjC from scratch. > > Ronald > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > |
|
From: Craig S. <cra...@fa...> - 2007-11-08 23:15:49
|
Thanks again, Ronald. I have it working. I just wanted to post the
code that I used in case some other person browses this list looking
for the same answer I was. In my case I created a framework out of my
class.
import objc
Bundle = objc.lookUpClass('NSBundle')
bundle = Bundle.alloc().initWithPath_('/Path/To/MyClass.framework')
bundle.load()
#and now Ronald's code in his reply can be used:
> MyClass = objc.lookUpClass("MyClass")
>
> myObject = MyClass.alloc().initWithSprocketCount_(4)
>
> class MyPythonClass (MyClass):
> pass
Craig
On Nov 8, 2007, at 7:36 AM, Ronald Oussoren wrote:
>
> On 20 Oct, 2007, at 15:29, Craig Swank wrote:
>
>> Hello,
>> How do you create an instance of a custom objective-c class in
>> python? Or instead of that, how about extending a custom objective-
>> c class as a python class? I've found a lot of information about
>> you can extend, for instance, NSObject, but not a custom class that
>> was written by me. Are either one of these possible?
>
> Both are possible. The key issue is getting a reference to your
> custom class, after that you can the same mechanisms as for any
> other class.
>
> To use or subclass your custom class you first have to make sure
> that said class is compiled into a bundle (such as a framework or
> plugin bundle). When you load that bundle (using the NSBundle API)
> you can get a reference to your class using objc.lookUpClass, that is:
>
> import objc
> MyClass = objc.lookUpClass("MyClass")
>
> myObject = MyClass.alloc().initWithSprocketCount_(4)
>
> class MyPythonClass (MyClass):
> pass
>
>
> Ronald
>
>>
>> Thanks,
>>
>> Craig Swank
>> cra...@fa...
>>
>>
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by: Splunk Inc.
>> Still grepping through log files to find problems? Stop.
>> Now Search log events and configuration files using AJAX and a
>> browser.
>> Download your FREE copy of Splunk now >> http://get.splunk.com/_______________________________________________
>> Pyobjc-dev mailing list
>> Pyo...@li...
>> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
>
Craig Swank
cra...@fa...
|
|
From: David B. <db3...@gm...> - 2007-11-08 21:01:30
|
Antonio <str...@ti...> writes: > hi all, > > I'm trying to use Twisted Perspective Broker with pyobjc ... the server > run on a Linux server, and the Linux client work very well ... > > I don't understand HOW use the deferred and tthe reactor with PyObjC ... > can someone help me or give me a link to a tutorial ? I'm running a PB-based client/server app (both on OS X at the moment) that works very nicely with PyObjC. I've been using PyObjC 1.4 (from source) with Python 2.5.1 and Twisted 2.5.0. I originally started with Bob's blog at: http://bob.pythonmac.org/archives/2005/04/17/twisted-and-foreign-event-loops/ and the example WebServicesTool application in the PyObjc Examples directory. (Note that I had to correct its use of "threadedselectreactor" to the current (in Twisted 2.5) "_threadedselect") >From your posted code, I think you're on the right track. I think the only critical issue you have is in trying to use the default reactor rather than the _threadedselect version. (I'm assuming that MyObject is defined via IB in MainMenu.nib as your application class delegate) I have found that I needed to improve the sample applicationShouldTerminate: handling to permit a system shutdown if the application is still running (by avoiding the use of NSTerminateCancel/False). By using NSTerminateFinal, and an extra reactor shutdown callback, I can let the reactor finish shutting down and still tell OS X that the application is permitting termination. While setting up your PB client in your constructor for your application delegate is certainly doable in simple cases, I'm generally a fan of keeping the non-GUI elements in separate modules and trying to let the GUI use that as business/processing logic. Here's a sample of my server's startup module, server_ui.py. This serves as the main module for the PyObjC version of my server (built with py2app), but the actual server logic is over in a "server" module. The latter is cross-platform portable (no PyObjC/UI code). Note that to avoid delaying the UI startup due to server startup processing, I added an extra delay so that the server startup processing only executes once the reactor is up and running. I do something similar in my client and find that it improves the perceived performance of the UI since it lets all initial UI message delivery/display take place before Twisted based code executes in the first few interleaved reactor executions. For the client case, it also let me postpone importing most of the twisted and other larger application modules (which can be a noticeable delay) while providing a plugin-like status display in the client window as everything is initialized. When server.startup() is executing, it can behave just like any Twisted application (it has no knowledge it is executing in a PyObjC/Cocoa environment). The only action for this application is quitting (via menu or a Shutdown button bound to terminate: on FirstResponder). Note that I need to assign self.version a value during the constructor since it is used as a binding and needs to be present in the delegate instance when the UI is being built from the NIB. Hope this helps point you in the right direction. -- David - - - - - - - - - - - - - - - - - - - - - - - - - import os from AppKit import NSApp, NSAlert, NSImage, NSTerminateLater, NSTerminateNow from PyObjCTools import NibClassBuilder, AppHelper from twisted.internet._threadedselect import install reactor = install() from twisted.internet.error import CannotListenError import server from version import __version__ NibClassBuilder.extractClasses("MainMenu") class PlayApplicationDelegate(NibClassBuilder.AutoBaseClass): # # Bindings: # version - Version string (NSTextField) for main window # status - Status message (NSTextField) for main window # Outlets: # logo - NSImageView reference for logo display in main window # window - NSWindow reference for main window # status = 'Server Initializing' def init(self): self = super(PlayApplicationDelegate, self).init() self.version = __version__ return self def awakeFromNib(self): frozen = getattr(sys, 'frozen', None) if frozen == 'macosx_app': root = os.getenv('RESOURCEPATH') else: root = os.path.dirname(__file__) image_fname = os.path.join(root, 'web', 'images', 'PlayLogo.gif') self.logo_image = NSImage.alloc().initByReferencingFile_(image_fname) self.logo.setImage_(self.logo_image) self.window.center() def _cbStartupComplete(self, value): self.status = 'Server running' def _cbStartupFailure(self, failure): title = 'Initialization failure (server must exit):\n%s\n' % \ failure.getErrorMessage() if failure.check(CannotListenError): title += '\nIs a server already running?\n' dlg = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( title, 'Exit', None, None, failure.getTraceback()) dlg.runModal() # Don't terminate from within the callback chain, as I got things stuck # (probably due to it calling applicationShouldTerminate: synchronously) AppHelper.callLater(0, NSApp().terminate_, self) def run(self): d = server.startup() d.addCallback(self._cbStartupComplete) d.addErrback(self._cbStartupFailure) def applicationShouldTerminate_(self, sender): self.status = 'Server shutting down' if reactor.running: reactor.addSystemEventTrigger( 'after', 'shutdown', NSApp().replyToApplicationShouldTerminate_, True) reactor.addSystemEventTrigger( 'after', 'shutdown', AppHelper.stopEventLoop) reactor.stop() return NSTerminateLater return NSTerminateNow def applicationDidFinishLaunching_(self, aNotification): """Create and display a new connection window """ reactor.interleave(AppHelper.callAfter) reactor.callWhenRunning(self.run) if __name__ == "__main__": AppHelper.runEventLoop() |
|
From: Antonio <str...@ti...> - 2007-11-08 16:10:23
|
hi all,
I'm trying to use Twisted Perspective Broker with pyobjc ... the server
run on a Linux server, and the Linux client work very well ...
I don't understand HOW use the deferred and tthe reactor with PyObjC ...
can someone help me or give me a link to a tutorial ?
tanks in advance ...
[CODE]
import objc
from Foundation import *
from AppKit import *
from PyObjCTools import NibClassBuilder, AppHelper
from twisted.spread import pb
from twisted.internet import reactor
from twisted.python import util
NibClassBuilder.extractClasses("MainMenu")
# class defined in MainMenu.nib
class MyObject(NibClassBuilder.AutoBaseClass):
# the actual base class is NSObject
# The following outlets are added to the class:
# ind
# nome
# piva
def init(self):
self = super(MyObject, self).init()
self._factory = pb.PBClientFactory()
reactor.connectTCP("antonio.xxx.nonesisto", 8789,
self._factory)
return self
def salva_(self, sender):
self.nome.setStringValue_("aaa")
def put_string(self, stringa):
print 'io sono put string'
self.ind.setStringValue_(stringa)
def trova_(self, sender):
d = self._factory.getRootObject()
d.addCallback(
lambda object: object.callRemote(
"echo", "hello network"))
d.addCallback(self.put_string)
d.addErrback(lambda reason: 'error: '+str(reason.value))
# debug
#
print d
def applicationDidFinishLaunching_(self, aNotification):
reactor.interleave(AppHelper.callAfter)
reactor.addSystemEventTrigger(
'after', 'shutdown', AppHelper.stopEventLoop)
# ?
#
#reactor.run()
def applicationShouldTerminate_(self, sender):
print
print 'stoppo tutto !'
print
if reactor.running:
reactor.stop()
return False
return True
if __name__ == "__main__":
AppHelper.runEventLoop()
--
#include <stdio.h>
int main(void){char c[]={10,65,110,116,111,110,105,111,32,98,97,114,98,111,110,
101,32,60,104,105,110,100,101,109,105,116,64,116,105,115,99,97,108,105,110,101,
116,46,105,116,62,10,10,0};printf("%s",c);return 0;}
|
|
From: Ben A. <be...@ar...> - 2007-11-08 15:50:49
|
On Nov 8, 2007, at 3:20 AM, Ronald Oussoren wrote: > BTW. The only truly save way to build a Python app bundle that works > on Tiger at the moment is by building all extensions (PyObjC, > wxPython, numpy, ...) on Tiger. Building the actual app bundle can > safely be done on Leopard, but you must extensions (anything that > requires a C compiler) on Tiger. Actually, that's not entirely true; it's only safe to build the app bundle on Leopard if you are building a standalone app. If you build a semi-standalone app, your .py files will be compiled with the Python 2.5 in /System, which the Python 2.3 in Tiger can't run. -- <http://artins.org/ben> "Computers! All they ever think of is hex!" |
|
From: Ronald O. <ron...@ma...> - 2007-11-08 14:44:03
|
I've just cleaned the mailing-list queue and forwarded the non-spam messages that we're still in the queue to the list (the spam messages were just discarded of course). I do want to remind folks that posting to the list is limited to list members, you can easily become a member at https://lists.sourceforge.net/lists/listinfo/pyobjc-dev . Mails from non-members get stuck into a review queue, and I'm not very good at looking after that queue. Ronald |
|
From: Ronald O. <ron...@ma...> - 2007-11-08 14:41:20
|
On 21 Oct, 2007, at 21:27, Samantha Atkins wrote:
> This is probably a newbie question. But it is not at all obvious to
> me after looking at the pyobjc provided examples what a subclass build
> in python of an Objective C class is named after the bundle (I presume
> from docs) is loaded. So I am not sure how to get that class and
> instantiate an instance in Objective C. How is this done? I
> imagine I am missing something obvious.
The class is named just as you named it in python. However, you cannot
use the class name as such in Objective-C because classes that you
define in Python won't exist at link time.
What you can do is something like this:
// The python code that defiines "MyPythonClass" must be loaded by now
Class MyPythonClass = NSClassFromString(@"MyPythonClass");
NSObject* myObject = [MyPythonClass new];
Ronald
>
>
> - s
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a
> browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Pyobjc-dev mailing list
> Pyo...@li...
> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
|
|
From: Ronald O. <ron...@ma...> - 2007-11-08 14:36:32
|
On 20 Oct, 2007, at 15:29, Craig Swank wrote:
> Hello,
> How do you create an instance of a custom objective-c class in
> python? Or instead of that, how about extending a custom objective-
> c class as a python class? I've found a lot of information about
> you can extend, for instance, NSObject, but not a custom class that
> was written by me. Are either one of these possible?
Both are possible. The key issue is getting a reference to your custom
class, after that you can the same mechanisms as for any other class.
To use or subclass your custom class you first have to make sure that
said class is compiled into a bundle (such as a framework or plugin
bundle). When you load that bundle (using the NSBundle API) you can
get a reference to your class using objc.lookUpClass, that is:
import objc
MyClass = objc.lookUpClass("MyClass")
myObject = MyClass.alloc().initWithSprocketCount_(4)
class MyPythonClass (MyClass):
pass
Ronald
>
> Thanks,
>
> Craig Swank
> cra...@fa...
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a
> browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/_______________________________________________
> Pyobjc-dev mailing list
> Pyo...@li...
> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
|
|
From: Ronald O. <ron...@ma...> - 2007-11-08 14:33:09
|
On 25 Oct, 2007, at 2:06, Scotty Delicious wrote:
> Hi PyObjC developers!
>
> I am new to PyObjC (and python) programming in general.
> I am an experienced PHP programmer. I started programming with
> AppleScript (Studio) and moved to Cocoa Objective-C, but Became
> frustrated with and unable to proficiently grasp the concepts of
> Objective-C. I dabbled with Python and Perl and I just love python,
> but I have some noob questions.
>
> I have an Xcode PyObjC project. I created two new Python classes in
> Xcode which are a sub-class of NSObject (one for the model, one
> controller).
>
> In my MainMenu.nib I have a NSTextView inside a NSScrollView and a
> button. What I am trying to do is have text programmatically
> inserted into the NSTextView when the button is pressed (it will get
> the text from a XML-RPC call using xmlrpclib.py). I have
> instantiated the controller class in the nib and tried using
> bindings and creating outlets and using objc.ivar() to access the
> text view.
>
> I am lost, however, in trying to figure out how to insert text into
> the NSTextView.
>
> Any suggestions, tutorials, or links are greatly appreciated.
NSTextViews are very flexible, but as a result are also not the
easiest widget to be working with. It is not too bad though.
You'll have to get the textStorage property of the text view to append
the text to (or insert/replace/remote text).
Something like:
myView = <... some NSTextView ...>
storage = myView.textStorage()
storage.insertAttributedString_atIndex_(
NSAttributedString.alloc().initWithString_(u"Hello world"), 0)
The Objective-C Cocoa documentation is often very usefull to find
information. I also use AppKiDo, which is a tool that provides
convenient access to the documentation from a GUI application.
Ronald
|
|
From: Ronald O. <ron...@ma...> - 2007-11-08 14:24:54
|
On 24 Oct, 2007, at 21:30, Ronaldo Nascimento wrote: > does PyObjC 1.4 work with MacPython 2.5.1 or must 2.4 be installed? > right now i have a clean 10.4 os x with python 2.3 > and i dont want to mess it up with multiple python versions > so i plan to install 2.5.1 and hope pyobjc 1.4 will work with it > > or should i just install PyObjC 1.3.7 installer package for Python 2.3 > on Mac OS X 10.4 PyObjC works just fine with Python 2.5.1, but you'll have to install from source. Ronald > > > thanks > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a > browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
|
From: Ronald O. <ron...@ma...> - 2007-11-08 08:20:14
|
On 8 Nov, 2007, at 9:04, Luc Heinrich wrote: > On 8 nov. 07, at 08:19, Ronald Oussoren wrote: > >> BTW. You do know that Leopard ships with a perfectly fine copy of >> Python 2.5 and PyObjC 2.0? At this point in time it would be easier >> to use that instead of trying to rebuild PyObjC from scratch. > > Unless your PyObjC application needs to run on 10.5 AND 10.4, right ? > I haven't tried it yet, but I wouldn't expect a PyObjC2/py2app > application built on Leopard to run on Tiger as-is. Go read the rest of my message. PyObjC2 requires some additional work to be useful on Tiger. BTW. The only truly save way to build a Python app bundle that works on Tiger at the moment is by building all extensions (PyObjC, wxPython, numpy, ...) on Tiger. Building the actual app bundle can safely be done on Leopard, but you must extensions (anything that requires a C compiler) on Tiger. In theory it should be possible to build extensions on Leopard as well, but AFAIK nobody has fully tested that and you might therefore run into problems when you do that. That said, Python itself is build on a Tiger systems and runs on Panther as well, including all extensions. Ronald |
|
From: Luc H. <lu...@ho...> - 2007-11-08 08:05:05
|
On 8 nov. 07, at 08:19, Ronald Oussoren wrote: > BTW. You do know that Leopard ships with a perfectly fine copy of > Python 2.5 and PyObjC 2.0? At this point in time it would be easier > to use that instead of trying to rebuild PyObjC from scratch. Unless your PyObjC application needs to run on 10.5 AND 10.4, right ? I haven't tried it yet, but I wouldn't expect a PyObjC2/py2app application built on Leopard to run on Tiger as-is. -- Luc Heinrich |
|
From: Ronald O. <ron...@ma...> - 2007-11-08 07:19:43
|
On 8 Nov, 2007, at 7:14, Seungchan Oh wrote: > Hello, > > I'm having a difficulty to install PyObjC2.0 at Leopard with MacBook > Pro. I haven't tried building on 10.4 for a while (which is what you're basicly trying to do because you're using the 10.4 SDK). Appearently there are some issues there. Note that PyObjC 2.0 definitely requires some work to be useful on Tiger systems because Tiger doesn't ship with bridgesupport files and PyObjC 2 requires those files to provide full bindings. Generating bridgesupport files is easy enough, but not a priority for me right now because building them takes a lot of time (for the computer, the task barely requires interaction with a human) and I'm currently thinking about some changes that would require rebuilding the bridgesupport files anyway. BTW. You do know that Leopard ships with a perfectly fine copy of Python 2.5 and PyObjC 2.0? At this point in time it would be easier to use that instead of trying to rebuild PyObjC from scratch. Ronald |
|
From: Seungchan O. <seu...@gm...> - 2007-11-08 06:14:13
|
Hello, I'm having a difficulty to install PyObjC2.0 at Leopard with MacBook Pro. I downloaded the source files from http://svn.red-bean.com/pyobjc/tags/r200-leopard And the command is python setup.py bdist_mpkg --open The part of message is ====================================================== 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 libffi-src/powerpc/ppc-ffi_darwin.c -o build/temp.macosx- 10.3-fat-2.5/libffi-src/powerpc/ppc-ffi_darwin.o -DPyObjC_STRICT_DEBUGGING -DMACOSX -no-cpp-precomp -Wno-long-double -g -O1 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wformat=2 -W -Wshadow -Wpointer-arith -Wmissing-declarations -Wnested-externs -Wno-long-long -Wno-import -I/usr/include/libxml2 -Ibuild/codegen/ -Ilibffi-src/include -Ilibffi-src/powerpc libffi-src/powerpc/ppc-ffi_darwin.c:41:67: error: libkern/OSCacheControl.h: No such file or directory libffi-src/powerpc/ppc-ffi_darwin.c:86: warning: no previous prototype for 'ffi_prep_args' libffi-src/powerpc/ppc-ffi_darwin.c: In function 'ffi_prep_closure': libffi-src/powerpc/ppc-ffi_darwin.c:751: warning: implicit declaration of function 'sys_icache_invalidate' libffi-src/powerpc/ppc-ffi_darwin.c:751: warning: nested extern declaration of 'sys_icache_invalidate' libffi-src/powerpc/ppc-ffi_darwin.c: At top level: libffi-src/powerpc/ppc-ffi_darwin.c:810: warning: no previous prototype for 'ffi_closure_helper_DARWIN' libffi-src/powerpc/ppc-ffi_darwin.c: In function 'ffi_closure_helper_DARWIN': libffi-src/powerpc/ppc-ffi_darwin.c:845: warning: comparison between signed and unsigned libffi-src/powerpc/ppc-ffi_darwin.c:901: warning: pointer of type 'void *' used in arithmetic libffi-src/powerpc/ppc-ffi_darwin.c:901: warning: pointer of type 'void *' used in arithmetic lipo: can't figure out the architecture type of: /var/folders/+w/+wei-YpVFdGoV29uK3G3x++++TI/-Tmp-//ccUuWnhU.out error: command 'gcc' failed with exit status 1 ====================================================== I'm new to the PyObjC. Any comments will help me a lot. Thanks in advance, SC |
|
From: Seungchan O. <seu...@gm...> - 2007-11-08 01:01:20
|
Hello, I'm having a difficulty to install PyObjC2.0 at Leopard with MacBook Pro. I downloaded the source files from http://svn.red-bean.com/pyobjc/tags/r200-leopard And the command is python setup.py bdist_mpkg --open The part of message is ====================================================== 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 libffi-src/powerpc/ppc-ffi_darwin.c -o build/temp.macosx-10.3-fat-2.5/libffi-src/powerpc/ppc-ffi_darwin.o -DPyObjC_STRICT_DEBUGGING -DMACOSX -no-cpp-precomp -Wno-long-double -g -O1 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wformat=2 -W -Wshadow -Wpointer-arith -Wmissing-declarations -Wnested-externs -Wno-long-long -Wno-import -I/usr/include/libxml2 -Ibuild/codegen/ -Ilibffi-src/include -Ilibffi-src/powerpc libffi-src/powerpc/ppc-ffi_darwin.c:41:67: error: libkern/OSCacheControl.h: No such file or directory libffi-src/powerpc/ppc-ffi_darwin.c:86: warning: no previous prototype for 'ffi_prep_args' libffi-src/powerpc/ppc-ffi_darwin.c: In function 'ffi_prep_closure': libffi-src/powerpc/ppc-ffi_darwin.c:751: warning: implicit declaration of function 'sys_icache_invalidate' libffi-src/powerpc/ppc-ffi_darwin.c:751: warning: nested extern declaration of 'sys_icache_invalidate' libffi-src/powerpc/ppc-ffi_darwin.c: At top level: libffi-src/powerpc/ppc-ffi_darwin.c:810: warning: no previous prototype for 'ffi_closure_helper_DARWIN' libffi-src/powerpc/ppc-ffi_darwin.c: In function 'ffi_closure_helper_DARWIN': libffi-src/powerpc/ppc-ffi_darwin.c:845: warning: comparison between signed and unsigned libffi-src/powerpc/ppc-ffi_darwin.c:901: warning: pointer of type 'void *' used in arithmetic libffi-src/powerpc/ppc-ffi_darwin.c:901: warning: pointer of type 'void *' used in arithmetic lipo: can't figure out the architecture type of: /var/folders/+w/+wei-YpVFdGoV29uK3G3x++++TI/-Tmp-//ccUuWnhU.out error: command 'gcc' failed with exit status 1 ====================================================== I'm new to the PyObjC. Any comments will help me a lot. Thanks in advance, SC |
|
From: Ronald O. <ron...@ma...> - 2007-11-07 19:41:36
|
On 7 Nov, 2007, at 19:53, Ronald Oussoren wrote: > > On 7 Nov, 2007, at 19:21, Ben Artin wrote: > >> I filed this bug, but I was accidentally anonymous when I did so. >> >> The circuitous path that got me into this mess is that >> twisted.failure.Failure records exception backtraces, including all >> locals and globals in each frame. When constructing a Failure whose >> stack includes a function in a module that globally imported >> kCFAllocatorUseContext, twisted crashes trying to repr() globals in >> that frame. >> >> PyObjCTools/AppHelper.py has a "from Foundation import *", which >> means >> that anyone using AppHelper.py and twisted dies as soon as they >> fail() >> from under AppHelper. Ouch. > > Ouch indeed. That constant is a magic pointer in ObjC (or rather > plain C), appearently I missed a location where I should treat is > specially. This is now fixed in the pyobjc2 branch (and the bugfix-only pyobjc-20x-branch branch as well) As a workaround you can add some code very early on in your program: import CoreFoundation del CoreFoundation.kCFAllocatorUseContext this should remove the (only) problematic object from traces. Ronald > > > Ronald > >> >> >> Ben >> >> -- >> >> <http://artins.org/ben> >> >> "Computers! All they ever think of is hex!" >> >> >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by: Splunk Inc. >> Still grepping through log files to find problems? Stop. >> Now Search log events and configuration files using AJAX and a >> browser. >> Download your FREE copy of Splunk now >> http://get.splunk.com/ >> _______________________________________________ >> Pyobjc-dev mailing list >> Pyo...@li... >> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a > browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/_______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |