mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-04 19:10:09 +01:00
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@66393 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
832 lines
24 KiB
Plaintext
832 lines
24 KiB
Plaintext
//---------------------------------------------------------------------------
|
|
// This file is generated by wxPython's SIP generator. Do not edit by hand.
|
|
//
|
|
// Copyright: (c) 2010 by Total Control Software
|
|
// License: wxWindows License
|
|
//
|
|
// This file will be included by _core.sip
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
%ModuleHeaderCode
|
|
enum wxAppAssertMode {
|
|
wxPYAPP_ASSERT_SUPPRESS = 1,
|
|
wxPYAPP_ASSERT_EXCEPTION = 2,
|
|
wxPYAPP_ASSERT_DIALOG = 4,
|
|
wxPYAPP_ASSERT_LOG = 8
|
|
};
|
|
|
|
class wxPyApp;
|
|
wxPyApp* wxGetApp();
|
|
|
|
%End
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
class wxAppConsole : wxEvtHandler
|
|
{
|
|
%TypeHeaderCode
|
|
#include <wx/app.h>
|
|
%End
|
|
|
|
|
|
public:
|
|
virtual
|
|
~wxAppConsole();
|
|
|
|
virtual
|
|
int MainLoop();
|
|
|
|
void ExitMainLoop();
|
|
|
|
virtual
|
|
int FilterEvent(
|
|
wxEvent & event
|
|
);
|
|
|
|
wxEventLoopBase * GetMainLoop();
|
|
|
|
virtual
|
|
void ProcessPendingEvents();
|
|
|
|
void DeletePendingEvents();
|
|
|
|
bool HasPendingEvents();
|
|
|
|
void SuspendProcessingOfPendingEvents();
|
|
|
|
void ResumeProcessingOfPendingEvents();
|
|
|
|
void ScheduleForDestruction(
|
|
wxObject * object
|
|
);
|
|
|
|
bool IsScheduledForDestruction(
|
|
wxObject * object
|
|
);
|
|
|
|
virtual
|
|
void OnEventLoopEnter(
|
|
wxEventLoopBase * loop
|
|
);
|
|
|
|
virtual
|
|
void OnEventLoopExit(
|
|
wxEventLoopBase * loop
|
|
);
|
|
|
|
virtual
|
|
int OnExit();
|
|
|
|
virtual
|
|
bool OnInit();
|
|
|
|
virtual
|
|
int OnRun();
|
|
|
|
wxString GetAppDisplayName();
|
|
|
|
wxString GetAppName();
|
|
|
|
wxString GetClassName();
|
|
|
|
wxAppTraits * GetTraits();
|
|
|
|
const wxString & GetVendorDisplayName();
|
|
|
|
const wxString & GetVendorName();
|
|
|
|
void SetAppDisplayName(
|
|
const wxString & name
|
|
);
|
|
|
|
void SetAppName(
|
|
const wxString & name
|
|
);
|
|
|
|
void SetClassName(
|
|
const wxString & name
|
|
);
|
|
|
|
void SetVendorDisplayName(
|
|
const wxString & name
|
|
);
|
|
|
|
void SetVendorName(
|
|
const wxString & name
|
|
);
|
|
|
|
static
|
|
void SetInstance(
|
|
wxAppConsole * app
|
|
);
|
|
|
|
static
|
|
wxAppConsole * GetInstance();
|
|
|
|
static
|
|
bool IsMainLoopRunning();
|
|
|
|
%Property(name=AppDisplayName, get=GetAppDisplayName, set=SetAppDisplayName)
|
|
%Property(name=AppName, get=GetAppName, set=SetAppName)
|
|
%Property(name=ClassName, get=GetClassName, set=SetClassName)
|
|
%Property(name=VendorDisplayName, get=GetVendorDisplayName, set=SetVendorDisplayName)
|
|
%Property(name=VendorName, get=GetVendorName, set=SetVendorName)
|
|
}; // end of class wxAppConsole
|
|
|
|
|
|
enum wxAppAssertMode {
|
|
wxPYAPP_ASSERT_SUPPRESS = 1,
|
|
wxPYAPP_ASSERT_EXCEPTION = 2,
|
|
wxPYAPP_ASSERT_DIALOG = 4,
|
|
wxPYAPP_ASSERT_LOG = 8
|
|
};
|
|
|
|
|
|
class wxPyApp : wxAppConsole
|
|
{
|
|
%TypeHeaderCode
|
|
#include <wx/app.h>
|
|
%End
|
|
|
|
%TypeCode
|
|
|
|
#ifdef __WXGTK__
|
|
#include <gdk/gdkx.h>
|
|
#include <wx/gtk/private/win_gtk.h>
|
|
#endif
|
|
|
|
#ifdef __WXMAC__
|
|
#include <wx/osx/private.h>
|
|
#endif
|
|
|
|
|
|
class wxPyApp : public wxApp
|
|
{
|
|
DECLARE_ABSTRACT_CLASS(wxPyApp)
|
|
|
|
public:
|
|
wxPyApp() : wxApp() {
|
|
m_assertMode = wxPYAPP_ASSERT_EXCEPTION;
|
|
m_startupComplete = false;
|
|
//m_callFilterEvent = false;
|
|
ms_appInstance = this;
|
|
}
|
|
~wxPyApp() {
|
|
ms_appInstance = NULL;
|
|
wxApp::SetInstance(NULL);
|
|
}
|
|
|
|
|
|
#ifndef __WXMAC__
|
|
virtual void MacNewFile() {}
|
|
virtual void MacOpenFile(const wxString &) {}
|
|
virtual void MacOpenURL(const wxString &) {}
|
|
virtual void MacPrintFile(const wxString &) {}
|
|
virtual void MacReopenApp() {}
|
|
#endif
|
|
|
|
#ifdef __WXMAC__
|
|
static long GetMacAboutMenuItemId() { return s_macAboutMenuItemId; }
|
|
static long GetMacPreferencesMenuItemId() { return s_macPreferencesMenuItemId; }
|
|
static long GetMacExitMenuItemId() { return s_macExitMenuItemId; }
|
|
static wxString GetMacHelpMenuTitleName() { return s_macHelpMenuTitleName; }
|
|
static void SetMacAboutMenuItemId(long val) { s_macAboutMenuItemId = val; }
|
|
static void SetMacPreferencesMenuItemId(long val) { s_macPreferencesMenuItemId = val; }
|
|
static void SetMacExitMenuItemId(long val) { s_macExitMenuItemId = val; }
|
|
static void SetMacHelpMenuTitleName(const wxString& val) { s_macHelpMenuTitleName = val; }
|
|
#else
|
|
static long GetMacAboutMenuItemId() { return 0; }
|
|
static long GetMacPreferencesMenuItemId() { return 0; }
|
|
static long GetMacExitMenuItemId() { return 0; }
|
|
static wxString GetMacHelpMenuTitleName() { return wxEmptyString; }
|
|
static void SetMacAboutMenuItemId(long) { }
|
|
static void SetMacPreferencesMenuItemId(long) { }
|
|
static void SetMacExitMenuItemId(long) { }
|
|
static void SetMacHelpMenuTitleName(const wxString&) { }
|
|
#endif
|
|
|
|
wxAppAssertMode GetAssertMode() { return m_assertMode; }
|
|
void SetAssertMode(wxAppAssertMode mode) { m_assertMode = mode; }
|
|
|
|
// virtual void OnAssertFailure(const wxChar *file,
|
|
// int line,
|
|
// const wxChar *func,
|
|
// const wxChar *cond,
|
|
// const wxChar *msg);
|
|
|
|
|
|
// Implementing OnInit is optional for wxPython apps
|
|
virtual bool OnInit() { return true; }
|
|
virtual void OnPreInit() { }
|
|
|
|
void _BootstrapApp();
|
|
virtual int MainLoop();
|
|
|
|
static bool IsDisplayAvailable();
|
|
|
|
// implementation only
|
|
void SetStartupComplete(bool val) { m_startupComplete = val; }
|
|
static wxPyApp* ms_appInstance;
|
|
|
|
private:
|
|
wxAppAssertMode m_assertMode;
|
|
bool m_startupComplete;
|
|
//bool m_callFilterEvent;
|
|
};
|
|
|
|
IMPLEMENT_ABSTRACT_CLASS(wxPyApp, wxApp);
|
|
|
|
wxPyApp* wxPyApp::ms_appInstance = NULL;
|
|
|
|
|
|
|
|
void wxPyApp::_BootstrapApp()
|
|
{
|
|
static bool haveInitialized = false;
|
|
bool result;
|
|
wxPyBlock_t blocked;
|
|
|
|
// Only initialize wxWidgets once
|
|
if (! haveInitialized) {
|
|
|
|
// Copy the values in Python's sys.argv list to a C array of char* to
|
|
// be passed to the wxEntryStart function below.
|
|
int argc = 0;
|
|
char** argv = NULL;
|
|
blocked = wxPyBeginBlockThreads();
|
|
PyObject* sysargv = PySys_GetObject("argv");
|
|
if (sysargv != NULL) {
|
|
argc = PyList_Size(sysargv);
|
|
argv = new char*[argc+1];
|
|
int x;
|
|
for(x=0; x<argc; x++) {
|
|
PyObject *pyArg = PyList_GetItem(sysargv, x); // borrowed reference
|
|
// if there isn't anything in sys.argv[0] then set it to the python executable
|
|
if (x == 0 && PyObject_Length(pyArg) < 1)
|
|
pyArg = PySys_GetObject("executable");
|
|
argv[x] = strdup(PyString_AsString(pyArg));
|
|
}
|
|
argv[argc] = NULL;
|
|
}
|
|
wxPyEndBlockThreads(blocked);
|
|
|
|
|
|
// Initialize wxWidgets
|
|
#ifdef __WXOSX__
|
|
wxMacAutoreleasePool autoreleasePool;
|
|
#endif
|
|
result = wxEntryStart(argc, argv);
|
|
// wxApp takes ownership of the argv array, don't delete it here
|
|
|
|
blocked = wxPyBeginBlockThreads();
|
|
if (! result) {
|
|
PyErr_SetString(PyExc_SystemError,
|
|
"wxEntryStart failed, unable to initialize wxWidgets!"
|
|
#ifdef __WXGTK__
|
|
" (Is DISPLAY set properly?)"
|
|
#endif
|
|
);
|
|
goto error;
|
|
}
|
|
wxPyEndBlockThreads(blocked);
|
|
haveInitialized = true;
|
|
}
|
|
else {
|
|
this->argc = 0;
|
|
}
|
|
|
|
// It's now ok to generate exceptions for assertion errors.
|
|
SetStartupComplete(true);
|
|
|
|
// Call the Python wxApp's OnPreInit and OnInit functions if they exist
|
|
OnPreInit();
|
|
result = OnInit();
|
|
|
|
blocked = wxPyBeginBlockThreads();
|
|
if (! result) {
|
|
PyErr_SetString(PyExc_SystemExit, "OnInit returned false, exiting...");
|
|
}
|
|
error:
|
|
wxPyEndBlockThreads(blocked);
|
|
}
|
|
|
|
|
|
int wxPyApp::MainLoop()
|
|
{
|
|
int retval = 0;
|
|
|
|
{
|
|
#ifdef __WXOSX__
|
|
wxMacAutoreleasePool autoreleasePool;
|
|
#endif
|
|
DeletePendingObjects();
|
|
}
|
|
bool initialized = wxTopLevelWindows.GetCount() != 0;
|
|
if (initialized) {
|
|
if ( m_exitOnFrameDelete == Later ) {
|
|
m_exitOnFrameDelete = Yes;
|
|
}
|
|
|
|
retval = wxApp::MainLoop();
|
|
OnExit();
|
|
}
|
|
return retval;
|
|
}
|
|
|
|
|
|
// 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 IsDisplayAvailable().
|
|
bool wxPyApp::IsDisplayAvailable()
|
|
{
|
|
#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
|
|
}
|
|
|
|
|
|
|
|
wxPyApp* wxGetApp()
|
|
{
|
|
return wxPyApp::ms_appInstance;
|
|
}
|
|
%End
|
|
|
|
public:
|
|
wxPyApp();
|
|
|
|
virtual
|
|
~wxPyApp();
|
|
|
|
virtual
|
|
void MacNewFile();
|
|
|
|
virtual
|
|
void MacOpenFile(
|
|
const wxString & fileName
|
|
);
|
|
|
|
virtual
|
|
void MacOpenURL(
|
|
const wxString & url
|
|
);
|
|
|
|
virtual
|
|
void MacPrintFile(
|
|
const wxString & fileName
|
|
);
|
|
|
|
virtual
|
|
void MacReopenApp();
|
|
|
|
static
|
|
long GetMacAboutMenuItemId();
|
|
|
|
static
|
|
long GetMacPreferencesMenuItemId();
|
|
|
|
static
|
|
long GetMacExitMenuItemId();
|
|
|
|
static
|
|
wxString GetMacHelpMenuTitleName();
|
|
|
|
static
|
|
void SetMacAboutMenuItemId(
|
|
long val
|
|
);
|
|
|
|
static
|
|
void SetMacPreferencesMenuItemId(
|
|
long val
|
|
);
|
|
|
|
static
|
|
void SetMacExitMenuItemId(
|
|
long val
|
|
);
|
|
|
|
static
|
|
void SetMacHelpMenuTitleName(
|
|
const wxString & val
|
|
);
|
|
|
|
wxVideoMode GetDisplayMode();
|
|
|
|
bool GetExitOnFrameDelete();
|
|
|
|
wxLayoutDirection GetLayoutDirection();
|
|
|
|
bool GetUseBestVisual();
|
|
|
|
wxWindow * GetTopWindow();
|
|
|
|
bool IsActive();
|
|
|
|
bool SafeYield(
|
|
wxWindow * win,
|
|
bool onlyIfNeeded
|
|
);
|
|
|
|
bool SafeYieldFor(
|
|
wxWindow * win,
|
|
long eventsToProcess
|
|
);
|
|
|
|
bool SendIdleEvents(
|
|
wxWindow * win,
|
|
wxIdleEvent & event
|
|
);
|
|
|
|
bool SetDisplayMode(
|
|
const wxVideoMode & info
|
|
);
|
|
|
|
void SetExitOnFrameDelete(
|
|
bool flag
|
|
);
|
|
|
|
bool SetNativeTheme(
|
|
const wxString & theme
|
|
);
|
|
|
|
void SetTopWindow(
|
|
wxWindow * window
|
|
);
|
|
|
|
void SetUseBestVisual(
|
|
bool flag,
|
|
bool forceTrueColour = false
|
|
);
|
|
|
|
%TypeCode
|
|
void _wxPyApp_MacHideApp(wxPyApp* self, int& _isErr)
|
|
{
|
|
#ifdef __WXMAC__
|
|
self->MacHideApp();
|
|
#endif
|
|
}
|
|
%End
|
|
void MacHideApp();
|
|
%MethodCode
|
|
_wxPyApp_MacHideApp(sipCpp, sipIsErr);
|
|
%End
|
|
|
|
wxAppAssertMode GetAssertMode();
|
|
void SetAssertMode(wxAppAssertMode mode);
|
|
void _BootstrapApp();
|
|
static bool IsDisplayAvailable();
|
|
|
|
virtual int MainLoop();
|
|
virtual void OnPreInit();
|
|
virtual bool OnInit();
|
|
virtual bool OnInitGui();
|
|
virtual int OnRun();
|
|
virtual int OnExit();
|
|
|
|
|
|
%Property(name=DisplayMode, get=GetDisplayMode, set=SetDisplayMode)
|
|
%Property(name=ExitOnFrameDelete, get=GetExitOnFrameDelete, set=SetExitOnFrameDelete)
|
|
%Property(name=LayoutDirection, get=GetLayoutDirection)
|
|
%Property(name=UseBestVisual, get=GetUseBestVisual, set=SetUseBestVisual)
|
|
%Property(name=TopWindow, get=GetTopWindow, set=SetTopWindow)
|
|
}; // end of class wxPyApp
|
|
|
|
|
|
wxPyApp* wxGetApp();
|
|
|
|
|
|
bool wxHandleFatalExceptions(
|
|
bool doIt = true
|
|
);
|
|
|
|
void wxWakeUpIdle();
|
|
|
|
bool wxYield();
|
|
|
|
bool wxSafeYield(
|
|
wxWindow * win = NULL,
|
|
bool onlyIfNeeded = false
|
|
);
|
|
|
|
void wxExit();
|
|
|
|
%Extract(id=pycode)
|
|
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
# This code block was included from src/app_ex.py
|
|
|
|
class PyOnDemandOutputWindow:
|
|
"""
|
|
A class that can be used for redirecting Python's stdout and
|
|
stderr streams. It will do nothing until something is wrriten to
|
|
the stream at which point it will create a Frame with a text area
|
|
and write the text there.
|
|
"""
|
|
def __init__(self, title="wxPython: stdout/stderr"):
|
|
self.frame = None
|
|
self.title = title
|
|
self.pos = wx.DefaultPosition
|
|
self.size = (450, 300)
|
|
self.parent = None
|
|
|
|
def SetParent(self, parent):
|
|
"""Set the window to be used as the popup Frame's parent."""
|
|
self.parent = parent
|
|
|
|
|
|
def CreateOutputWindow(self, st):
|
|
self.frame = wx.Frame(self.parent, -1, self.title, self.pos, self.size,
|
|
style=wx.DEFAULT_FRAME_STYLE)
|
|
self.text = wx.TextCtrl(self.frame, -1, "",
|
|
style=wx.TE_MULTILINE|wx.TE_READONLY)
|
|
self.text.AppendText(st)
|
|
self.frame.Show(True)
|
|
self.frame.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
|
|
|
|
|
def OnCloseWindow(self, event):
|
|
if self.frame is not None:
|
|
self.frame.Destroy()
|
|
self.frame = None
|
|
self.text = None
|
|
self.parent = None
|
|
|
|
|
|
# These methods provide the file-like output behaviour.
|
|
def write(self, text):
|
|
"""
|
|
Create the output window if needed and write the string to it.
|
|
If not called in the context of the gui thread then uses
|
|
CallAfter to do the work there.
|
|
"""
|
|
if self.frame is None:
|
|
if not wx.Thread.IsMain():
|
|
wx.CallAfter(self.CreateOutputWindow, text)
|
|
else:
|
|
self.CreateOutputWindow(text)
|
|
else:
|
|
if not wx.Thread.IsMain():
|
|
wx.CallAfter(self.text.AppendText, text)
|
|
else:
|
|
self.text.AppendText(text)
|
|
|
|
|
|
def close(self):
|
|
if self.frame is not None:
|
|
wx.CallAfter(self.frame.Close)
|
|
|
|
|
|
def flush(self):
|
|
pass
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
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 native windowing system main message or event loop,
|
|
and to dispatch events to window instances
|
|
* etc.
|
|
|
|
Every wx application must have a single ``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)``,
|
|
however ``wx.App`` is also usable on it's own without derivation.
|
|
"""
|
|
|
|
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.Port == "__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."""
|
|
|
|
elif wx.Port == "__WXGTK__":
|
|
msg ="Unable to access the X Display, is $DISPLAY set properly?"
|
|
|
|
else:
|
|
msg = "Unable to create GUI"
|
|
# TODO: more description is needed for wxMSW...
|
|
|
|
raise SystemExit(msg)
|
|
|
|
# This has to be done before OnInit
|
|
self.SetUseBestVisual(useBestVisual)
|
|
|
|
# Set the default handler for SIGINT. This fixes a problem
|
|
# where if Ctrl-C is pressed in the console that started this
|
|
# app then it will not appear to do anything, (not even send
|
|
# KeyboardInterrupt???) but will later segfault on exit. By
|
|
# setting the default handler then the app will exit, as
|
|
# expected (depending on platform.)
|
|
if clearSigInt:
|
|
try:
|
|
import signal
|
|
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
|
except:
|
|
pass
|
|
|
|
# Save and redirect the stdio to a window?
|
|
self.stdioWin = None
|
|
self.saveStdio = (_sys.stdout, _sys.stderr)
|
|
if redirect:
|
|
self.RedirectStdio(filename)
|
|
|
|
## # Use Python's install prefix as the default
|
|
## wx.StandardPaths.Get().SetInstallPrefix(_sys.prefix)
|
|
|
|
## # Until the new native control for wxMac is up to par, still use the generic one.
|
|
## wx.SystemOptions.SetOptionInt("mac.listctrl.always_use_generic", 1)
|
|
|
|
# This finishes the initialization of wxWindows and then calls
|
|
# the OnInit that should be present in the derived class
|
|
self._BootstrapApp()
|
|
|
|
|
|
def OnPreInit(self):
|
|
"""
|
|
Things that must be done after _BootstrapApp has done its thing, but
|
|
would be nice if they were already done by the time that OnInit is
|
|
called.
|
|
"""
|
|
## wx.StockGDI._initStockObjects()
|
|
|
|
|
|
def __del__(self):
|
|
self.RestoreStdio() # Just in case the MainLoop was overridden
|
|
|
|
|
|
def Destroy(self):
|
|
## self.this.own(False)
|
|
wx.PyApp.Destroy(self)
|
|
|
|
def SetTopWindow(self, frame):
|
|
"""Set the \"main\" top level window"""
|
|
if self.stdioWin:
|
|
self.stdioWin.SetParent(frame)
|
|
wx.PyApp.SetTopWindow(self, frame)
|
|
|
|
|
|
def MainLoop(self):
|
|
"""Execute the main GUI event loop"""
|
|
wx.PyApp.MainLoop(self)
|
|
self.RestoreStdio()
|
|
|
|
|
|
def RedirectStdio(self, filename=None):
|
|
"""Redirect sys.stdout and sys.stderr to a file or a popup window."""
|
|
if filename:
|
|
_sys.stdout = _sys.stderr = open(filename, 'a')
|
|
else:
|
|
self.stdioWin = self.outputWindowClass()
|
|
_sys.stdout = _sys.stderr = self.stdioWin
|
|
|
|
|
|
def RestoreStdio(self):
|
|
try:
|
|
_sys.stdout, _sys.stderr = self.saveStdio
|
|
except:
|
|
pass
|
|
|
|
|
|
def SetOutputWindowAttributes(self, title=None, pos=None, size=None):
|
|
"""
|
|
Set the title, position and/or size of the output window if the stdio
|
|
has been redirected. This should be called before any output would
|
|
cause the output window to be created.
|
|
"""
|
|
if self.stdioWin:
|
|
if title is not None:
|
|
self.stdioWin.title = title
|
|
if pos is not None:
|
|
self.stdioWin.pos = pos
|
|
if size is not None:
|
|
self.stdioWin.size = size
|
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
@deprecated
|
|
class PySimpleApp(App):
|
|
"""
|
|
This class is deprecated. Please use wx.App instead.
|
|
"""
|
|
def __init__(self, *args, **kw):
|
|
App.__init__(self, *args, **kw)
|
|
|
|
|
|
## #----------------------------------------------------------------------------
|
|
## # DO NOT hold any other references to this object. This is how we
|
|
## # know when to cleanup system resources that wxWidgets is holding. When
|
|
## # the sys module is unloaded, the refcount on sys.__wxPythonCleanup
|
|
## # goes to zero and it calls the wx.App_CleanUp function.
|
|
|
|
## #class __wxPyCleanup:
|
|
## #def __init__(self):
|
|
## #self.cleanup = _core_.App_CleanUp
|
|
## #def __del__(self):
|
|
## #self.cleanup()
|
|
|
|
## #_sys.__wxPythonCleanup = __wxPyCleanup()
|
|
|
|
# End of included code block
|
|
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
|
|
%End
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|