wxTheClipBoard error message.

Hi,
I've added a listbox panel into my application to store every time user copy something into the clipboard.
For this I used a IDLE event associated to this:

    def Copy(self, event):
  clipdata = wxTextDataObject()
  wxTheClipboard.Open()
  success = wxTheClipboard.GetData(clipdata)
  id = self.clip_list.GetCount() - 1
  if not id < 0:
    if self.clip_list.GetClientData(id) == clipdata.GetText():
      return
  if success:
    try:
      self.addToClipBoard(clipdata.GetText())
      self.searchedWords.append(clipdata.GetText().split('\n')[0])
    except: pass
  wxTheClipboard.Close()

Very often, about 1 of 2 times, i get this error message:
"Failed to get data from the clipboard (error -2417221040: openClipboard non riuscita)"

I think this is a windows error message, but ho to prevent this?

thanks

Alessandro Crugnola - sephiroth

···

---------------------------------------------
Macromedia Flash Team Volunteer
http://www.macromedia.com/go/team
Flash && PHP developer
alessandro@sephiroth.it
---------------------------------------------

Alessandro Crugnola *sephiroth* wrote:

Hi,
I've added a listbox panel into my application to store every time user copy something into the clipboard.
For this I used a IDLE event associated to this:

    def Copy(self, event):
  clipdata = wxTextDataObject()
  wxTheClipboard.Open()
  success = wxTheClipboard.GetData(clipdata)
  id = self.clip_list.GetCount() - 1
  if not id < 0:
    if self.clip_list.GetClientData(id) == clipdata.GetText():
      return
  if success:
    try:
      self.addToClipBoard(clipdata.GetText())
      self.searchedWords.append(clipdata.GetText().split('\n')[0])
    except: pass
  wxTheClipboard.Close()

Very often, about 1 of 2 times, i get this error message:
"Failed to get data from the clipboard (error -2417221040: openClipboard non riuscita)"

I think this is a windows error message, but ho to prevent this?

What does "non riuscita" translate to in english? In any case there are a couple things I can guess might make it better. First move the Close statement up to right after the GetData as there is no need to keep it open any longer than that. Secondly, idle events can sometimes happen very quickly but there is probably no need to do the above more than once or twice per second (if that much) so you may want to use a timer event instead of idle.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

::What does "non riuscita" translate to in english? In any
::case there are a couple things I can guess might make it
::better. First move the Close statement up to right after the
::GetData as there is no need to keep it open any longer than
::that. Secondly, idle events can sometimes happen very
::quickly but there is probably no need to do the above more
::than once or twice per second (if that much) so you may want
::to use a timer event instead of idle.

Yes, sorry.. "non riuscita" means "it can't be able to.."
I'll try to use an interval, thanks.
thanks

Alessandro Crugnola [ sephiroth ]
alessandro@sephiroth.it
Flash & PHP Developer