If I'm right then with wxPython the only way to place something on the
clipboard is to calculate the data and create a DataObject.
The disadvantage is that the calculation may be time and/or
memory intensive, especially when I want to offer multiple
different formats.
Is there a way to calculate the data only on demand?
The standard way under win32 is to claim the clipboard
using this way:
Once another application wants to get the data,
we receive a win32con.WM_RENDERFORMAT event and then use
win32clipboard.SetClipboardData(win32con.CF_TEXT, "Text")
to actually place the text on the clipboard.
Is there a cross-platform or win32 way under wxPython to achieve
the same?
Plan B:
It's probably OK to use win32clipboard from within a wx
application, but how can I register a handler for a
WM_RENDERFORMAT event without messing things up?
Once another application wants to get the data,
we receive a win32con.WM_RENDERFORMAT event and then use
win32clipboard.SetClipboardData(win32con.CF_TEXT, "Text")
to actually place the text on the clipboard.
Is there a cross-platform or win32 way under wxPython to achieve
the same?
Perhaps surprisingly, the behavior of the clipboard is one thing that
varies wildly among the various GUI systems. This is not just a Python
thing, it's something all application authors have to battle. X, for
example, dictates no clipboard policy at all. It was left to window
managers and desktop environments to decide that.
Plan B:
It's probably OK to use win32clipboard from within a wx
application, but how can I register a handler for a
WM_RENDERFORMAT event without messing things up?
You don't have to mess things up. You just need to subclass the
window. That's common in the C++ world; not as common, but still
possible in the Python world: HookingTheWndProc - wxPyWiki
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Once another application wants to get the data,
we receive a win32con.WM_RENDERFORMAT event and then use
win32clipboard.SetClipboardData(win32con.CF_TEXT, "Text")
to actually place the text on the clipboard.
Is there a cross-platform or win32 way under wxPython to achieve
the same?
Perhaps surprisingly, the behavior of the clipboard is one thing that
varies wildly among the various GUI systems. This is not just a Python
thing, it's something all application authors have to battle. X, for
example, dictates no clipboard policy at all. It was left to window
managers and desktop environments to decide that.
Plan B:
It's probably OK to use win32clipboard from within a wx
application, but how can I register a handler for a
WM_RENDERFORMAT event without messing things up?
You don't have to mess things up. You just need to subclass the
window. That's common in the C++ world; not as common, but still
possible in the Python world: HookingTheWndProc - wxPyWiki
wxWidgets does support dealing with the clipboard at a lower level and not having to provide the data until it is asked for in a supported format. Unfortunately that was a little too complex and messy for the wxPython wrappers and I never got around to making it possible to do that from Python. Until Phoenix. The Phoenix wrappers of the data object classes allow fully overriding all the pertinent virtual methods and also doing data transfers to/from the clipboard (or the other end of the clipboard transaction actually) using Python memoryview or other buffer objects.
Thanks a lot. That's cool and I will probably take this route.
Regards,
Dietmar
···
Am 21.02.2013 18:52, schrieb Tim Roberts:
Dietmar Schwertberger wrote:
It's probably OK to use win32clipboard from within a wx
application, but how can I register a handler for a
WM_RENDERFORMAT event without messing things up?
You don't have to mess things up. You just need to subclass the
window. That's common in the C++ world; not as common, but still
possible in the Python world: HookingTheWndProc - wxPyWiki