pyobjc-dev Mailing List for PyObjC (Page 14)
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
|
Nov
|
Dec
|
From: Ronald O. <ron...@ma...> - 2013-12-19 12:55:43
|
On 19 Dec 2013, at 13:42, Ronald Oussoren <ron...@ma...> wrote: >>> >> >> Is there something in the nature of pyobjc objects that makes them confuse dockets? > > Not sure if the class repr at the top of the traceback is relevant, but if it is this might be due to doctest trying to test some PyObjC classes. I’ve done some investigation, and this likely is doctest being confused by a bug in PyObjC: some of the types created by PyObjC don’t have a __module__ attribute due to a misunderstanding of the heaptype protocol on my part. I’ll fix this for a future release. Ronald |
From: Ronald O. <ron...@ma...> - 2013-12-19 12:42:24
|
On 07 Dec 2013, at 21:33, Erik van Blokland <er...@le...> wrote: > Hey, > > I have a small problem writing doctests for a module with a NSObject subclass. > Here's a small test: > > from AppKit import * > """ > An odd interaction between doctest and an NSObject subclass. > """ > class MyClass(NSObject): > def __new__(cls, a, b): > self = cls.alloc().init() > self.a = a > self.b = b > return self > > def doSomething(self): > return a+b > > def _test(): > def testOne(): > """ > Test one >>>> m = MyClass(1,1) >>>> m.doSomething() > 2 > """ > import doctest > doctest.testmod() > > _test() > > Here's the result, using Python 2.7.2 (default, Oct 11 2012, 20:14:37) and objc 2.3.2a0. > >> <class 'NSAppleEventManagerSuspensionID'> >> Traceback (most recent call last): >> File "/Users/erik/Desktop/docTestTest.py", line 53, in <module> >> _test() >> File "/Users/erik/Desktop/docTestTest.py", line 51, in _test >> doctest.testmod() >> File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/doctest.py", line 1850, in testmod >> for test in finder.find(m, name, globs=globs, extraglobs=extraglobs): >> File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/doctest.py", line 865, in find >> self._find(tests, obj, name, module, source_lines, globs, {}) >> File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/doctest.py", line 917, in _find >> self._from_module(module, val)): >> File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/doctest.py", line 880, in _from_module >> elif inspect.getmodule(object) is not None: >> File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 486, in getmodule >> file = getabsfile(object, _filename) >> File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 469, in getabsfile >> _filename = getsourcefile(object) or getfile(object) >> File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 447, in getsourcefile >> filename = getfile(object) >> File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 408, in getfile >> object = sys.modules.get(object.__module__) >> AttributeError: __module__ > > Is there something in the nature of pyobjc objects that makes them confuse dockets? Not sure if the class repr at the top of the traceback is relevant, but if it is this might be due to doctest trying to test some PyObjC classes. BTW. I’m moving away from “from AppKit import *” towards just importing what I need. That leads to code that’s slightly easier to check with linting tools, and in recent versions of PyObjC is faster as well because the framework wrappers now try to do as little work as possible (and that doesn’t work when you import everything). Ronald > Thanks! > Erik > ------------------------------------------------------------------------------ > Sponsored by Intel(R) XDK > Develop, test and display web and hybrid apps with a single code base. > Download it for free now! > http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Erik v. B. <er...@le...> - 2013-12-07 20:33:40
|
Hey, I have a small problem writing doctests for a module with a NSObject subclass. Here's a small test: from AppKit import * """ An odd interaction between doctest and an NSObject subclass. """ class MyClass(NSObject): def __new__(cls, a, b): self = cls.alloc().init() self.a = a self.b = b return self def doSomething(self): return a+b def _test(): def testOne(): """ Test one >>> m = MyClass(1,1) >>> m.doSomething() 2 """ import doctest doctest.testmod() _test() Here's the result, using Python 2.7.2 (default, Oct 11 2012, 20:14:37) and objc 2.3.2a0. > <class 'NSAppleEventManagerSuspensionID'> > Traceback (most recent call last): > File "/Users/erik/Desktop/docTestTest.py", line 53, in <module> > _test() > File "/Users/erik/Desktop/docTestTest.py", line 51, in _test > doctest.testmod() > File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/doctest.py", line 1850, in testmod > for test in finder.find(m, name, globs=globs, extraglobs=extraglobs): > File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/doctest.py", line 865, in find > self._find(tests, obj, name, module, source_lines, globs, {}) > File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/doctest.py", line 917, in _find > self._from_module(module, val)): > File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/doctest.py", line 880, in _from_module > elif inspect.getmodule(object) is not None: > File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 486, in getmodule > file = getabsfile(object, _filename) > File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 469, in getabsfile > _filename = getsourcefile(object) or getfile(object) > File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 447, in getsourcefile > filename = getfile(object) > File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 408, in getfile > object = sys.modules.get(object.__module__) > AttributeError: __module__ Is there something in the nature of pyobjc objects that makes them confuse doctest? Thanks! Erik |
From: Jake W. <del...@gm...> - 2013-11-21 13:15:36
|
That's really good to know. Thanks. According to Diez's suggestion, I've already moved to PyQT, which is much better than wx! Every aspects of what I need work very well. On Thu, Nov 21, 2013 at 8:44 PM, Ronald Oussoren <ron...@ma...>wrote: > > On 21 Nov 2013, at 13:37, Jake Wang <del...@gm...> wrote: > > Thank you Ronald, > > I didn't use Objective-C before, and only in a recent project, I realised > that some functions were required to use some Objc code, then I found > PyObjc is a great option. Sorry for the stupid question I posted :) > > > It is not a stupid question at al! The answer is only obvious if you know > how memory management in Objective-C actually works, which is different > from Python’s and furthermore PyObjC tries hard to hide most of the memory > management from Python programmers but that abstraction layer cannot hide > everything (I wish it could…) > > Ronald > > > Anyway, with Diez's and your help, the issue I encountered was resolved, > and I learned it about the NSAutoreleasePool. > > Thanks again! > Jake > > > On Thu, Nov 21, 2013 at 7:34 PM, Ronald Oussoren <ron...@ma...>wrote: > >> >> On 03 Nov 2013, at 12:14, Diez B. Roggisch <de...@we...> wrote: >> >> Hi, >> >> the problem is obvious: you allocate the pool from within the *MAIN* >> thread, not within the run-method of your EventHandlingThread. Thus it's >> essentially useless. >> >> >> That’s obvious if you already know Objective-C :-). For the records >> (and something that I should somehow include in PyObjC’s documentation): an >> NSAutoreleasePool is a fairly magic object that has a global effect for a >> single thread. You must allocate a pool on every thread that uses Cocoa, >> and if you create two nested pools like so: >> >> p1 = NSAutoreleasePool.alloc().init() >> p2 = NSAutoreleasePool.alloc().init() >> >> Then draining (clearing) p1 will also drain p2. That is, >> NSAutoreleasePool objects can (more or less) be seen as markers in a >> per-thread stack of objects and draining a pool calls “release” on all >> objects on the stack upto that marker. >> >> For the most part you don’t have to worry about this, as long as you >> create an regularly drain an autorelease pool on every thread (and you >> don’t even have to do the draining bit if you use a Cocoa event loop in the >> thread) >> >> Ronald >> >> >> >> Diez >> >> On Oct 29, 2013, at 3:03 AM, Jake Wang <del...@gm...> wrote: >> >> Hi Diez, >> >> Thanks for your sample code, which is really helpful. >> >> Please find my sample code as attached. >> >> Entrance script: test_wx_and_event_2.py >> >> Thread 1 - the main thread >> Thread 2 - user_event.EventHandlingThread >> >> It is slightly different, because only the first thread (the main thread) >> has PyObjc code, the second thread just shares an event queue with the >> first thread. >> >> After I added auto release code in the second thread, I got a new error: >> >> objc[1488]: Object 0x10791bf50 of class __NSCFString autoreleased with no >> pool in place - just leaking - break on objc_autoreleaseNoPool() to debug >> >> Also got the system error when quitting the app. >> >> Thanks, >> Jake >> >> >> On Sun, Oct 27, 2013 at 2:45 PM, Diez B. Roggisch <de...@we...> wrote: >> >>> >>> >>> On Oct 27, 2013, at 3:35 AM, Jake Wang <del...@gm...> wrote: >>> >>> Hi Diez, >>> >>> Thanks for your reply and links, I tried some auto release code in the >>> sample code (https://github.com/jiakuan/wx-sample), but still no luck. >>> >>> >>> I don't see it, can you show it to me? >>> >>> >>> >>> I tried to replace the following code: >>> >>> def OnUnexpectedExit(event): >>> # >>> # Event handler that deals with the unexpected close event. >>> # >>> wx.GetApp().ExitMainLoop() >>> >>> to this: >>> >>> def OnUnexpectedExit(self, event): >>> # >>> # Event handler that deals with the unexpected close event. >>> # >>> sys.exit() >>> >>> Then no such error any more. I guess the issue was related to wxPython >>> with PyObjc in some way. >>> >>> >>> I'm not sure if that's a good solution. There are a *lot* of >>> possibilities here, and under normal circumstances, whatever you do in a >>> user-space program shouldn't cause problems for the OS. However, the rather >>> "rude" way of terminating a program you chose here might have just push the >>> problem from your logging output to the system log's output, because some >>> application cleanup hasn't been performed. This is just guessing, but a >>> check couldn't hurt. >>> >>> What you *must* verify though is that the lack of autorelease-pool >>> doesn't introduce garbage over time. >>> >>> I created the attached program to simulate that. You can ignore most of >>> it of course, but if you put a call to "garbage_producer" with e.g. a >>> million bytes as argument into your event handler, you should be able to >>> see in the activity monitor if the process grows in size. >>> >>> If so, you have to use a pool. >>> >>> >>> >>> The reason why we choose PyObjc and wxPython is that we want to use >>> Python language to share the majority of business logic on both Mac OS X >>> and Windows. The platform-dependent requirement is a relative small part, >>> which only contains global events listening, and a system tray icon (this >>> code can be shared on both Mac and Windows too). >>> >>> Any better solutions? >>> >>> >>> Better is relative. I personally would *never* go with wx, as it's not >>> good in looks as well as API. If being cross-platform was justified for me >>> enough (meaning the UI was sophisticated enough so that developing it >>> natively would be a major effort), I'd be using Qt, and one of it's >>> available bindings. >>> >>> Of course, these are matters of taste. I just suggest exploring the >>> alternatives. >>> >>> Diez >>> >>> >> <wx-sample.zip> >> ------------------------------------------------------------------------------ >> Android is increasing in popularity, but the open development platform >> that >> developers love is also attractive to malware creators. Download this >> white >> paper to learn more about secure code signing practices that can help keep >> Android apps secure. >> >> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________ >> Pyobjc-dev mailing list >> Pyo...@li... >> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev >> >> >> >> ------------------------------------------------------------------------------ >> Android is increasing in popularity, but the open development platform >> that >> developers love is also attractive to malware creators. Download this >> white >> paper to learn more about secure code signing practices that can help keep >> Android apps secure. >> >> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________ >> Pyobjc-dev mailing list >> Pyo...@li... >> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev >> >> >> > > |
From: Ronald O. <ron...@ma...> - 2013-11-21 12:44:22
|
On 21 Nov 2013, at 13:37, Jake Wang <del...@gm...> wrote: > Thank you Ronald, > > I didn't use Objective-C before, and only in a recent project, I realised that some functions were required to use some Objc code, then I found PyObjc is a great option. Sorry for the stupid question I posted :) It is not a stupid question at al! The answer is only obvious if you know how memory management in Objective-C actually works, which is different from Python’s and furthermore PyObjC tries hard to hide most of the memory management from Python programmers but that abstraction layer cannot hide everything (I wish it could…) Ronald > > Anyway, with Diez's and your help, the issue I encountered was resolved, and I learned it about the NSAutoreleasePool. > > Thanks again! > Jake > > > On Thu, Nov 21, 2013 at 7:34 PM, Ronald Oussoren <ron...@ma...> wrote: > > On 03 Nov 2013, at 12:14, Diez B. Roggisch <de...@we...> wrote: > >> Hi, >> >> the problem is obvious: you allocate the pool from within the *MAIN* thread, not within the run-method of your EventHandlingThread. Thus it's essentially useless. > > That’s obvious if you already know Objective-C :-). For the records (and something that I should somehow include in PyObjC’s documentation): an NSAutoreleasePool is a fairly magic object that has a global effect for a single thread. You must allocate a pool on every thread that uses Cocoa, and if you create two nested pools like so: > > p1 = NSAutoreleasePool.alloc().init() > p2 = NSAutoreleasePool.alloc().init() > > Then draining (clearing) p1 will also drain p2. That is, NSAutoreleasePool objects can (more or less) be seen as markers in a per-thread stack of objects and draining a pool calls “release” on all objects on the stack upto that marker. > > For the most part you don’t have to worry about this, as long as you create an regularly drain an autorelease pool on every thread (and you don’t even have to do the draining bit if you use a Cocoa event loop in the thread) > > Ronald > >> >> Diez >> >> On Oct 29, 2013, at 3:03 AM, Jake Wang <del...@gm...> wrote: >> >>> Hi Diez, >>> >>> Thanks for your sample code, which is really helpful. >>> >>> Please find my sample code as attached. >>> >>> Entrance script: test_wx_and_event_2.py >>> >>> Thread 1 - the main thread >>> Thread 2 - user_event.EventHandlingThread >>> >>> It is slightly different, because only the first thread (the main thread) has PyObjc code, the second thread just shares an event queue with the first thread. >>> >>> After I added auto release code in the second thread, I got a new error: >>> >>> objc[1488]: Object 0x10791bf50 of class __NSCFString autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug >>> >>> Also got the system error when quitting the app. >>> >>> Thanks, >>> Jake >>> >>> >>> On Sun, Oct 27, 2013 at 2:45 PM, Diez B. Roggisch <de...@we...> wrote: >>> >>> >>> On Oct 27, 2013, at 3:35 AM, Jake Wang <del...@gm...> wrote: >>> >>>> Hi Diez, >>>> >>>> Thanks for your reply and links, I tried some auto release code in the sample code (https://github.com/jiakuan/wx-sample), but still no luck. >>> >>> I don't see it, can you show it to me? >>> >>> >>>> >>>> I tried to replace the following code: >>>> >>>> def OnUnexpectedExit(event): >>>> # >>>> # Event handler that deals with the unexpected close event. >>>> # >>>> wx.GetApp().ExitMainLoop() >>>> >>>> to this: >>>> >>>> def OnUnexpectedExit(self, event): >>>> # >>>> # Event handler that deals with the unexpected close event. >>>> # >>>> sys.exit() >>>> >>>> Then no such error any more. I guess the issue was related to wxPython with PyObjc in some way. >>> >>> I'm not sure if that's a good solution. There are a *lot* of possibilities here, and under normal circumstances, whatever you do in a user-space program shouldn't cause problems for the OS. However, the rather "rude" way of terminating a program you chose here might have just push the problem from your logging output to the system log's output, because some application cleanup hasn't been performed. This is just guessing, but a check couldn't hurt. >>> >>> What you *must* verify though is that the lack of autorelease-pool doesn't introduce garbage over time. >>> >>> I created the attached program to simulate that. You can ignore most of it of course, but if you put a call to "garbage_producer" with e.g. a million bytes as argument into your event handler, you should be able to see in the activity monitor if the process grows in size. >>> >>> If so, you have to use a pool. >>> >>> >>>> >>>> The reason why we choose PyObjc and wxPython is that we want to use Python language to share the majority of business logic on both Mac OS X and Windows. The platform-dependent requirement is a relative small part, which only contains global events listening, and a system tray icon (this code can be shared on both Mac and Windows too). >>>> >>>> Any better solutions? >>> >>> Better is relative. I personally would *never* go with wx, as it's not good in looks as well as API. If being cross-platform was justified for me enough (meaning the UI was sophisticated enough so that developing it natively would be a major effort), I'd be using Qt, and one of it's available bindings. >>> >>> Of course, these are matters of taste. I just suggest exploring the alternatives. >>> >>> Diez >>> >>> >>> <wx-sample.zip>------------------------------------------------------------------------------ >>> Android is increasing in popularity, but the open development platform that >>> developers love is also attractive to malware creators. Download this white >>> paper to learn more about secure code signing practices that can help keep >>> Android apps secure. >>> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________ >>> Pyobjc-dev mailing list >>> Pyo...@li... >>> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev >> >> ------------------------------------------------------------------------------ >> Android is increasing in popularity, but the open development platform that >> developers love is also attractive to malware creators. Download this white >> paper to learn more about secure code signing practices that can help keep >> Android apps secure. >> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________ >> Pyobjc-dev mailing list >> Pyo...@li... >> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > |
From: Jake W. <del...@gm...> - 2013-11-21 12:37:56
|
Thank you Ronald, I didn't use Objective-C before, and only in a recent project, I realised that some functions were required to use some Objc code, then I found PyObjc is a great option. Sorry for the stupid question I posted :) Anyway, with Diez's and your help, the issue I encountered was resolved, and I learned it about the NSAutoreleasePool. Thanks again! Jake On Thu, Nov 21, 2013 at 7:34 PM, Ronald Oussoren <ron...@ma...>wrote: > > On 03 Nov 2013, at 12:14, Diez B. Roggisch <de...@we...> wrote: > > Hi, > > the problem is obvious: you allocate the pool from within the *MAIN* > thread, not within the run-method of your EventHandlingThread. Thus it's > essentially useless. > > > That’s obvious if you already know Objective-C :-). For the records > (and something that I should somehow include in PyObjC’s documentation): an > NSAutoreleasePool is a fairly magic object that has a global effect for a > single thread. You must allocate a pool on every thread that uses Cocoa, > and if you create two nested pools like so: > > p1 = NSAutoreleasePool.alloc().init() > p2 = NSAutoreleasePool.alloc().init() > > Then draining (clearing) p1 will also drain p2. That is, > NSAutoreleasePool objects can (more or less) be seen as markers in a > per-thread stack of objects and draining a pool calls “release” on all > objects on the stack upto that marker. > > For the most part you don’t have to worry about this, as long as you > create an regularly drain an autorelease pool on every thread (and you > don’t even have to do the draining bit if you use a Cocoa event loop in the > thread) > > Ronald > > > > Diez > > On Oct 29, 2013, at 3:03 AM, Jake Wang <del...@gm...> wrote: > > Hi Diez, > > Thanks for your sample code, which is really helpful. > > Please find my sample code as attached. > > Entrance script: test_wx_and_event_2.py > > Thread 1 - the main thread > Thread 2 - user_event.EventHandlingThread > > It is slightly different, because only the first thread (the main thread) > has PyObjc code, the second thread just shares an event queue with the > first thread. > > After I added auto release code in the second thread, I got a new error: > > objc[1488]: Object 0x10791bf50 of class __NSCFString autoreleased with no > pool in place - just leaking - break on objc_autoreleaseNoPool() to debug > > Also got the system error when quitting the app. > > Thanks, > Jake > > > On Sun, Oct 27, 2013 at 2:45 PM, Diez B. Roggisch <de...@we...> wrote: > >> >> >> On Oct 27, 2013, at 3:35 AM, Jake Wang <del...@gm...> wrote: >> >> Hi Diez, >> >> Thanks for your reply and links, I tried some auto release code in the >> sample code (https://github.com/jiakuan/wx-sample), but still no luck. >> >> >> I don't see it, can you show it to me? >> >> >> >> I tried to replace the following code: >> >> def OnUnexpectedExit(event): >> # >> # Event handler that deals with the unexpected close event. >> # >> wx.GetApp().ExitMainLoop() >> >> to this: >> >> def OnUnexpectedExit(self, event): >> # >> # Event handler that deals with the unexpected close event. >> # >> sys.exit() >> >> Then no such error any more. I guess the issue was related to wxPython >> with PyObjc in some way. >> >> >> I'm not sure if that's a good solution. There are a *lot* of >> possibilities here, and under normal circumstances, whatever you do in a >> user-space program shouldn't cause problems for the OS. However, the rather >> "rude" way of terminating a program you chose here might have just push the >> problem from your logging output to the system log's output, because some >> application cleanup hasn't been performed. This is just guessing, but a >> check couldn't hurt. >> >> What you *must* verify though is that the lack of autorelease-pool >> doesn't introduce garbage over time. >> >> I created the attached program to simulate that. You can ignore most of >> it of course, but if you put a call to "garbage_producer" with e.g. a >> million bytes as argument into your event handler, you should be able to >> see in the activity monitor if the process grows in size. >> >> If so, you have to use a pool. >> >> >> >> The reason why we choose PyObjc and wxPython is that we want to use >> Python language to share the majority of business logic on both Mac OS X >> and Windows. The platform-dependent requirement is a relative small part, >> which only contains global events listening, and a system tray icon (this >> code can be shared on both Mac and Windows too). >> >> Any better solutions? >> >> >> Better is relative. I personally would *never* go with wx, as it's not >> good in looks as well as API. If being cross-platform was justified for me >> enough (meaning the UI was sophisticated enough so that developing it >> natively would be a major effort), I'd be using Qt, and one of it's >> available bindings. >> >> Of course, these are matters of taste. I just suggest exploring the >> alternatives. >> >> Diez >> >> > <wx-sample.zip> > ------------------------------------------------------------------------------ > Android is increasing in popularity, but the open development platform that > developers love is also attractive to malware creators. Download this white > paper to learn more about secure code signing practices that can help keep > Android apps secure. > > http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > > > ------------------------------------------------------------------------------ > Android is increasing in popularity, but the open development platform that > developers love is also attractive to malware creators. Download this white > paper to learn more about secure code signing practices that can help keep > Android apps secure. > > http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > > |
From: Ronald O. <ron...@ma...> - 2013-11-21 11:35:22
|
On 03 Nov 2013, at 12:14, Diez B. Roggisch <de...@we...> wrote: > Hi, > > the problem is obvious: you allocate the pool from within the *MAIN* thread, not within the run-method of your EventHandlingThread. Thus it's essentially useless. That’s obvious if you already know Objective-C :-). For the records (and something that I should somehow include in PyObjC’s documentation): an NSAutoreleasePool is a fairly magic object that has a global effect for a single thread. You must allocate a pool on every thread that uses Cocoa, and if you create two nested pools like so: p1 = NSAutoreleasePool.alloc().init() p2 = NSAutoreleasePool.alloc().init() Then draining (clearing) p1 will also drain p2. That is, NSAutoreleasePool objects can (more or less) be seen as markers in a per-thread stack of objects and draining a pool calls “release” on all objects on the stack upto that marker. For the most part you don’t have to worry about this, as long as you create an regularly drain an autorelease pool on every thread (and you don’t even have to do the draining bit if you use a Cocoa event loop in the thread) Ronald > > Diez > > On Oct 29, 2013, at 3:03 AM, Jake Wang <del...@gm...> wrote: > >> Hi Diez, >> >> Thanks for your sample code, which is really helpful. >> >> Please find my sample code as attached. >> >> Entrance script: test_wx_and_event_2.py >> >> Thread 1 - the main thread >> Thread 2 - user_event.EventHandlingThread >> >> It is slightly different, because only the first thread (the main thread) has PyObjc code, the second thread just shares an event queue with the first thread. >> >> After I added auto release code in the second thread, I got a new error: >> >> objc[1488]: Object 0x10791bf50 of class __NSCFString autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug >> >> Also got the system error when quitting the app. >> >> Thanks, >> Jake >> >> >> On Sun, Oct 27, 2013 at 2:45 PM, Diez B. Roggisch <de...@we...> wrote: >> >> >> On Oct 27, 2013, at 3:35 AM, Jake Wang <del...@gm...> wrote: >> >>> Hi Diez, >>> >>> Thanks for your reply and links, I tried some auto release code in the sample code (https://github.com/jiakuan/wx-sample), but still no luck. >> >> I don't see it, can you show it to me? >> >> >>> >>> I tried to replace the following code: >>> >>> def OnUnexpectedExit(event): >>> # >>> # Event handler that deals with the unexpected close event. >>> # >>> wx.GetApp().ExitMainLoop() >>> >>> to this: >>> >>> def OnUnexpectedExit(self, event): >>> # >>> # Event handler that deals with the unexpected close event. >>> # >>> sys.exit() >>> >>> Then no such error any more. I guess the issue was related to wxPython with PyObjc in some way. >> >> I'm not sure if that's a good solution. There are a *lot* of possibilities here, and under normal circumstances, whatever you do in a user-space program shouldn't cause problems for the OS. However, the rather "rude" way of terminating a program you chose here might have just push the problem from your logging output to the system log's output, because some application cleanup hasn't been performed. This is just guessing, but a check couldn't hurt. >> >> What you *must* verify though is that the lack of autorelease-pool doesn't introduce garbage over time. >> >> I created the attached program to simulate that. You can ignore most of it of course, but if you put a call to "garbage_producer" with e.g. a million bytes as argument into your event handler, you should be able to see in the activity monitor if the process grows in size. >> >> If so, you have to use a pool. >> >> >>> >>> The reason why we choose PyObjc and wxPython is that we want to use Python language to share the majority of business logic on both Mac OS X and Windows. The platform-dependent requirement is a relative small part, which only contains global events listening, and a system tray icon (this code can be shared on both Mac and Windows too). >>> >>> Any better solutions? >> >> Better is relative. I personally would *never* go with wx, as it's not good in looks as well as API. If being cross-platform was justified for me enough (meaning the UI was sophisticated enough so that developing it natively would be a major effort), I'd be using Qt, and one of it's available bindings. >> >> Of course, these are matters of taste. I just suggest exploring the alternatives. >> >> Diez >> >> >> <wx-sample.zip>------------------------------------------------------------------------------ >> Android is increasing in popularity, but the open development platform that >> developers love is also attractive to malware creators. Download this white >> paper to learn more about secure code signing practices that can help keep >> Android apps secure. >> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________ >> Pyobjc-dev mailing list >> Pyo...@li... >> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > ------------------------------------------------------------------------------ > Android is increasing in popularity, but the open development platform that > developers love is also attractive to malware creators. Download this white > paper to learn more about secure code signing practices that can help keep > Android apps secure. > http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Burak N. <bu...@ne...> - 2013-11-09 21:34:25
|
…. Thank you. I’m speechless. I have been fighting with this issue since the last 30-ish hours, and have just thrown the towel a few hours ago. Best, Burak On November 9, 2013 at 3:52:48 PM, Robert Klep (rob...@gm...) wrote: Hi Burak, The signature of that specific method is different: applicationShouldHandleReopen:hasVisibleWindows: Sent by the application to the delegate prior to default behavior to reopen (rapp) AppleEvents. - (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag (full documentation here) Here's a minimal example that works for me: #!/usr/bin/env python from AppKit import NSObject, NSApplication from Foundation import NSLog import objc class TestApp(NSObject): @objc.signature('B@:#B') def applicationShouldHandleReopen_hasVisibleWindows_(self, app, flag): NSLog('Hello!') return True def applicationDidFinishLaunching_(self, notification): NSLog('App running') if __name__ == '__main__': sharedapp = NSApplication.sharedApplication() testapp = TestApp.alloc().init() sharedapp.setDelegate_(testapp) sharedapp.run() Regards, Robert Burak Nehbit <bu...@ne...> wrote on Sat Nov 09 2013 at 20:45:40: (Sorry for the double post, my mail client glitched—this is the full one.) Hi there, I am building a Qt application called Aether (www.getaether.net). For its Mac version, I have run into the problem of Qt not being able to detect and raise events to Mac’s dock icon clicks. This is an essential and widely used feature on OS X that is completely ignored by Qt, and I want to provide my users this functionality. I have found a way to do this on C++ here: http://aksenkin.blogspot.com/2012/02/how-to-handle-click-on-app-icon-in-mac.html I am using Python, so I need to accomplish it using PyObjC. I have written the following piece of code so far: @objc.signature('B@:') def applicationShouldHandleReopen_hasVisibleWindows_(self, sender): print('hello!') app.onClickOnDock() return True cls = objc.lookUpClass('NSApplication') appInstance = cls.sharedApplication # I'm doing some real crazy runtime shit there. #print(cls, appInstance) delegate = appInstance.definingClass.delegate delClass = delegate.definingClass objc.classAddMethods(cls, [applicationShouldHandleReopen_hasVisibleWindows_]) But this has no effect. No method gets triggered, nothing happens. I have little to no C++ knowledge, so I am probably missing a nuance in the translation. Can anyone point me in the right direction? Regards, Burak ------------------------------------------------------------------------------ November Webinars for C, C++, Fortran Developers Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk_______________________________________________ Pyobjc-dev mailing list Pyo...@li... https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Robert K. <rob...@gm...> - 2013-11-09 20:52:23
|
Hi Burak, The signature of that specific method is different: applicationShouldHandleReopen:hasVisibleWindows: Sent by the application to the delegate prior to default behavior to reopen (rapp) AppleEvents. - (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag (full documentation here) Here's a minimal example that works for me: #!/usr/bin/env python from AppKit import NSObject, NSApplication from Foundation import NSLog import objc class TestApp(NSObject): @objc.signature('B@:#B') def applicationShouldHandleReopen_hasVisibleWindows_(self, app, flag): NSLog('Hello!') return True def applicationDidFinishLaunching_(self, notification): NSLog('App running') if __name__ == '__main__': sharedapp = NSApplication.sharedApplication() testapp = TestApp.alloc().init() sharedapp.setDelegate_(testapp) sharedapp.run() Regards, Robert Burak Nehbit <bu...@ne...> wrote on Sat Nov 09 2013 at 20:45:40: > (Sorry for the double post, my mail client glitched—this is the full one.) > > Hi there, > > I am building a Qt application called Aether (www.getaether.net). > > For its Mac version, I have run into the problem of Qt not being able to detect and raise events to Mac’s dock icon clicks. This is an essential and widely used feature on OS X that is completely ignored by Qt, and I want to provide my users this functionality. > > I have found a way to do this on C++ here: > http://aksenkin.blogspot.com/2012/02/how-to-handle-click-on-app-icon-in-mac.html > > I am using Python, so I need to accomplish it using PyObjC. I have written the following piece of code so far: > > @objc.signature('B@:') > def applicationShouldHandleReopen_hasVisibleWindows_(self, sender): > print('hello!') > app.onClickOnDock() > return True > > cls = objc.lookUpClass('NSApplication') > appInstance = cls.sharedApplication # I'm doing some real crazy runtime shit there. > #print(cls, appInstance) > delegate = appInstance.definingClass.delegate > delClass = delegate.definingClass > objc.classAddMethods(cls, [applicationShouldHandleReopen_hasVisibleWindows_]) > > But this has no effect. No method gets triggered, nothing happens. I have little to no C++ knowledge, so I am probably missing a nuance in the translation. Can anyone point me in the right direction? > > Regards, > Burak > |
From: Burak N. <bu...@ne...> - 2013-11-09 19:44:58
|
(Sorry for the double post, my mail client glitched—this is the full one.) Hi there, I am building a Qt application called Aether (www.getaether.net). For its Mac version, I have run into the problem of Qt not being able to detect and raise events to Mac’s dock icon clicks. This is an essential and widely used feature on OS X that is completely ignored by Qt, and I want to provide my users this functionality. I have found a way to do this on C++ here: http://aksenkin.blogspot.com/2012/02/how-to-handle-click-on-app-icon-in-mac.html I am using Python, so I need to accomplish it using PyObjC. I have written the following piece of code so far: @objc.signature('B@:') def applicationShouldHandleReopen_hasVisibleWindows_(self, sender): print('hello!') app.onClickOnDock() return True cls = objc.lookUpClass('NSApplication') appInstance = cls.sharedApplication # I'm doing some real crazy runtime shit there. #print(cls, appInstance) delegate = appInstance.definingClass.delegate delClass = delegate.definingClass objc.classAddMethods(cls, [applicationShouldHandleReopen_hasVisibleWindows_]) But this has no effect. No method gets triggered, nothing happens. I have little to no C++ knowledge, so I am probably missing a nuance in the translation. Can anyone point me in the right direction? Regards, Burak |
From: Burak N. <bu...@ne...> - 2013-11-09 19:39:58
|
Hi there, I am building a Qt application called Aether (www.getaether.net). For its Mac version, I have run into the problem of Qt not being able to detect and raise events to Mac’s dock icon clicks. This is an essential and widely used feature on OS X that is completely ignored by Qt, and I want to provide my users this functionality. I have found a way to do this on C++ here: http://aksenkin.blogspot.com/2012/02/how-to-handle-click-on-app-icon-in-mac.html |
From: Jake W. <del...@gm...> - 2013-11-03 12:46:12
|
Thank you so much Diez! That resolved it! (I didn't know much about Objc and just use it by quick search and learning.) I found some wx bugs, which really are headaches. For example, in html2.WebView, common shortcuts didn't work (Cmd+V to paste, Cmd+A to select all etc). I resolved them by hacking methods, which will be a maintenance issue. After you suggested to have a look at alternatives, I checked QT, which looks much maturer. And I'm going to switch to PyQT4 for the UI parts. Thanks again, Jake On Sun, Nov 3, 2013 at 7:14 PM, Diez B. Roggisch <de...@we...> wrote: > Hi, > > the problem is obvious: you allocate the pool from within the *MAIN* > thread, not within the run-method of your EventHandlingThread. Thus it's > essentially useless. > > Diez > > On Oct 29, 2013, at 3:03 AM, Jake Wang <del...@gm...> wrote: > > Hi Diez, > > Thanks for your sample code, which is really helpful. > > Please find my sample code as attached. > > Entrance script: test_wx_and_event_2.py > > Thread 1 - the main thread > Thread 2 - user_event.EventHandlingThread > > It is slightly different, because only the first thread (the main thread) > has PyObjc code, the second thread just shares an event queue with the > first thread. > > After I added auto release code in the second thread, I got a new error: > > objc[1488]: Object 0x10791bf50 of class __NSCFString autoreleased with no > pool in place - just leaking - break on objc_autoreleaseNoPool() to debug > > Also got the system error when quitting the app. > > Thanks, > Jake > > > On Sun, Oct 27, 2013 at 2:45 PM, Diez B. Roggisch <de...@we...> wrote: > >> >> >> On Oct 27, 2013, at 3:35 AM, Jake Wang <del...@gm...> wrote: >> >> Hi Diez, >> >> Thanks for your reply and links, I tried some auto release code in the >> sample code (https://github.com/jiakuan/wx-sample), but still no luck. >> >> >> I don't see it, can you show it to me? >> >> >> >> I tried to replace the following code: >> >> def OnUnexpectedExit(event): >> # >> # Event handler that deals with the unexpected close event. >> # >> wx.GetApp().ExitMainLoop() >> >> to this: >> >> def OnUnexpectedExit(self, event): >> # >> # Event handler that deals with the unexpected close event. >> # >> sys.exit() >> >> Then no such error any more. I guess the issue was related to wxPython >> with PyObjc in some way. >> >> >> I'm not sure if that's a good solution. There are a *lot* of >> possibilities here, and under normal circumstances, whatever you do in a >> user-space program shouldn't cause problems for the OS. However, the rather >> "rude" way of terminating a program you chose here might have just push the >> problem from your logging output to the system log's output, because some >> application cleanup hasn't been performed. This is just guessing, but a >> check couldn't hurt. >> >> What you *must* verify though is that the lack of autorelease-pool >> doesn't introduce garbage over time. >> >> I created the attached program to simulate that. You can ignore most of >> it of course, but if you put a call to "garbage_producer" with e.g. a >> million bytes as argument into your event handler, you should be able to >> see in the activity monitor if the process grows in size. >> >> If so, you have to use a pool. >> >> >> >> The reason why we choose PyObjc and wxPython is that we want to use >> Python language to share the majority of business logic on both Mac OS X >> and Windows. The platform-dependent requirement is a relative small part, >> which only contains global events listening, and a system tray icon (this >> code can be shared on both Mac and Windows too). >> >> Any better solutions? >> >> >> Better is relative. I personally would *never* go with wx, as it's not >> good in looks as well as API. If being cross-platform was justified for me >> enough (meaning the UI was sophisticated enough so that developing it >> natively would be a major effort), I'd be using Qt, and one of it's >> available bindings. >> >> Of course, these are matters of taste. I just suggest exploring the >> alternatives. >> >> Diez >> >> > <wx-sample.zip> > ------------------------------------------------------------------------------ > Android is increasing in popularity, but the open development platform that > developers love is also attractive to malware creators. Download this white > paper to learn more about secure code signing practices that can help keep > Android apps secure. > > http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________ > > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > > |
From: Diez B. R. <de...@we...> - 2013-11-03 11:14:43
|
Hi, the problem is obvious: you allocate the pool from within the *MAIN* thread, not within the run-method of your EventHandlingThread. Thus it's essentially useless. Diez On Oct 29, 2013, at 3:03 AM, Jake Wang <del...@gm...> wrote: > Hi Diez, > > Thanks for your sample code, which is really helpful. > > Please find my sample code as attached. > > Entrance script: test_wx_and_event_2.py > > Thread 1 - the main thread > Thread 2 - user_event.EventHandlingThread > > It is slightly different, because only the first thread (the main thread) has PyObjc code, the second thread just shares an event queue with the first thread. > > After I added auto release code in the second thread, I got a new error: > > objc[1488]: Object 0x10791bf50 of class __NSCFString autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug > > Also got the system error when quitting the app. > > Thanks, > Jake > > > On Sun, Oct 27, 2013 at 2:45 PM, Diez B. Roggisch <de...@we...> wrote: > > > On Oct 27, 2013, at 3:35 AM, Jake Wang <del...@gm...> wrote: > >> Hi Diez, >> >> Thanks for your reply and links, I tried some auto release code in the sample code (https://github.com/jiakuan/wx-sample), but still no luck. > > I don't see it, can you show it to me? > > >> >> I tried to replace the following code: >> >> def OnUnexpectedExit(event): >> # >> # Event handler that deals with the unexpected close event. >> # >> wx.GetApp().ExitMainLoop() >> >> to this: >> >> def OnUnexpectedExit(self, event): >> # >> # Event handler that deals with the unexpected close event. >> # >> sys.exit() >> >> Then no such error any more. I guess the issue was related to wxPython with PyObjc in some way. > > I'm not sure if that's a good solution. There are a *lot* of possibilities here, and under normal circumstances, whatever you do in a user-space program shouldn't cause problems for the OS. However, the rather "rude" way of terminating a program you chose here might have just push the problem from your logging output to the system log's output, because some application cleanup hasn't been performed. This is just guessing, but a check couldn't hurt. > > What you *must* verify though is that the lack of autorelease-pool doesn't introduce garbage over time. > > I created the attached program to simulate that. You can ignore most of it of course, but if you put a call to "garbage_producer" with e.g. a million bytes as argument into your event handler, you should be able to see in the activity monitor if the process grows in size. > > If so, you have to use a pool. > > >> >> The reason why we choose PyObjc and wxPython is that we want to use Python language to share the majority of business logic on both Mac OS X and Windows. The platform-dependent requirement is a relative small part, which only contains global events listening, and a system tray icon (this code can be shared on both Mac and Windows too). >> >> Any better solutions? > > Better is relative. I personally would *never* go with wx, as it's not good in looks as well as API. If being cross-platform was justified for me enough (meaning the UI was sophisticated enough so that developing it natively would be a major effort), I'd be using Qt, and one of it's available bindings. > > Of course, these are matters of taste. I just suggest exploring the alternatives. > > Diez > > > <wx-sample.zip>------------------------------------------------------------------------------ > Android is increasing in popularity, but the open development platform that > developers love is also attractive to malware creators. Download this white > paper to learn more about secure code signing practices that can help keep > Android apps secure. > http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Diez B. R. <de...@we...> - 2013-10-27 06:45:44
|
On Oct 27, 2013, at 3:35 AM, Jake Wang <del...@gm...> wrote: > Hi Diez, > > Thanks for your reply and links, I tried some auto release code in the sample code (https://github.com/jiakuan/wx-sample), but still no luck. I don't see it, can you show it to me? > > I tried to replace the following code: > > def OnUnexpectedExit(event): > # > # Event handler that deals with the unexpected close event. > # > wx.GetApp().ExitMainLoop() > > to this: > > def OnUnexpectedExit(self, event): > # > # Event handler that deals with the unexpected close event. > # > sys.exit() > > Then no such error any more. I guess the issue was related to wxPython with PyObjc in some way. I'm not sure if that's a good solution. There are a *lot* of possibilities here, and under normal circumstances, whatever you do in a user-space program shouldn't cause problems for the OS. However, the rather "rude" way of terminating a program you chose here might have just push the problem from your logging output to the system log's output, because some application cleanup hasn't been performed. This is just guessing, but a check couldn't hurt. What you *must* verify though is that the lack of autorelease-pool doesn't introduce garbage over time. I created the attached program to simulate that. You can ignore most of it of course, but if you put a call to "garbage_producer" with e.g. a million bytes as argument into your event handler, you should be able to see in the activity monitor if the process grows in size. If so, you have to use a pool. > > The reason why we choose PyObjc and wxPython is that we want to use Python language to share the majority of business logic on both Mac OS X and Windows. The platform-dependent requirement is a relative small part, which only contains global events listening, and a system tray icon (this code can be shared on both Mac and Windows too). > > Any better solutions? Better is relative. I personally would *never* go with wx, as it's not good in looks as well as API. If being cross-platform was justified for me enough (meaning the UI was sophisticated enough so that developing it natively would be a major effort), I'd be using Qt, and one of it's available bindings. Of course, these are matters of taste. I just suggest exploring the alternatives. Diez |
From: Jake W. <del...@gm...> - 2013-10-27 00:35:53
|
Hi Diez, Thanks for your reply and links, I tried some auto release code in the sample code (https://github.com/jiakuan/wx-sample), but still no luck. I tried to replace the following code: def OnUnexpectedExit(event): # # Event handler that deals with the unexpected close event. # wx.GetApp().ExitMainLoop() to this: def OnUnexpectedExit(self, event): # # Event handler that deals with the unexpected close event. # sys.exit() Then no such error any more. I guess the issue was related to wxPython with PyObjc in some way. The reason why we choose PyObjc and wxPython is that we want to use Python language to share the majority of business logic on both Mac OS X and Windows. The platform-dependent requirement is a relative small part, which only contains global events listening, and a system tray icon (this code can be shared on both Mac and Windows too). Any better solutions? Thanks, Jake On Sun, Oct 27, 2013 at 3:03 AM, Diez B. Roggisch <de...@we...> wrote: > Hi, > > just to rule out the obvious - you are aware of this? > > > https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSAutoreleasePool_Class/Reference/Reference.html#//apple_ref/doc/uid/20000051-SW6 > > And of course this: > > http://pythonhosted.org/pyobjc/core/intro.html?highlight=nsautoreleasepool > > Also, there seems to be a workaround: > > http://stackoverflow.com/questions/16453026/pyobjc-autorelease-pool > > Last, but not least: why on earth WX-python? It's ugly both API and > UI-wise, as it essentially looks like Windows - everywhere. Of course > that's your choice, but on OS X, people easily are alienated by non-native > looking apps. Just a suggestion :) > > Diez > > On Oct 24, 2013, at 5:01 PM, Jake Wang <del...@gm...> wrote: > > Sorry, for the screenshot of the system error dialog, I included in this > post: > http://stackoverflow.com/questions/19520078/wxpython-with-pyobjc-autorelease-pool-page-corrupted > > > On Thu, Oct 24, 2013 at 9:52 PM, Jake Wang <del...@gm...> wrote: > >> Hi Ronald, >> >> Thanks for your response! You reply only arrived once, so no worries :) >> >> I've arranged a small app to reproduce this issue. Please see the source >> code from this link: https://github.com/jiakuan/wx-sample >> >> *New findings* >> >> While preparing the small app, I found that the issue might be related to >> two event binds together with a multiple-thread environment: >> >> app.Bind(wx.EVT_QUERY_END_SESSION, OnUnexpectedExit) >> app.Bind(wx.EVT_END_SESSION, OnUnexpectedExit) >> >> *Sample project description* >> >> Test 1: From the sample project, please run *test_wx_and_event_1.py*, >> you will see a taskbar icon. When you click the taskbar icon and select >> "Close wxPython Sample", the app quit correctly without any issues. >> >> Test 2: From the sample project, please run *test_wx_and_event_2.py*, >> you will also see a taskbar icon. When you click the taskbar icon and >> select "Close wxPython Sample", the app quit with a system dialog as the >> same as the one I attached in my previous post, and an error message will >> be printed in console like the following: >> >> objc[9303]: autorelease pool page 0x103889000 corrupted >> magic 0x1038a800 0x70000000 0x1039c000 0x50000000 >> pthread 0x7fff79c40180 >> >> If we comment two lines (line 145 and 146) in test_wx_and_event_2.py >> >> # self.Bind(wx.EVT_QUERY_END_SESSION, self.OnUnexpectedExit) >> # self.Bind(wx.EVT_END_SESSION, self.OnUnexpectedExit) >> >> then no such error when quitting app from the taskbar menu. >> >> The only difference between test_wx_and_event_1.py >> and test_wx_and_event_2.py is that the second one used a new thread to >> maintain an event queue. >> >> And the issue in test 2 only happened in wxPython 2.9.5.0, no such issues >> for wxPython 2.9.4.0. >> >> Really appreciate your help on this issue. >> >> Thanks, >> Jake >> >> >> >> On Thu, Oct 24, 2013 at 7:55 PM, Ronald Oussoren <ron...@ma...>wrote: >> >>> >>> On 22 Oct, 2013, at 15:49, Jake Wang <del...@gm...> wrote: >>> >>> > Hi, >>> > >>> > I used PyObjc in a python application for monitoring some global >>> events: >>> > >>> > class MacOSXEventMonitor(): >>> > def init(self): >>> > log.debug("Initializing events monitor for Mac OS X...") >>> > >>> > self._observer = >>> NSEvent.addGlobalMonitorForEventsMatchingMask_handler_( >>> > NSLeftMouseDownMask >>> > | NSLeftMouseUpMask >>> > | NSRightMouseDownMask >>> > | NSRightMouseUpMask >>> > | NSMouseMovedMask >>> > | NSLeftMouseDraggedMask >>> > | NSRightMouseDraggedMask >>> > | NSMouseEnteredMask >>> > | NSMouseExitedMask >>> > | NSScrollWheelMask >>> > | NSKeyDownMask >>> > | NSKeyUpMask >>> > | NSAlphaShiftKeyMask >>> > | NSShiftKeyMask >>> > | NSControlKeyMask >>> > | NSAlternateKeyMask >>> > | NSCommandKeyMask >>> > | NSNumericPadKeyMask >>> > | NSHelpKeyMask >>> > | NSFunctionKeyMask >>> > | NSFlagsChangedMask, self.handleEvent) >>> > >>> > def handleEvent(self, event): >>> > # NSLog(u"%@", event) >>> > >>> > def stop(self): >>> > NSEvent.removeMonitor_(self._observer) >>> > >>> > It is strange that each time when I exit the application, the >>> following error printed in console: >>> > >>> > objc[8775]: autorelease pool page 0x1009e0000 corrupted >>> > magic 0x1009ff00 0xc0000000 0x00000000 0x60000000 >>> > pthread 0x7fff7e917180 >>> > >>> > Also a system dialog shown (please see the screenshot attached). >>> > >>> > Anyone encountered this before? Much appreciate for any >>> suggestions/help. >>> >>> (I'm sorry if this arrives twice, I just noticed that an earlier attempt >>> at replying seems to be dropped to the floor by mail.app...) >>> >>> Do you have a self-contained program that demonstrates the problem? I >>> can get callbacks to handleEvent by embedding the code above >>> in a small app, but the app doesn't crash in the way you mention. >>> >>> Ronald >>> >>> > >>> > Thanks, >>> > Jake >>> > >>> > >>> ------------------------------------------------------------------------------ >>> > October Webinars: Code for Performance >>> > Free Intel webinars can help you accelerate application performance. >>> > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the >>> most from >>> > the latest Intel processors and coprocessors. See abstracts and >>> register > >>> > >>> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk_______________________________________________ >>> > Pyobjc-dev mailing list >>> > Pyo...@li... >>> > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev >>> >>> >> > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most > from > the latest Intel processors and coprocessors. See abstracts and register > > > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk_______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > > > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most > from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > |
From: Diez B. R. <de...@we...> - 2013-10-26 19:03:40
|
Hi, just to rule out the obvious - you are aware of this? https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSAutoreleasePool_Class/Reference/Reference.html#//apple_ref/doc/uid/20000051-SW6 And of course this: http://pythonhosted.org/pyobjc/core/intro.html?highlight=nsautoreleasepool Also, there seems to be a workaround: http://stackoverflow.com/questions/16453026/pyobjc-autorelease-pool Last, but not least: why on earth WX-python? It's ugly both API and UI-wise, as it essentially looks like Windows - everywhere. Of course that's your choice, but on OS X, people easily are alienated by non-native looking apps. Just a suggestion :) Diez On Oct 24, 2013, at 5:01 PM, Jake Wang <del...@gm...> wrote: > Sorry, for the screenshot of the system error dialog, I included in this post: http://stackoverflow.com/questions/19520078/wxpython-with-pyobjc-autorelease-pool-page-corrupted > > > On Thu, Oct 24, 2013 at 9:52 PM, Jake Wang <del...@gm...> wrote: > Hi Ronald, > > Thanks for your response! You reply only arrived once, so no worries :) > > I've arranged a small app to reproduce this issue. Please see the source code from this link: https://github.com/jiakuan/wx-sample > > New findings > > While preparing the small app, I found that the issue might be related to two event binds together with a multiple-thread environment: > > app.Bind(wx.EVT_QUERY_END_SESSION, OnUnexpectedExit) > app.Bind(wx.EVT_END_SESSION, OnUnexpectedExit) > > Sample project description > > Test 1: From the sample project, please run test_wx_and_event_1.py, you will see a taskbar icon. When you click the taskbar icon and select "Close wxPython Sample", the app quit correctly without any issues. > > Test 2: From the sample project, please run test_wx_and_event_2.py, you will also see a taskbar icon. When you click the taskbar icon and select "Close wxPython Sample", the app quit with a system dialog as the same as the one I attached in my previous post, and an error message will be printed in console like the following: > > objc[9303]: autorelease pool page 0x103889000 corrupted > magic 0x1038a800 0x70000000 0x1039c000 0x50000000 > pthread 0x7fff79c40180 > > If we comment two lines (line 145 and 146) in test_wx_and_event_2.py > > # self.Bind(wx.EVT_QUERY_END_SESSION, self.OnUnexpectedExit) > # self.Bind(wx.EVT_END_SESSION, self.OnUnexpectedExit) > > then no such error when quitting app from the taskbar menu. > > The only difference between test_wx_and_event_1.py and test_wx_and_event_2.py is that the second one used a new thread to maintain an event queue. > > And the issue in test 2 only happened in wxPython 2.9.5.0, no such issues for wxPython 2.9.4.0. > > Really appreciate your help on this issue. > > Thanks, > Jake > > > > On Thu, Oct 24, 2013 at 7:55 PM, Ronald Oussoren <ron...@ma...> wrote: > > On 22 Oct, 2013, at 15:49, Jake Wang <del...@gm...> wrote: > > > Hi, > > > > I used PyObjc in a python application for monitoring some global events: > > > > class MacOSXEventMonitor(): > > def init(self): > > log.debug("Initializing events monitor for Mac OS X...") > > > > self._observer = NSEvent.addGlobalMonitorForEventsMatchingMask_handler_( > > NSLeftMouseDownMask > > | NSLeftMouseUpMask > > | NSRightMouseDownMask > > | NSRightMouseUpMask > > | NSMouseMovedMask > > | NSLeftMouseDraggedMask > > | NSRightMouseDraggedMask > > | NSMouseEnteredMask > > | NSMouseExitedMask > > | NSScrollWheelMask > > | NSKeyDownMask > > | NSKeyUpMask > > | NSAlphaShiftKeyMask > > | NSShiftKeyMask > > | NSControlKeyMask > > | NSAlternateKeyMask > > | NSCommandKeyMask > > | NSNumericPadKeyMask > > | NSHelpKeyMask > > | NSFunctionKeyMask > > | NSFlagsChangedMask, self.handleEvent) > > > > def handleEvent(self, event): > > # NSLog(u"%@", event) > > > > def stop(self): > > NSEvent.removeMonitor_(self._observer) > > > > It is strange that each time when I exit the application, the following error printed in console: > > > > objc[8775]: autorelease pool page 0x1009e0000 corrupted > > magic 0x1009ff00 0xc0000000 0x00000000 0x60000000 > > pthread 0x7fff7e917180 > > > > Also a system dialog shown (please see the screenshot attached). > > > > Anyone encountered this before? Much appreciate for any suggestions/help. > > (I'm sorry if this arrives twice, I just noticed that an earlier attempt at replying seems to be dropped to the floor by mail.app...) > > Do you have a self-contained program that demonstrates the problem? I can get callbacks to handleEvent by embedding the code above > in a small app, but the app doesn't crash in the way you mention. > > Ronald > > > > > Thanks, > > Jake > > > > ------------------------------------------------------------------------------ > > October Webinars: Code for Performance > > Free Intel webinars can help you accelerate application performance. > > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > > the latest Intel processors and coprocessors. See abstracts and register > > > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk_______________________________________________ > > Pyobjc-dev mailing list > > Pyo...@li... > > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk_______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Wool S. S. <woo...@gm...> - 2013-10-25 17:27:00
|
> isVisible = myviewcontroller.isVisible() > if isVisible is False: > # do something special The problem is that you shouldn't use if x is False: to test falsehood. Nor, according to PEP 8, should you use if x == False: Instead, use if not x: Python's is operator compares object identity, not value. Your test will fail for any "false-y" value that's not the False singleton itself, like None or an empty list. > it seems to return an int (1 or 0) In case you're not aware of it, ObjC's BOOL is not a true boolean type; it's just a typedef'd signed char, so the integer 0 or 1 you get is strictly correct. There's actually no way for PyObjC to know that it should be a turned into a Python boolean, unless you create bridge metadata for your method. -- Josh Caswell |
From: Jake W. <del...@gm...> - 2013-10-24 14:01:11
|
Sorry, for the screenshot of the system error dialog, I included in this post: http://stackoverflow.com/questions/19520078/wxpython-with-pyobjc-autorelease-pool-page-corrupted On Thu, Oct 24, 2013 at 9:52 PM, Jake Wang <del...@gm...> wrote: > Hi Ronald, > > Thanks for your response! You reply only arrived once, so no worries :) > > I've arranged a small app to reproduce this issue. Please see the source > code from this link: https://github.com/jiakuan/wx-sample > > *New findings* > > While preparing the small app, I found that the issue might be related to > two event binds together with a multiple-thread environment: > > app.Bind(wx.EVT_QUERY_END_SESSION, OnUnexpectedExit) > app.Bind(wx.EVT_END_SESSION, OnUnexpectedExit) > > *Sample project description* > > Test 1: From the sample project, please run *test_wx_and_event_1.py*, you > will see a taskbar icon. When you click the taskbar icon and select "Close > wxPython Sample", the app quit correctly without any issues. > > Test 2: From the sample project, please run *test_wx_and_event_2.py*, you > will also see a taskbar icon. When you click the taskbar icon and select > "Close wxPython Sample", the app quit with a system dialog as the same as > the one I attached in my previous post, and an error message will be > printed in console like the following: > > objc[9303]: autorelease pool page 0x103889000 corrupted > magic 0x1038a800 0x70000000 0x1039c000 0x50000000 > pthread 0x7fff79c40180 > > If we comment two lines (line 145 and 146) in test_wx_and_event_2.py > > # self.Bind(wx.EVT_QUERY_END_SESSION, self.OnUnexpectedExit) > # self.Bind(wx.EVT_END_SESSION, self.OnUnexpectedExit) > > then no such error when quitting app from the taskbar menu. > > The only difference between test_wx_and_event_1.py > and test_wx_and_event_2.py is that the second one used a new thread to > maintain an event queue. > > And the issue in test 2 only happened in wxPython 2.9.5.0, no such issues > for wxPython 2.9.4.0. > > Really appreciate your help on this issue. > > Thanks, > Jake > > > > On Thu, Oct 24, 2013 at 7:55 PM, Ronald Oussoren <ron...@ma...>wrote: > >> >> On 22 Oct, 2013, at 15:49, Jake Wang <del...@gm...> wrote: >> >> > Hi, >> > >> > I used PyObjc in a python application for monitoring some global events: >> > >> > class MacOSXEventMonitor(): >> > def init(self): >> > log.debug("Initializing events monitor for Mac OS X...") >> > >> > self._observer = >> NSEvent.addGlobalMonitorForEventsMatchingMask_handler_( >> > NSLeftMouseDownMask >> > | NSLeftMouseUpMask >> > | NSRightMouseDownMask >> > | NSRightMouseUpMask >> > | NSMouseMovedMask >> > | NSLeftMouseDraggedMask >> > | NSRightMouseDraggedMask >> > | NSMouseEnteredMask >> > | NSMouseExitedMask >> > | NSScrollWheelMask >> > | NSKeyDownMask >> > | NSKeyUpMask >> > | NSAlphaShiftKeyMask >> > | NSShiftKeyMask >> > | NSControlKeyMask >> > | NSAlternateKeyMask >> > | NSCommandKeyMask >> > | NSNumericPadKeyMask >> > | NSHelpKeyMask >> > | NSFunctionKeyMask >> > | NSFlagsChangedMask, self.handleEvent) >> > >> > def handleEvent(self, event): >> > # NSLog(u"%@", event) >> > >> > def stop(self): >> > NSEvent.removeMonitor_(self._observer) >> > >> > It is strange that each time when I exit the application, the following >> error printed in console: >> > >> > objc[8775]: autorelease pool page 0x1009e0000 corrupted >> > magic 0x1009ff00 0xc0000000 0x00000000 0x60000000 >> > pthread 0x7fff7e917180 >> > >> > Also a system dialog shown (please see the screenshot attached). >> > >> > Anyone encountered this before? Much appreciate for any >> suggestions/help. >> >> (I'm sorry if this arrives twice, I just noticed that an earlier attempt >> at replying seems to be dropped to the floor by mail.app...) >> >> Do you have a self-contained program that demonstrates the problem? I can >> get callbacks to handleEvent by embedding the code above >> in a small app, but the app doesn't crash in the way you mention. >> >> Ronald >> >> > >> > Thanks, >> > Jake >> > >> > >> ------------------------------------------------------------------------------ >> > October Webinars: Code for Performance >> > Free Intel webinars can help you accelerate application performance. >> > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the >> most from >> > the latest Intel processors and coprocessors. See abstracts and >> register > >> > >> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk_______________________________________________ >> > Pyobjc-dev mailing list >> > Pyo...@li... >> > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev >> >> > |
From: Jake W. <del...@gm...> - 2013-10-24 13:52:20
|
Hi Ronald, Thanks for your response! You reply only arrived once, so no worries :) I've arranged a small app to reproduce this issue. Please see the source code from this link: https://github.com/jiakuan/wx-sample *New findings* While preparing the small app, I found that the issue might be related to two event binds together with a multiple-thread environment: app.Bind(wx.EVT_QUERY_END_SESSION, OnUnexpectedExit) app.Bind(wx.EVT_END_SESSION, OnUnexpectedExit) *Sample project description* Test 1: From the sample project, please run *test_wx_and_event_1.py*, you will see a taskbar icon. When you click the taskbar icon and select "Close wxPython Sample", the app quit correctly without any issues. Test 2: From the sample project, please run *test_wx_and_event_2.py*, you will also see a taskbar icon. When you click the taskbar icon and select "Close wxPython Sample", the app quit with a system dialog as the same as the one I attached in my previous post, and an error message will be printed in console like the following: objc[9303]: autorelease pool page 0x103889000 corrupted magic 0x1038a800 0x70000000 0x1039c000 0x50000000 pthread 0x7fff79c40180 If we comment two lines (line 145 and 146) in test_wx_and_event_2.py # self.Bind(wx.EVT_QUERY_END_SESSION, self.OnUnexpectedExit) # self.Bind(wx.EVT_END_SESSION, self.OnUnexpectedExit) then no such error when quitting app from the taskbar menu. The only difference between test_wx_and_event_1.py and test_wx_and_event_2.py is that the second one used a new thread to maintain an event queue. And the issue in test 2 only happened in wxPython 2.9.5.0, no such issues for wxPython 2.9.4.0. Really appreciate your help on this issue. Thanks, Jake On Thu, Oct 24, 2013 at 7:55 PM, Ronald Oussoren <ron...@ma...>wrote: > > On 22 Oct, 2013, at 15:49, Jake Wang <del...@gm...> wrote: > > > Hi, > > > > I used PyObjc in a python application for monitoring some global events: > > > > class MacOSXEventMonitor(): > > def init(self): > > log.debug("Initializing events monitor for Mac OS X...") > > > > self._observer = > NSEvent.addGlobalMonitorForEventsMatchingMask_handler_( > > NSLeftMouseDownMask > > | NSLeftMouseUpMask > > | NSRightMouseDownMask > > | NSRightMouseUpMask > > | NSMouseMovedMask > > | NSLeftMouseDraggedMask > > | NSRightMouseDraggedMask > > | NSMouseEnteredMask > > | NSMouseExitedMask > > | NSScrollWheelMask > > | NSKeyDownMask > > | NSKeyUpMask > > | NSAlphaShiftKeyMask > > | NSShiftKeyMask > > | NSControlKeyMask > > | NSAlternateKeyMask > > | NSCommandKeyMask > > | NSNumericPadKeyMask > > | NSHelpKeyMask > > | NSFunctionKeyMask > > | NSFlagsChangedMask, self.handleEvent) > > > > def handleEvent(self, event): > > # NSLog(u"%@", event) > > > > def stop(self): > > NSEvent.removeMonitor_(self._observer) > > > > It is strange that each time when I exit the application, the following > error printed in console: > > > > objc[8775]: autorelease pool page 0x1009e0000 corrupted > > magic 0x1009ff00 0xc0000000 0x00000000 0x60000000 > > pthread 0x7fff7e917180 > > > > Also a system dialog shown (please see the screenshot attached). > > > > Anyone encountered this before? Much appreciate for any suggestions/help. > > (I'm sorry if this arrives twice, I just noticed that an earlier attempt > at replying seems to be dropped to the floor by mail.app...) > > Do you have a self-contained program that demonstrates the problem? I can > get callbacks to handleEvent by embedding the code above > in a small app, but the app doesn't crash in the way you mention. > > Ronald > > > > > Thanks, > > Jake > > > > > ------------------------------------------------------------------------------ > > October Webinars: Code for Performance > > Free Intel webinars can help you accelerate application performance. > > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most > from > > the latest Intel processors and coprocessors. See abstracts and register > > > > > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk_______________________________________________ > > Pyobjc-dev mailing list > > Pyo...@li... > > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > |
From: Ronald O. <ron...@ma...> - 2013-10-24 11:55:38
|
On 22 Oct, 2013, at 15:49, Jake Wang <del...@gm...> wrote: > Hi, > > I used PyObjc in a python application for monitoring some global events: > > class MacOSXEventMonitor(): > def init(self): > log.debug("Initializing events monitor for Mac OS X...") > > self._observer = NSEvent.addGlobalMonitorForEventsMatchingMask_handler_( > NSLeftMouseDownMask > | NSLeftMouseUpMask > | NSRightMouseDownMask > | NSRightMouseUpMask > | NSMouseMovedMask > | NSLeftMouseDraggedMask > | NSRightMouseDraggedMask > | NSMouseEnteredMask > | NSMouseExitedMask > | NSScrollWheelMask > | NSKeyDownMask > | NSKeyUpMask > | NSAlphaShiftKeyMask > | NSShiftKeyMask > | NSControlKeyMask > | NSAlternateKeyMask > | NSCommandKeyMask > | NSNumericPadKeyMask > | NSHelpKeyMask > | NSFunctionKeyMask > | NSFlagsChangedMask, self.handleEvent) > > def handleEvent(self, event): > # NSLog(u"%@", event) > > def stop(self): > NSEvent.removeMonitor_(self._observer) > > It is strange that each time when I exit the application, the following error printed in console: > > objc[8775]: autorelease pool page 0x1009e0000 corrupted > magic 0x1009ff00 0xc0000000 0x00000000 0x60000000 > pthread 0x7fff7e917180 > > Also a system dialog shown (please see the screenshot attached). > > Anyone encountered this before? Much appreciate for any suggestions/help. (I'm sorry if this arrives twice, I just noticed that an earlier attempt at replying seems to be dropped to the floor by mail.app...) Do you have a self-contained program that demonstrates the problem? I can get callbacks to handleEvent by embedding the code above in a small app, but the app doesn't crash in the way you mention. Ronald > > Thanks, > Jake > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk_______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Jake W. <del...@gm...> - 2013-10-22 13:49:38
|
Hi, I used PyObjc in a python application for monitoring some global events: class MacOSXEventMonitor(): def init(self): log.debug("Initializing events monitor for Mac OS X...") self._observer = NSEvent.addGlobalMonitorForEventsMatchingMask_handler_( NSLeftMouseDownMask | NSLeftMouseUpMask | NSRightMouseDownMask | NSRightMouseUpMask | NSMouseMovedMask | NSLeftMouseDraggedMask | NSRightMouseDraggedMask | NSMouseEnteredMask | NSMouseExitedMask | NSScrollWheelMask | NSKeyDownMask | NSKeyUpMask | NSAlphaShiftKeyMask | NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask | NSNumericPadKeyMask | NSHelpKeyMask | NSFunctionKeyMask | NSFlagsChangedMask, self.handleEvent) def handleEvent(self, event): # NSLog(u"%@", event) def stop(self): NSEvent.removeMonitor_(self._observer) It is strange that each time when I exit the application, the following error printed in console: objc[8775]: autorelease pool page 0x1009e0000 corrupted magic 0x1009ff00 0xc0000000 0x00000000 0x60000000 pthread 0x7fff7e917180 Also a system dialog shown (please see the screenshot attached). Anyone encountered this before? Much appreciate for any suggestions/help. Thanks, Jake |
From: Patrick R. <rob...@gm...> - 2013-10-19 11:42:36
|
Hi all, I'm currently creating a PyObjc app which uses a mixture of PyObjc and Plain Objc (mainly for view stuff). I have a method in one of my (Objective-C) view controllers as follows: @implementation MyVC - (BOOL)isVisible { return [self.mySpecialView isVisible] } in Python, I call this: # myviewcontroller = MyVC.alloc().init() # …stuff isVisible = myviewcontroller.isVisible() if isVisible is False: # do something special Now, I'd expect this call through to my Objective-C method to return a Python bool value of True or False. However, it seems to return an int (1 or 0) I've checked this with repr(isVisible) and what have you. This subsequently causes the line: if isVisible is False: to fail (since 0 is not False) Of course I can do if isVisible == False: to get round this, but I feel like if I'm declaring a BOOL in Obj-C I should get one pack in Python P.S. I've tried casting the return value of my Obj-C method to a BOOL just incase that'd make a difference. It doesn't. Thanks for any help |
From: Ronald O. <ron...@ma...> - 2013-10-17 10:33:25
|
On 11 Oct, 2013, at 18:14, Roy Nielsen <am...@gm...> wrote: > Hello, > > I'm trying to use SMJobSubmit - trying to convert the example at : > > http://www.stairways.com/blog/2012-08-06-smjobsubmit > > to python using pyobjc... > > I've gotten this far: > > 18 mylabel = "gov.lanl.example" > 19 > 20 authItem = [kSMRightBlessPrivilegedHelper, 0, None, 0] > 21 authRights = [1, authItem] > 22 flags = kAuthorizationFlagInteractionAllowed | kAuthorizationFlagPreAuthorize | kAuthorizationFlagExtendRights > 23 > 24 auth = None > 25 > 26 if AuthorizationCreate(authrights, kAuthorizationEmptyEnvironment, flags, auth ) == errAuthorizationSuccess : > 27 SMJobRemove(kSMDomainSystemLaunchd, mylabel, auth, false, NULL) > 28 > 29 ##### > 30 # To load a plist into a dictionary: > 31 #plist = NSMutableDictionary.dictionaryWithContentsOfFile_(os.path.expanduser(plist)) > 32 > 33 plist = NSMutableDictionary.dictionary() > 34 > 35 plist.setObject_forKey(mylabel, "Label") > 36 plist.setObject_forKey(NSNumber.numberWithBool(YES), "RunAtLoad") > 37 plist.setObject_forKey(executablePath "Program") > 38 > > I need to pass in some ProgramArguments... > > Would I do it by: > > plist.setObject_forKey([arg1, arg2, arg3], "ProgramArguments") Use plist.setObject_forKey_(value, key), or plist[key] = value The "_" at the end of the method name is important. Ronald > > Thanks, > -Roy Nielsen > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk_______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Roy N. <am...@gm...> - 2013-10-11 16:14:33
|
Hello, I'm trying to use SMJobSubmit - trying to convert the example at : http://www.stairways.com/blog/2012-08-06-smjobsubmit to python using pyobjc... I've gotten this far: 18 mylabel = "gov.lanl.example" 19 20 authItem = [kSMRightBlessPrivilegedHelper, 0, None, 0] 21 authRights = [1, authItem] 22 flags = kAuthorizationFlagInteractionAllowed | kAuthorizationFlagPreAuthorize | kAuthorizationFlagExtendRights 23 24 auth = None 25 26 if AuthorizationCreate(authrights, kAuthorizationEmptyEnvironment, flags, auth ) == errAuthorizationSuccess : 27 SMJobRemove(kSMDomainSystemLaunchd, mylabel, auth, false, NULL) 28 29 ##### 30 # To load a plist into a dictionary: 31 #plist = NSMutableDictionary.dictionaryWithContentsOfFile_(os.path.expanduser(plist)) 32 33 plist = NSMutableDictionary.dictionary() 34 35 plist.setObject_forKey(mylabel, "Label") 36 plist.setObject_forKey(NSNumber.numberWithBool(YES), "RunAtLoad") 37 plist.setObject_forKey(executablePath "Program") 38 I need to pass in some ProgramArguments... Would I do it by: plist.setObject_forKey([arg1, arg2, arg3], "ProgramArguments") Thanks, -Roy Nielsen |
From: Erik v. B. <er...@le...> - 2013-08-31 13:52:35
|
Hi Ronald, thanks for the clue. I think I've localised the problem. On 29 aug. 2013, at 13:37, Ronald Oussoren <ron...@ma...> wrote: > > This means that your document class problably has an attribute that has the same name as a method that is new in OSX 10.9. This script shows the 10.9 NSView has a backgroundColor method. from AppKit import NSView, NSColor class MyView(NSView): def init(self): self = super(MyView, self).init() self.backgroundColor = NSColor.lightGrayColor() return self print MyView.alloc().init() On 10.8.4: > <MyView: 0x7fe65620eaa0> On 10.9 (13A558): > Traceback (most recent call last): > File "/Volumes/erik/Desktop/test.py", line 10, in <module> > print MyView.alloc().init() > File "/Volumes/erik/Desktop/test.py", line 7, in init > self.backgroundColor = NSColor.lightGrayColor() > TypeError: cannot change a method Cheers, Erik |