Comments (5)
I'm not an expert on the async features of Rubicon, but I think the line app = NSApplication
might be the problem - that sets app
to the NSApplication
class, not a NSApplication
instance. You probably need to use app = NSApplication.sharedApplication()
, like in the code from the documentation.
from rubicon-objc.
@dgelessus I have changed the file to:
# Import the Event Loop Policy and lifecycle
from rubicon.objc.eventloop import EventLoopPolicy, CocoaLifecycle
# importing asyncio to set event loop
import asyncio
# Asyncio Install the event loop policy
asyncio.set_event_loop_policy(EventLoopPolicy())
# Get a handle to the shared NSApplication
from ctypes import cdll, util
from rubicon.objc import ObjCClass
appkit = cdll.LoadLibrary(util.find_library('AppKit'))
NSApplication = ObjCClass('NSApplication')
app = NSApplication.sharedApplication()
# Get an event loop, and run it, using the NSApplication!
loop = asyncio.get_event_loop()
loop.run_forever(lifecycle=CocoaLifecycle(app))
Here is the error message:
Traceback (most recent call last):
File "aio/r1a.py", line 13, in <module>
app = NSApplication.sharedApplication()
TypeError: 'ObjCInstance' object is not callable
Thanks for the help!
from rubicon-objc.
Ah, this is a relatively common problem - it happens when you try to call a method, but it's actually a property. In this case, you need to add NSApplication.declare_class_property('sharedApplication')
under the NSApplication = ObjCClass('NSApplication')
line, and then remove the parentheses from the sharedApplication
call (i. e. replace NSApplication.sharedApplication()
with NSApplication.sharedApplication
).
from rubicon-objc.
Super cool! It works! Thanks so much!
May I set up a PR for editing the documentation representing the correct syntax?
from rubicon-objc.
Merged it. Thank you for all the documentation fixes :)
from rubicon-objc.
Related Issues (20)
- Calling performSelector for a @objc_method created by rubicon from Objective C crashes in Python 3.9 HOT 3
- Blocks not fully working on M1 hardware HOT 5
- "ObjC Class 'b'WrappedPyObject'' couldn't be found." when running on iOS device HOT 7
- iOS event loop blocks when thread waits on socket.
- x86_64 machine architecture not identified correctly on iOS simulator
- Attribute intermittently returns the wrong object HOT 5
- Segmentation fault when exiting multi-threaded program
- Race condition when instantiating ObjCInstance objects
- Race condition when populating the ObjCClass method/attribute cache
- Update CI configuration to test release artefacts
- Improve correspondence between ObjectiveC objects and Python wrappers HOT 17
- New caching logic may inadvertently release objects that are still needed HOT 5
- ctypes.ArgumentError message is split into individual characters
- Warning about deprecated `pkg_resources` API
- Incompatibility with `from __future__ import annotations` HOT 1
- Incompatibility with Python 3.12.0b1 HOT 4
- Scroll blocks eventloop for ios HOT 3
- Can't invoke Protocol methods that collide with object properties HOT 2
- "ImportError: No module named 'rubicon'" if trying to bundle script via py2app. HOT 1
- Sphinx 7.2 dropped support for Python 3.8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rubicon-objc.