"""
from globals import *
-import os, sys, getopt, re, traceback, tempfile, shutil
+import os, sys, getopt, re, traceback, tempfile, shutil, cPickle
# Local modules
from tree import * # imports xxx which imports params
self.SetSizer(sizer)
# Initialize
- self.clipboard = None
self.Clear()
# Other events
selected = tree.selection
if not selected: return # key pressed event
xxx = tree.GetPyData(selected)
- self.clipboard = xxx.element.cloneNode(True)
+ wx.TheClipboard.Open()
+ data = wx.CustomDataObject('XRCED')
+ data.SetData(cPickle.dumps(xxx.element))
+ wx.TheClipboard.SetData(data)
+ wx.TheClipboard.Close()
self.SetStatusText('Copied')
def OnPaste(self, evt):
parentLeaf = selected
parent = tree.GetPyData(parentLeaf).treeObject()
- # Create a copy of clipboard element
- elem = self.clipboard.cloneNode(True)
+ # Create a copy of clipboard pickled element
+ wx.TheClipboard.Open()
+ data = wx.CustomDataObject('XRCED')
+ if not wx.TheClipboard.IsSupported(data.GetFormat()):
+ wx.TheClipboard.Close()
+ wx.LogError('unsupported clipboard format')
+ return
+ wx.TheClipboard.GetData(data)
+ wx.TheClipboard.Close()
+ elem = cPickle.loads(data.GetData())
# Tempopary xxx object to test things
xxx = MakeXXXFromDOM(parent, elem)
elem = tree.RemoveLeaf(selected)
undoMan.RegisterUndo(UndoCutDelete(index, parent, elem))
if evt.GetId() == wxID_CUT:
- if self.clipboard: self.clipboard.unlink()
- self.clipboard = elem.cloneNode(True)
+ wx.TheClipboard.Open()
+ data = wx.CustomDataObject('XRCED')
+ data.SetData(cPickle.dumps(elem))
+ wx.TheClipboard.SetData(data)
+ wx.TheClipboard.Close()
tree.pendingHighLight = None
tree.UnselectAll()
tree.selection = None
elif evt.GetId() == wxID_SAVE:
evt.Enable(self.modified)
elif evt.GetId() in [wxID_PASTE, self.ID_TOOL_PASTE]:
- evt.Enable((self.clipboard and tree.selection) != None)
+ evt.Enable(tree.selection is not None)
elif evt.GetId() == self.ID_TEST:
evt.Enable(tree.selection is not None and tree.selection != tree.root)
elif evt.GetId() in [self.ID_LOCATE, self.ID_TOOL_LOCATE]:
def Clear(self):
self.dataFile = ''
- if self.clipboard:
- self.clipboard.unlink()
- self.clipboard = None
undoMan.Clear()
self.SetModified(False)
tree.Clear()