wxTheClipboard problem, IDLE vs PythonWin

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Rice

    #1

    wxTheClipboard problem, IDLE vs PythonWin

    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):[color=blue][color=green][color=darkred]
    >>> from wxPython.wx import *
    >>> wxTheClipboard. Open()[/color][/color][/color]
    True[color=blue][color=green][color=darkred]
    >>> wxTheClipboard. Clear()
    >>> wxTheClipboard. SetData(wxTextD ataObject("Test 1"))[/color][/color][/color]
    True[color=blue][color=green][color=darkred]
    >>> wxTheClipboard. Close()
    >>> ## ctrl+v = Test 1[/color][/color][/color]


    From IDLE (doesn't work):[color=blue][color=green][color=darkred]
    >>> from wxPython.wx import *
    >>> wxTheClipboard. Open()[/color][/color][/color]
    True[color=blue][color=green][color=darkred]
    >>> wxTheClipboard. SetData(wxTextD ataObject("Test 2"))[/color][/color][/color]
    False[color=blue][color=green][color=darkred]
    >>> ## ctrl+v = Test 1
    >>> wxTheClipboard. Clear()
    >>> ## ctrl+v = Test 1
    >>> wxTheClipboard. Close()[/color][/color][/color]


    From Python (command-line) (doesn't work, more verbose errors):[color=blue][color=green][color=darkred]
    >>> from wxPython.wx import *
    >>> wxTheClipboard. Open()[/color][/color][/color]
    True[color=blue][color=green][color=darkred]
    >>> wxTheClipboard. SetData(wxTextD ataObject("Test 3"))[/color][/color][/color]
    02:17:48: Error: Failed to put data on the clipboard (error -2147221008:
    coIniti
    alize has not been called.)
    False[color=blue][color=green][color=darkred]
    >>> wxTheClipboard. Clear()[/color][/color][/color]
    02:17:56: Debug: ..\..\src\msw\c lipbrd.cpp(554) : 'OleSetClipboar d(NULL)'
    failed
    with error 0x00000002 (the system cannot find the file specified.).




  • Tom B.

    #2
    Re: wxTheClipboard problem, IDLE vs PythonWin


    "Tim Rice" <timrice@nosp am-gmail.com> wrote in message news:bp-dnYrA8b_ttq3cRV n-hA@adelphia.com ...[color=blue]
    > 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?[/color]

    Idle is incompatible with wxPython, what I do when I work in Idle is just double click on the file to open it (don't use the run menu unless you have an error to look up). A programming tool I have found useful with wxPython is Leo (A literate programming tool) found at http://personalpages.tds.net/~edream/front.html


    Tom

    Comment

    Working...