wxTheClipboard problem, IDLE vs PythonWin
Tim Rice
timrice at nospam-gmail.com
Sat Aug 28 02:53:32 EDT 2004
I have a need to write data to the Windows clipboard from a Python script.
I found a nice, simple solution @
http://wiki.wxpython.org/index.cgi/ClipBoard. The problem is, I can only
get it to work from within the PythonWin and SPE IDE's. I get errors if I
try to run the exact same code from the command line or via IDLE's
interactive shell. I can't figure it out. Any ideas? Possibly something
missing from my PYTHONPATH environment variable?
Any help is appreciated. Thanks,
Tim
>From PythonWin (works fine):
>>> from wxPython.wx import *
>>> wxTheClipboard.Open()
True
>>> wxTheClipboard.Clear()
>>> wxTheClipboard.SetData(wxTextDataObject("Test 1"))
True
>>> wxTheClipboard.Close()
>>> ## ctrl+v = Test 1
>From IDLE (doesn't work):
>>> from wxPython.wx import *
>>> wxTheClipboard.Open()
True
>>> wxTheClipboard.SetData(wxTextDataObject("Test 2"))
False
>>> ## ctrl+v = Test 1
>>> wxTheClipboard.Clear()
>>> ## ctrl+v = Test 1
>>> wxTheClipboard.Close()
>From Python (command-line) (doesn't work, more verbose errors):
>>> from wxPython.wx import *
>>> wxTheClipboard.Open()
True
>>> wxTheClipboard.SetData(wxTextDataObject("Test 3"))
02:17:48: Error: Failed to put data on the clipboard (error -2147221008:
coIniti
alize has not been called.)
False
>>> wxTheClipboard.Clear()
02:17:56: Debug: ..\..\src\msw\clipbrd.cpp(554): 'OleSetClipboard(NULL)'
failed
with error 0x00000002 (the system cannot find the file specified.).
More information about the Python-list
mailing list