question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nuitka doesn't support wxPython on MacOs

See original GitHub issue

Hello!

Is Nuitka using virtualenv like technology? After I packaged my WxPython program with Nuitka, I ran the program with the following error prompt, which is the same as if Virtualenv were running a WxPython program.

This program needs access to the screen. Please run with a Framework build of python, and only when you are logged in on the main display of your Mac.

Virtualenv runs the WxPython program with python2.7 step-by-step as follows,But python3.7 is normal:

(noticeAppByPy2) mac@zqw-10 o % python -c “import wx;app=wx.App();” This program needs access to the screen. Please run with a Framework build of python, and only when you are logged in on the main display of your Mac.

`import wx

app = wx.App() window = wx.Frame(None, title = “wxPython - www.yiibai.com”, size = (400,300)) panel = wx.Panel(window) label = wx.StaticText(panel, label = “Hello World”, pos = (100,100)) window.Show(True) app.MainLoop()`

Now the question is, how can this error be resolved when using Nuitka to package a WxPython program? Thank you very much!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kayhayencommented, Oct 4, 2021

Fogive my failure to update. With the new option --macos-create-app-bundle and --macos-disable-console the wx works fine. This bundle mode currently only works in standalone mode, but not in onefile mode. It’s required for macOS and wx to be a GUI program, which seems impossible without being a bundle.

1reaction
kayhayencommented, Sep 10, 2021

This removes wx from the equation entirely. It reproduces above C code in Python. It seems the framework loads with a simple “find_library”, in Python and while it reports an error message to not locating the plist as above, there is no reason to assume the framework didn’t load, the first call works, while the second to bring the process to the front does not.

from ctypes.util import find_library
from ctypes import cdll, c_int, pointer, Structure

app_services = cdll.LoadLibrary(find_library("ApplicationServices"))

if app_services.CGMainDisplayID() == 0:
    print("no gui")
else:
    print("gui")

print(app_services)

class ProcessSerialNumber(Structure):
    _fields_ = [("highLongOfPSN", c_int),
                ("lowLongOfPSN", c_int)]
psn = ProcessSerialNumber()
psn_p = pointer(psn)
if app_services.GetCurrentProcess(psn_p) < 0:
    print("cannot run without OS X gui process")
elif        (app_services.SetFrontProcess(psn_p) < 0):
    print("cannot set to front without OS X gui process")
else:
    print("works")

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build system for wxpython project(s)
Hello, I'm about to start working on open-source desktop app using wxPython. I need to include and bind 3rd party C library and...
Read more >
How to Distribute a wxPython Application - Mouse Vs Python
If none of those work, try Google or go to PyInstaller's support page and get help there. Creating Executables for Mac. While the...
Read more >
Can't install wxPython on OSX : r/Python - Reddit
I know this probably isn't the best place, but I'm trying to install wxPython on a mac and despite trying several mirrors it...
Read more >
Nuitka-chat/community - Gitter
so am asking here to be sure that am in the right way and i want to know the correct command to convert...
Read more >
User Manual - Nuitka
No information is available for this page.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found