-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
importing AWT classes hangs the script on OSX #151
Comments
I had the same problem and here is a solution/workaround. For AWT to work, the cocoa main loop needs to be started. This can be done outside jnius. Something like this works for me: import objc
from Foundation import *
from AppKit import *
from PyObjCTools import AppHelper
def runAwtStuff():
# main program goes here
class AppDelegate (NSObject):
def runjava_(self,arg):
runAwtStuff()
def applicationDidFinishLaunching_(self, aNotification):
self.performSelectorInBackground_withObject_("runjava:",0)
def main():
app = NSApplication.sharedApplication()
delegate = AppDelegate.alloc().init()
NSApp().setDelegate_(delegate)
AppHelper.runEventLoop()
if __name__ == '__main__' : main() |
@tpietzsch many thanks for sharing the workaround! I'm not using Pyjnius at the moment, but will give it a try as soon as I have a chance. |
This avoids problems with AWT on macOS. The alternative is to use the OSXAWTwrapper approach from https://github.com/hanslovsky/imglib2-imglyb. See also: kivy/pyjnius#151 (comment)
This fixes the issue with generating shapefiles where loading openmap's EsriPointList would hang. Some of openmap's classes, like EsriPointList, depend on AWT classes and this causes pyjnius to hang on macOS. See kivy/pyjnius#151 for more details.
@tpietzsch The workaround works great! For anyone who also stumbles upon this issue: the needed lib can be installed via pip install -U pyobjc |
This python script:
hangs when loading the Frame class (runnning OSX 10.9.5, JDK 1.8.0_31). I'm aware of issues with AWT on OSX #85, where a suggested workaround is to use -Djava.awt.headless=true.
But if I explicitly don't want to use the headless mode, is there ant workaround to this issue?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: