From: Robin Dunn Date: Wed, 10 Mar 2004 18:53:01 +0000 (+0000) Subject: Added wx.PlatformInfo which is a tuple containing strings that X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/dd346b947bac6295b5a8fe5eb15a72c0f4be718e Added wx.PlatformInfo which is a tuple containing strings that describe the platform and build options of wxPython. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26174 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/wxPython/docs/CHANGES.txt b/wxPython/docs/CHANGES.txt index c503135bcf..a82ddba9ba 100644 --- a/wxPython/docs/CHANGES.txt +++ b/wxPython/docs/CHANGES.txt @@ -83,6 +83,10 @@ Added wx.Display and wx.VideoMode. AppleEvents can be handled by overriding wx.App methods MacOpenFile, MacPrintFile, MacNewFile, and MacReopenApp. +Added wx.PlatformInfo which is a tuple containing strings that +describe the platform and build options of wxPython. See the +MigrationGuide for more details. + diff --git a/wxPython/docs/MigrationGuide.txt b/wxPython/docs/MigrationGuide.txt index c469b3808f..9a510f0e1d 100644 --- a/wxPython/docs/MigrationGuide.txt +++ b/wxPython/docs/MigrationGuide.txt @@ -415,6 +415,31 @@ Insert, Prepend, and etc.) methods any longer. Just use Add and the wrappers will figure out what to do. +PlatformInfo +------------ + +Added wx.PlatformInfo which is a tuple containing strings that +describe the platform and build options of wxPython. This lets you +know more about the build than just the __WXPORT__ value that +wx.Platform contains, such as if it is a GTK2 build. For example, +instead of:: + + if wx.Platform == "__WXGTK__": + ... + +you should do this:: + + if "__WXGTK__" in wx.PlatformInfo: + ... + +and you can specifically check for a wxGTK2 build by looking for +"gtk2" in wx.PlatformInfo. Unicode builds are also detectable this +way. If there are any other platform/toolkit/build flags that make +sense to add to this tuple please let me know. + +BTW, wx.Platform will probably be deprecated in the future. + + Other Stuff ----------- diff --git a/wxPython/src/helpers.cpp b/wxPython/src/helpers.cpp index 5416f937a5..79c46641b6 100644 --- a/wxPython/src/helpers.cpp +++ b/wxPython/src/helpers.cpp @@ -561,18 +561,23 @@ PyObject* __wxPySetDictionary(PyObject* /* self */, PyObject* args) #ifdef __WXMOTIF__ #define wxPlatform "__WXMOTIF__" +#define wxPlatName "wxMotif" #endif #ifdef __WXX11__ #define wxPlatform "__WXX11__" +#define wxPlatName "wxX11" #endif #ifdef __WXGTK__ #define wxPlatform "__WXGTK__" +#define wxPlatName "wxGTK" #endif -#if defined(__WIN32__) || defined(__WXMSW__) +#ifdef __WXMSW__ #define wxPlatform "__WXMSW__" +#define wxPlatName "wxMSW" #endif #ifdef __WXMAC__ #define wxPlatform "__WXMAC__" +#define wxPlatName "wxMac" #endif #ifdef __WXDEBUG__ @@ -581,10 +586,41 @@ PyObject* __wxPySetDictionary(PyObject* /* self */, PyObject* args) int wxdebug = 0; #endif + // These should be deprecated in favor of the PlatformInfo tuple built below... PyDict_SetItemString(wxPython_dict, "Platform", PyString_FromString(wxPlatform)); PyDict_SetItemString(wxPython_dict, "USE_UNICODE", PyInt_FromLong(wxUSE_UNICODE)); PyDict_SetItemString(wxPython_dict, "__WXDEBUG__", PyInt_FromLong(wxdebug)); + + PyObject* PlatInfo = PyList_New(0); + PyObject* obj; + +#define _AddInfoString(st) \ + obj = PyString_FromString(st); \ + PyList_Append(PlatInfo, obj); \ + Py_DECREF(obj) + + _AddInfoString(wxPlatform); + _AddInfoString(wxPlatName); +#if wxUSE_UNICODE + _AddInfoString("unicode"); +#else + _AddInfoString("ascii"); +#endif +#ifdef __WXGTK__ +#ifdef __WXGTK20__ + _AddInfoString("gtk2"); +#else + _AddInfoString("gtk1"); +#endif +#endif + +#undef _AddInfoString + + PyObject* PlatInfoTuple = PyList_AsTuple(PlatInfo); + Py_DECREF(PlatInfo); + PyDict_SetItemString(wxPython_dict, "PlatformInfo", PlatInfoTuple); + RETURN_NONE(); }