clipboard format error

Hi all,

I have the following piece of code in wich I want the read the contents of the clipboard:

78: x = win32clipboard.RegisterClipboardFormat(str(win32con.CF_UNICODETEXT))
79: print x
80: win32clipboard.OpenClipboard(None)
81: strSource = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT)
82: win32clipboard.CloseClipboard()

It gives me the following error:

49842
Traceback (most recent call last):
File “ET_Gui.pyc”, line 189, in OnMenu_FileOpen
File “ET_Classes.pyc”, line 81, in FileOpen
TypeError: Specified clipboard format is not available

But ONLY the first time after I have booted my computer. If I close and restart the program the error doesn’t occur anymore. Also, when I run the program from my IDE (Eclipse/Pydev) the error doesn’t occur at all.

Does anyone have an idea?

Thanks,
Frans

···

Express yourself instantly with MSN Messenger! MSN Messenger

Hi Frans,

Hi all,
I have the following piece of code in wich I want the read the contents of the clipboard:
78: x = win32clipboard.RegisterClipboardFormat(str(win32con.CF_UNICODETEXT))
79: print x
80: win32clipboard.OpenClipboard(None)
81: strSource = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT)
82: win32clipboard.CloseClipboard()

It gives me the following error:
49842
Traceback (most recent call last):
  File "ET_Gui.pyc", line 189, in OnMenu_FileOpen
  File "ET_Classes.pyc", line 81, in FileOpen
TypeError: Specified clipboard format is not available

But ONLY the first time after I have booted my computer. If I close and restart the program the error doesn't occur anymore. Also, when I run the program from my IDE (Eclipse/Pydev) the error doesn't occur at all.
Does anyone have an idea?
Thanks,
Frans

This is a shot in the dark, but it sounds kind of like a unicode error of some sort. However, wx provides a wrapper for the clipboard called wx.Clipboard. I recommend giving that a try:

http://wxpython.org/docs/api/wx.Clipboard-class.html
http://wiki.wxpython.org/ClipBoard

If you really need the win32con method, you might try posting to the PyWin32 group: python-win32 Info Page

HTH

···

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org

Thanks, Mike.

It works with wx.TheClipboard().

Frans

···

Date: Mon, 17 Nov 2008 11:15:46 -0600
From: mike@pythonlibrary.org
To: wxpython-users@lists.wxwidgets.org
Subject: Re: [wxpython-users] clipboard format error

Hi Frans,

Hi all,

I have the following piece of code in wich I want the read the
contents of the clipboard:

78: x =
win32clipboard.RegisterClipboardFormat(str(win32con.CF_UNICODETEXT))
79: print x
80: win32clipboard.OpenClipboard(None)
81: strSource =
win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT)
82: win32clipboard.CloseClipboard()

It gives me the following error:

49842
Traceback (most recent call last):
File “ET_Gui.pyc”, line 189, in OnMenu_FileOpen
File “ET_Classes.pyc”, line 81, in FileOpen
TypeError: Specified clipboard format is not available

But ONLY the first time after I have booted my computer. If I close
and restart the program the error doesn’t occur anymore. Also, when I
run the program from my IDE (Eclipse/Pydev) the error doesn’t occur at
all.

Does anyone have an idea?

Thanks,
Frans

This is a shot in the dark, but it sounds kind of like a unicode error
of some sort. However, wx provides a wrapper for the clipboard called
wx.Clipboard. I recommend giving that a try:

wxPython API Documentation — wxPython Phoenix 4.2.2 documentation
ClipBoard - wxPyWiki

If you really need the win32con method, you might try posting to the
PyWin32 group: python-win32 Info Page

HTH


Mike Driscoll

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org


wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users


Express yourself instantly with MSN Messenger! MSN Messenger