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
This commit is contained in:
parent
fd92852491
commit
dd346b947b
@ -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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -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
|
||||
-----------
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user