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.
Hi, I need to run wxPython python script code inside the GDB's embedding python interpreter. (actually the python script is a python's pretty printer to visualize some data through wxPython and Matpoltlib)
But I see the error message:
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.
After that, GDB just quit.
-- Tim Roberts, ti...@probo.com Providenza & Boekelheide, Inc.
vmmap $pid command, the pid is the running python process
. I can also run wxPython scripts directly under the global python interrupter without any virtual environment. The actual python executable file locates inside the some folder named: Python.app/Contents/MacOS/python. It looks like this executable also contains an rocket kind icon.class App(wx.PyApp):
"""
The ``wx.App`` class represents the application and is used to:
* bootstrap the wxPython system and initialize the underlying
gui toolkit
* set and get application-wide properties
* implement the windowing system main message or event loop,
and to dispatch events to window instances
* etc.
Every application must have a ``wx.App`` instance, and all
creation of UI objects should be delayed until after the
``wx.App`` object has been created in order to ensure that the gui
platform and wxWidgets have been fully initialized.
Normally you would derive from this class and implement an
``OnInit`` method that creates a frame and then calls
``self.SetTopWindow(frame)``.
"""
outputWindowClass = PyOnDemandOutputWindow
def __init__(self,
redirect=False,
filename=None,
useBestVisual=False,
clearSigInt=True):
"""
Construct a ``wx.App`` object.
:param redirect: Should ``sys.stdout`` and ``sys.stderr`` be
redirected? Defaults to False. If ``filename`` is None
then output will be redirected to a window that pops up
as needed. (You can control what kind of window is created
for the output by resetting the class variable
``outputWindowClass`` to a class of your choosing.)
:param filename: The name of a file to redirect output to, if
redirect is True.
:param useBestVisual: Should the app try to use the best
available visual provided by the system (only relevant on
systems that have more than one visual.) This parameter
must be used instead of calling `SetUseBestVisual` later
on because it must be set before the underlying GUI
toolkit is initialized.
:param clearSigInt: Should SIGINT be cleared? This allows the
app to terminate upon a Ctrl-C in the console like other
GUI apps will.
:note: You should override OnInit to do applicaition
initialization to ensure that the system, toolkit and
wxWidgets are fully initialized.
"""
wx.PyApp.__init__(self)
# make sure we can create a GUI
if not self.IsDisplayAvailable():
if wx.Platform == "__WXMAC__":
msg = """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."""
//----------------------------------------------------------------------
// Function to test if the Display (or whatever is the platform equivallent)
// can be connected to. This is accessable from wxPython as a staticmethod of
// wx.App called DisplayAvailable().
bool wxPyTestDisplayAvailable()
{
#ifdef __WXGTK__
Display* display;
display = XOpenDisplay(NULL);
if (display == NULL)
return false;
XCloseDisplay(display);
return true;
#endif
#ifdef __WXMAC__
// This is adapted from Python's Mac/Modules/MacOS.c in the
// MacOS_WMAvailable function.
bool rv;
ProcessSerialNumber psn;
/*
** This is a fairly innocuous call to make if we don't have a window
** manager, or if we have no permission to talk to it. It will print
** a message on stderr, but at least it won't abort the process.
** It appears the function caches the result itself, and it's cheap, so
** no need for us to cache.
*/
#ifdef kCGNullDirectDisplay
/* On 10.1 CGMainDisplayID() isn't available, and
** kCGNullDirectDisplay isn't defined.
*/
if (CGMainDisplayID() == 0) {
rv = false;
} else
#endif
{
// Also foreground the application on the first call as a side-effect.
if (GetCurrentProcess(&psn) < 0 || SetFrontProcess(&psn) < 0) {
rv = false;
} else {
rv = true;
}
}
return rv;
#endif
#ifdef __WXMSW__
// TODO...
return true;
#endif
}
Quartz Display Services Reference - https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/Quartz_Services_Ref/#//apple_ref/c/func/CGMainDisplayID
Thanks
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
The Python.org build of Python for OS-X has an ugly hack to allow it to run GUI apps. You could maybe replicate it with gdb's embeddd Python.See the source code and the python Mac list archives for some discussion.
Another option is to take a look at the different kludge that Anaconda's Python does for OS-X -- I think it's almost as simple as putting the executable in an app bundle.Try installing it and see what pythonw is actually linked to.
lydeMBP:~ ly$ otool -L /usr/local/Cellar/gdb/7.10/bin/gdb
/usr/local/Cellar/gdb/7.10/bin/gdb:
/usr/local/opt/readline/lib/libreadline.6.dylib (compatibility version
6.0.0, current version 6.3.0)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current
version 5.4.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 1213.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
(compatibility version 150.0.0, current version 1153.18.0)
/System/Library/Frameworks/Python.framework/Versions/2.7/Python
(compatibility version 2.7.0, current version 2.7.10)
/usr/lib/libexpat.1.dylib (compatibility version 7.0.0, current version 7.2.0)
I think it's almost as simple as putting the executable in an app bundle.
See the source code and the python Mac list archives for some discussion.Hi, CHB, thanks for the reply.
I did subscribe to the pythonmac-sig maillist, and I have posted an email to that maillist several days ago, but sadly, I see my post is not appeared in that maillist, maybe, the email is not approved by the administer of that maillist.
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Fri, Oct 23, 2015 at 7:45 PM, asm warrior <asmwa...@gmail.com> wrote:See the source code and the python Mac list archives for some discussion.Hi, CHB, thanks for the reply.
I did subscribe to the pythonmac-sig maillist, and I have posted an email to that maillist several days ago, but sadly, I see my post is not appeared in that maillist, maybe, the email is not approved by the administer of that maillist.That's odd -- I don't think it's moderated. But at anyrate, here is the thread where we discussed this a while back.HTH,-Chris