def onCopyProfileClipboard(self, e): try: if not wx.TheClipboard.IsOpened(): wx.TheClipboard.Open() clipData = wx.TextDataObject() self.lastTriedClipboard = profile.getProfileString() profileString = profile.insertNewlines("CURA_PROFILE_STRING:" + self.lastTriedClipboard) clipData.SetText(profileString) wx.TheClipboard.SetData(clipData) wx.TheClipboard.Close() except: print "Could not write to clipboard, unable to get ownership. Another program is using the clipboard."