+
+ void _SetDashes(PyObject* _self, PyObject* pyDashes) {
+ bool blocked = wxPyBeginBlockThreads();
+ int size = PyList_Size(pyDashes);
+ wxDash* dashes = (wxDash*)byte_LIST_helper(pyDashes);
+
+ // black magic warning! The array of wxDashes needs to exist as
+ // long as the pen does because wxPen does not copy the array. So
+ // stick a copy in a Python string object and attach it to _self,
+ // and then call SetDashes with a pointer to that array. Then
+ // when the Python pen object is destroyed the array will be
+ // cleaned up too.
+ PyObject* strDashes = PyString_FromStringAndSize((char*)dashes, size*sizeof(wxDash));
+ PyObject_SetAttrString(_self, "_dashes", strDashes);
+
+ self->SetDashes(size, (wxDash*)PyString_AS_STRING(strDashes));
+ delete [] dashes;
+ Py_DECREF(strDashes);
+ wxPyEndBlockThreads(blocked);
+ }
+ }
+ %pythoncode {
+ def SetDashes(self, dashes):
+ """
+ Associate a list of dash lengths with the Pen.
+ """
+ self._SetDashes(self, dashes)