mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-06 20:10:08 +01:00
* Rename the wrappers for the C++ wxPlatformInfo to wx.PlatformInformation.
* Restore the wx.PlatformInfo tuple like it exists in Classic. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71270 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -111,28 +111,6 @@ your encoding to Unicode before passing the text to the wx API.
|
||||
|
||||
|
||||
|
||||
wx.Platform, wx.PlatformInfo
|
||||
----------------------------
|
||||
|
||||
wx.Platform has been renamed to wx.Port, and wx.PlatformInfo has been renamed
|
||||
to wx.PortInfo. The reason for this change is that wrappers for a C++ class
|
||||
named wxPlatformInfo have been added, and would have caused a name conflict
|
||||
if the old wx.PlatformInfo had not been renamed. To make transitioning a
|
||||
little easier, I've made instances of the new wx.PlatformInfo class act like
|
||||
a Python sequence containing the same items as the old wx.PlatformInfo. So
|
||||
that means that you can simply change things like this::
|
||||
|
||||
if 'wxMac' in wx.PlatformInfo:
|
||||
...
|
||||
|
||||
to this::
|
||||
|
||||
if 'wxMac' in wx.PlatformInfo.Get():
|
||||
...
|
||||
|
||||
|
||||
|
||||
|
||||
Font, Pen, and Brush Styles
|
||||
---------------------------
|
||||
|
||||
|
||||
@@ -221,13 +221,13 @@ def run():
|
||||
if wx.Port == '__WXMSW__':
|
||||
port = 'msw'
|
||||
elif wx.Port == '__WXMAC__':
|
||||
if 'wxOSX-carbon' in wx.PortInfo:
|
||||
if 'wxOSX-carbon' in wx.PlatformInfo:
|
||||
port = 'osx-carbon'
|
||||
else:
|
||||
port = 'osx-cocoa'
|
||||
elif wx.Port == '__WXGTK__':
|
||||
port = 'gtk'
|
||||
if 'gtk2' in wx.PortInfo:
|
||||
if 'gtk2' in wx.PlatformInfo:
|
||||
port = 'gtk2'
|
||||
else:
|
||||
port = '???'
|
||||
|
||||
@@ -139,7 +139,7 @@ def run():
|
||||
# button can't change color. So for the Mac we'll implement our own
|
||||
# picker using a wx.BitmapButton instead.
|
||||
module.addPyCode("""\
|
||||
if 'wxMac' in wx.PortInfo:
|
||||
if 'wxMac' in wx.PlatformInfo:
|
||||
# ColourData object to be shared by all colour pickers
|
||||
_colourData = None
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ def run():
|
||||
c = module.find('wxPlatformInfo')
|
||||
assert isinstance(c, etgtools.ClassDef)
|
||||
|
||||
# to avoid conflicts with wxPython's wx.PlatformInfo
|
||||
c.pyName = 'PlatformInformation'
|
||||
|
||||
c.find('GetEndianness').findOverload('end').ignore()
|
||||
c.find('GetArchName').findOverload('arch').ignore()
|
||||
c.find('GetOperatingSystemId').findOverload('name').ignore()
|
||||
@@ -47,10 +50,6 @@ def run():
|
||||
c.find('GetPortIdShortName').findOverload('port').ignore()
|
||||
|
||||
|
||||
# Make this class act a bit like the wx.PlatformInfo tuple in Classic
|
||||
c.addPyMethod('__getitem__', '(self, idx)', 'return wx.PortInfo[idx]')
|
||||
c.addPyMethod('__len__', '(self)', 'return len(wx.PortInfo)')
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
tools.doCommonTweaks(module)
|
||||
tools.runGenerators(module)
|
||||
|
||||
@@ -128,16 +128,18 @@ void wxPyCoreModuleInject(PyObject* moduleDict)
|
||||
|
||||
wxInitAllImageHandlers();
|
||||
|
||||
// TODO: Find some blackmagic way to deprecate wx.Platform such that it raises
|
||||
// a wraning when used... Maybe a class that returns wx.Port for any __getattr__?
|
||||
PyDict_SetItemString(moduleDict, "Port", PyString_FromString(wxPort));
|
||||
PyDict_SetItemString(moduleDict, "Platform", PyString_FromString(wxPort));
|
||||
|
||||
// Make a tuple of strings that gives more info about the platform and build.
|
||||
PyObject* PortInfo = PyList_New(0);
|
||||
PyObject* PlatformInfo = PyList_New(0);
|
||||
PyObject* obj;
|
||||
|
||||
#define _AddInfoString(st) \
|
||||
obj = PyString_FromString(st); \
|
||||
PyList_Append(PortInfo, obj); \
|
||||
PyList_Append(PlatformInfo, obj); \
|
||||
Py_DECREF(obj)
|
||||
|
||||
_AddInfoString(wxPort);
|
||||
@@ -178,7 +180,7 @@ void wxPyCoreModuleInject(PyObject* moduleDict)
|
||||
|
||||
#undef _AddInfoString
|
||||
|
||||
PyObject* PortInfoTuple = PyList_AsTuple(PortInfo);
|
||||
Py_DECREF(PortInfo);
|
||||
PyDict_SetItemString(moduleDict, "PortInfo", PortInfoTuple);
|
||||
PyObject* PlatformInfoTuple = PyList_AsTuple(PlatformInfo);
|
||||
Py_DECREF(PlatformInfo);
|
||||
PyDict_SetItemString(moduleDict, "PlatformInfo", PlatformInfoTuple);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@ if 'wxEVT_NULL' in dir():
|
||||
del _core
|
||||
else:
|
||||
Port = ''
|
||||
PortInfo = []
|
||||
Platform = ''
|
||||
PlatformInfo = []
|
||||
|
||||
import warnings
|
||||
class wxPyDeprecationWarning(DeprecationWarning):
|
||||
|
||||
@@ -18,7 +18,7 @@ class aboutdlg_Tests(wtc.WidgetTestCase):
|
||||
|
||||
|
||||
def test_aboutdlgNative(self):
|
||||
if not 'wxMSW' in wx.PlatformInfo():
|
||||
if not 'wxMSW' in wx.PlatformInfo:
|
||||
info = self._makeInfo()
|
||||
wx.CallLater(25, self.closeDialogs)
|
||||
wx.adv.AboutBox(info, self.frame)
|
||||
|
||||
@@ -95,7 +95,7 @@ class dc_Tests(wtc.WidgetTestCase):
|
||||
|
||||
def test_NativeWinHandle(self):
|
||||
dc = wx.ClientDC(self.frame)
|
||||
if 'wxMSW' in wx.PortInfo:
|
||||
if 'wxMSW' in wx.PlatformInfo:
|
||||
h = dc.GetHDC()
|
||||
self.assertNotEqual(h, 0)
|
||||
else:
|
||||
@@ -104,7 +104,7 @@ class dc_Tests(wtc.WidgetTestCase):
|
||||
|
||||
def test_NativeGTKHandle(self):
|
||||
dc = wx.ClientDC(self.frame)
|
||||
if 'wxGTK' in wx.PortInfo:
|
||||
if 'wxGTK' in wx.PlatformInfo:
|
||||
h = dc.GetGdkDrawable()
|
||||
self.assertNotEqual(h, 0)
|
||||
else:
|
||||
@@ -113,7 +113,7 @@ class dc_Tests(wtc.WidgetTestCase):
|
||||
|
||||
def test_NativeMacHandle(self):
|
||||
dc = wx.ClientDC(self.frame)
|
||||
if 'wxMac' in wx.PortInfo:
|
||||
if 'wxMac' in wx.PlatformInfo:
|
||||
h = dc.GetCGContext()
|
||||
self.assertNotEqual(h, 0)
|
||||
else:
|
||||
|
||||
@@ -29,7 +29,7 @@ class deadobj_Tests(wtc.WidgetTestCase):
|
||||
|
||||
# TODO: figure out if this is a bug in wxMSW, or just an oddity of
|
||||
# the test environment.
|
||||
if 'wxMSW' not in wx.PlatformInfo.Get():
|
||||
if 'wxMSW' not in wx.PlatformInfo:
|
||||
self.assertFalse(True if f else False)
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class dialog_Tests(wtc.WidgetTestCase):
|
||||
ok = wx.Button(dlg, wx.ID_OK, pos=(10,10))
|
||||
cancel = wx.Button(dlg, wx.ID_CANCEL, pos=(100,10))
|
||||
|
||||
if 'wxMac' not in wx.PortInfo:
|
||||
if 'wxMac' not in wx.PlatformInfo:
|
||||
# Something is causing a hang when running one of these tests, so
|
||||
# for now we'll not actually test ShowModal on Macs.
|
||||
# TODO: FIX THIS!!
|
||||
|
||||
@@ -7,21 +7,16 @@ import wx
|
||||
class platinfo_Tests(wtc.WidgetTestCase):
|
||||
|
||||
def test_platinfo(self):
|
||||
pi = wx.PlatformInfo.Get()
|
||||
pi = wx.PlatformInformation.Get()
|
||||
|
||||
pi.GetArchitecture()
|
||||
pi.GetOperatingSystemId()
|
||||
pi.GetPortId()
|
||||
|
||||
|
||||
def test_platinfoClassicCompatibility(self):
|
||||
self.assertTrue( ('wxMac' in wx.PlatformInfo.Get()) == ('wxMac' in wx.PortInfo) )
|
||||
self.assertTrue( ('wxMSW' in wx.PlatformInfo.Get()) == ('wxMSW' in wx.PortInfo) )
|
||||
self.assertTrue( ('wxGTK' in wx.PlatformInfo.Get()) == ('wxGTK' in wx.PortInfo) )
|
||||
|
||||
|
||||
def test_platinfoProperties(self):
|
||||
pi = wx.PlatformInfo.Get()
|
||||
pi = wx.PlatformInformation.Get()
|
||||
pi.ArchName
|
||||
pi.Architecture
|
||||
pi.DesktopEnvironment
|
||||
|
||||
@@ -12,7 +12,7 @@ class process_Tests(wtc.WidgetTestCase):
|
||||
def test_process1(self):
|
||||
# wx.Execute and wx.Process can only launch app bundles on OSX!! It's
|
||||
# a good thing we have the subprocess module that can be used instead.
|
||||
if 'wxMac' not in wx.PortInfo:
|
||||
if 'wxMac' not in wx.PlatformInfo:
|
||||
p = wx.Process.Open('%s %s' % (sys.executable, testscript))
|
||||
pid = p.GetPid()
|
||||
|
||||
@@ -22,7 +22,7 @@ class process_Tests(wtc.WidgetTestCase):
|
||||
def onEndProcess(evt):
|
||||
flag = True
|
||||
|
||||
if 'wxMac' not in wx.PortInfo:
|
||||
if 'wxMac' not in wx.PlatformInfo:
|
||||
p = wx.Process(self.frame)
|
||||
self.frame.Bind(wx.EVT_END_PROCESS, onEndProcess)
|
||||
wx.Execute('%s %s' % (sys.executable, testscript), callback=p)
|
||||
|
||||
@@ -42,7 +42,7 @@ class WidgetTestCase(unittest.TestCase):
|
||||
1/30 of second we need to wait a little to ensure that there will
|
||||
actually be a paint event while we are yielding.
|
||||
"""
|
||||
if 'wxOSX' in wx.PlatformInfo():
|
||||
if 'wxOSX' in wx.PlatformInfo:
|
||||
wx.MilliSleep(40) # a little more than 1/30, just in case
|
||||
window.Update()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user