I
was reading through the documentation here while porting a program from
wxPython to wxPython Phoenix and I noticed that there are no SetData and GetData functions referenced in the documentation. Furthermore, my program now seems to crash whenever trying to run GetData on a CustomDataObject and I haven’t been able to root out why. Is it just because wxPython Phoenix doesn’t have an implementation for those methods yet?
Here’s my code:
format = self.clipBoardDataFormat
if wx.TheClipboard.Open() and wx.TheClipboard.IsSupported(format):
clipData = wx.CustomDataObject(format)
wx.TheClipboard.GetData(clipData)
wx.TheClipboard.Close()
data = pickle.loads(clipData.GetData())
It seems to crash right at the last line without any kind of terminal information; I’ve narrowed it down specifically to being related to the call to GetData.
I was reading through the documentation here while porting a program
from wxPython to wxPython Phoenix and I noticed that there are no
SetData and GetData functions referenced in the documentation.
Furthermore, my program now seems to crash whenever trying to run
GetData on a CustomDataObject and I haven't been able to root out why.
Is it just because wxPython Phoenix doesn't have an implementation for
those methods yet?
I'm not sure why they are not showing up in the docs, but the methods are there. Notice that the Data property is documented as that it refers to GetData and SetData. Perhaps it is because Phoenix is explicitly ignoring the GetData and SetData definitions that it is getting from wx and adding new implementations, like this:
c.find('GetData').ignore()
c.addCppMethod('PyObject*', 'GetData', '()', isConst=True,
doc="Returns a reference to the data buffer.",
body="return wxPyMakeBuffer(self->GetData(), self->GetSize());")
c.find('SetData').ignore()
c.addCppMethod('bool', 'SetData', '(wxPyBuffer* buf)',
cppSignature='bool (size_t len, const void* buf)',
isVirtual=True,
doc="Copies data from the provided buffer to this data object's buffer",
body="return self->SetData(buf->m_len, buf->m_ptr);")
(wxPyBuffer is a custom C++ class that can be converted to/from Python memoryview objects.)
Here's my code:
Please make a small runnable sample that shows the problem and I'll take a closer look at it.