wxGTK now uses gtk_init_check so wxPython can raise an exception if

there is no DISPLAY available or other initializaion problem.

wx.GetKeyState now has an implementation for wxGTK and is able to
detect the up/down or toggle state of modifier and toggle keys.

The LC_NUMERIC locale is now reset back to "C" (compatibility) when
running on wxGTK to work around the fact that GTK requires the locale
to be set to the system settings but Python depends on LC_NUMERIC
remaining compatible with "C".


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27376 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2004-05-21 00:23:50 +00:00
parent c156411a08
commit 89c876de1c
6 changed files with 39 additions and 35 deletions

View File

@@ -50,9 +50,19 @@ a very small amount of overhead and removes several unneccessary
problems. problems.
Replaced wx/lib/pubsub.py with a version that uses weak references to Replaced wx/lib/pubsub.py with a version that uses weak references to
track the subscribers. Thanks go to Oliver Schoenborn and Robb track the subscribers, plus other fixes/additions. Thanks go to
Shecter. Oliver Schoenborn and Robb Shecter.
wxGTK now uses gtk_init_check so wxPython can raise an exception if
there is no DISPLAY available or other initializaion problem.
wx.GetKeyState now has an implementation for wxGTK and is able to
detect the up/down or toggle state of modifier and toggle keys.
The LC_NUMERIC locale is now reset back to "C" (compatibility) when
running on wxGTK to work around the fact that GTK requires the locale
to be set to the system settings but Python depends on LC_NUMERIC
remaining compatible with "C".

View File

@@ -209,17 +209,11 @@ wxWindow* wxGetTopLevelParent(wxWindow *win);
#if defined(__WXMSW__) || defined(__WXMAC__)
// Get the state of a key (true if pressed, false if not) // Get the state of a key (true if pressed, false if not)
// This is generally most useful getting the state of // This is generally most useful getting the state of
// Caps Lock, Num Lock and Scroll Lock... // the modifier or toggle keys.
bool wxGetKeyState(wxKeyCode key); bool wxGetKeyState(wxKeyCode key);
#else
%inline %{
bool wxGetKeyState(wxKeyCode key)
{ wxPyRaiseNotImplemented(); return False; }
%}
#endif
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@@ -1,14 +1,5 @@
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# wxGTK sets the locale when initialized. Doing this at the Python # On MSW add the directory where the wxWidgets catalogs were installed
# level should set it up to match what GTK is doing at the C level.
if wx.Platform == "__WXGTK__":
try:
import locale
locale.setlocale(locale.LC_ALL, "")
except:
pass
# On MSW add the directory where the wxWindows catalogs were installed
# to the default catalog path. # to the default catalog path.
if wx.Platform == "__WXMSW__": if wx.Platform == "__WXMSW__":
import os import os

View File

@@ -2306,16 +2306,16 @@ def EncodingConverter_CanConvert(*args, **kwargs):
return _gdi_.EncodingConverter_CanConvert(*args, **kwargs) return _gdi_.EncodingConverter_CanConvert(*args, **kwargs)
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# wxGTK sets the locale when initialized. Doing this at the Python ## # wxGTK sets the locale when initialized. Doing this at the Python
# level should set it up to match what GTK is doing at the C level. ## # level should set it up to match what GTK is doing at the C level.
if wx.Platform == "__WXGTK__": ## if wx.Platform == "__WXGTK__":
try: ## try:
import locale ## import locale
locale.setlocale(locale.LC_ALL, "") ## locale.setlocale(locale.LC_ALL, "")
except: ## except:
pass ## pass
# On MSW add the directory where the wxWindows catalogs were installed # On MSW add the directory where the wxWidgets catalogs were installed
# to the default catalog path. # to the default catalog path.
if wx.Platform == "__WXMSW__": if wx.Platform == "__WXMSW__":
import os import os

View File

@@ -527,10 +527,6 @@ SWIG_FromUnsignedLong(unsigned long value)
} }
bool wxGetKeyState(wxKeyCode key)
{ wxPyRaiseNotImplemented(); return False; }
void wxWakeUpMainThread() {} void wxWakeUpMainThread() {}

View File

@@ -29,6 +29,7 @@
#include <gdk/gdkprivate.h> #include <gdk/gdkprivate.h>
#include <wx/gtk/win_gtk.h> #include <wx/gtk/win_gtk.h>
#define GetXWindow(wxwin) GDK_WINDOW_XWINDOW((wxwin)->m_widget->window) #define GetXWindow(wxwin) GDK_WINDOW_XWINDOW((wxwin)->m_widget->window)
#include <locale.h>
#endif #endif
#ifdef __WXX11__ #ifdef __WXX11__
@@ -398,15 +399,28 @@ void wxPyApp::_BootstrapApp()
} }
wxPyEndBlockThreads(blocked); wxPyEndBlockThreads(blocked);
// Initialize wxWidgets
result = wxEntryStart(argc, argv); result = wxEntryStart(argc, argv);
delete [] argv; delete [] argv;
blocked = wxPyBeginBlockThreads(); blocked = wxPyBeginBlockThreads();
if (! result) { if (! result) {
PyErr_SetString(PyExc_SystemError, "wxEntryStart failed!"); PyErr_SetString(PyExc_SystemError,
"wxEntryStart failed, unable to initialize wxWidgets!"
#ifdef __WXGTK__
" (Is DISPLAY set properly?)"
#endif
);
goto error; goto error;
} }
// On wxGTK the locale will be changed to match the system settings, but
// Python needs to have LC_NUMERIC set to "C" in order for the floating
// point conversions and such to work right.
#ifdef __WXGTK__
setlocale(LC_NUMERIC, "C");
#endif
// The stock objects were all NULL when they were loaded into // The stock objects were all NULL when they were loaded into
// SWIG generated proxies, so re-init those now... // SWIG generated proxies, so re-init those now...
wxPy_ReinitStockObjects(3); wxPy_ReinitStockObjects(3);
@@ -437,7 +451,6 @@ void wxPyApp::_BootstrapApp()
result = True; result = True;
} }
if (! result) { if (! result) {
PyErr_SetString(PyExc_SystemExit, "OnInit returned False, exiting..."); PyErr_SetString(PyExc_SystemExit, "OnInit returned False, exiting...");
} }