Can cut-and-paste be added to a wxPython application globally/to ListCtrl ? (II)

Hi,

Reading Manning’s book, chapter 13 (Building list controls and managing items), I’m unclear if wx.ListCtrl should support cut-and-paste (as is).

I have a ListCtrl subclass, that I want to have cut-and-paste capabilities.

Looking at http://www.wxpython.org/docs/api/wx.ListCtrl-class.html (et. al.), I don’t see that ListCtrl has any methods for cut-and-paste.

  1. Am I not looking in the correct place (or am I misunderstanding), and wx.ListCtrl does support cut-and-paste ?
  2. Is there another subclass of ListCtrl that does support cut-and-paste ?

Or, a more general question:
Can cut-and-paste be added to a wxPython application globally, namely, have Ctrl-Insert/Shift-Insert (or Ctrl-c/Ctrl-v on Windows) be supported on any widget ?

Could you point to any examples on implementing cut-and-paste, as I’m not sure I can apply Manning’s chapter 18’s (Using other wxPython functionality) example to my application.

Thanks,
Ron.

P.S.: Robin Dunn suggests that one could define Ctrl-Insert/Shift-Insert as menu accelerators and then
catch them as menu events.
Could there be a more streight forward way to do cut-and-paste ?

Barak, Ron wrote:

Hi,

Reading Manning's book, chapter 13 (Building list controls and managing items), I'm unclear if wx.ListCtrl should support cut-and-paste (as is).

I have a ListCtrl subclass, that I want to have cut-and-paste capabilities.

Looking at http://www.wxpython.org/docs/api/wx.ListCtrl-class.html (et. al.), I don't see that ListCtrl has any methods for cut-and-paste.

   1. Am I not looking in the correct place (or am I misunderstanding),
      and wx.ListCtrl does support cut-and-paste ?

What data format would it use if it did? Plain text? CSV text? Images? Files? Item indexes? The contents of a listctrl is highly specific to the application and there is no standard single value that it can hold, so copy/paste is left up to the application programmer.

   2. Is there another subclass of ListCtrl that does support
      cut-and-paste ?

No. You need to decide what it means for your specific application, and implement the clipboard actions yourself accordingly.

Or, a more general question:
Can cut-and-paste be added to a wxPython application globally, namely, have Ctrl-Insert/Shift-Insert (or Ctrl-c/Ctrl-v on Windows) be supported on any widget ?

Not really. The best you could do is catch the events via menu accelerators, find the widget with the focus, and then call its methods to do the copy/paste. That will take care of getting events when the keys are pressed, but you'll still need to handle the actual clipboard actions for each widget, since each of them could have a different meaning or purpose related to the data and data type that it is holding.

···

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

Hello Robin,

From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Monday, February 16, 2009 21:28
To: wxpython-users@lists.wxwidgets.org
Subject: Re: [wxpython-users] Can cut-and-paste be added to a
wxPython application globally/to ListCtrl ? (II)

Barak, Ron wrote:
> Hi,
>
> Reading Manning's book, chapter 13 (Building list controls and
> managing items), I'm unclear if wx.ListCtrl should support
cut-and-paste (as is).
>
> I have a ListCtrl subclass, that I want to have
cut-and-paste capabilities.
>
> Looking at
http://www.wxpython.org/docs/api/wx.ListCtrl-class.html (et.
> al.), I don't see that ListCtrl has any methods for cut-and-paste.
>
> 1. Am I not looking in the correct place (or am I
misunderstanding),
> and wx.ListCtrl does support cut-and-paste ?

What data format would it use if it did? Plain text? CSV
text? Images?
  Files? Item indexes? The contents of a listctrl is highly
specific to the application and there is no standard single
value that it can hold, so copy/paste is left up to the
application programmer.

In this application, the data format is plain text and I only want to be able to copy from the application to the clipboard.

> 2. Is there another subclass of ListCtrl that does support
> cut-and-paste ?

No. You need to decide what it means for your specific
application, and implement the clipboard actions yourself accordingly.

Okay.

>
> Or, a more general question:
> Can cut-and-paste be added to a wxPython application
globally, namely,
> have Ctrl-Insert/Shift-Insert (or Ctrl-c/Ctrl-v on Windows)
be supported
> on any widget ?

Not really. The best you could do is catch the events via menu
accelerators, find the widget with the focus, and then call
its methods
to do the copy/paste. That will take care of getting events when the
keys are pressed, but you'll still need to handle the actual
clipboard
actions for each widget, since each of them could have a different
meaning or purpose related to the data and data type that it
is holding.

Okay, I'll try and gather more information and follow your outline above.

Thanks,
Ron.

···

-----Original Message-----

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

In this application, the data format is plain text and I only want to be

able to copy from the application to the clipboard.

>
>
> > 2. Is there another subclass of ListCtrl that does support
> > cut-and-paste ?
>
> No. You need to decide what it means for your specific
> application, and implement the clipboard actions yourself accordingly.

Okay.

ObjectListView supports copying plain text and HTML to the clipboard. You
can find it here: http://objectlistview.sourceforge.net/python

Regards,
Phillip

···

------------------------------------------------------------------------
Phillip Piper www.bigfoot.com/~phillip_piper phillip_piper@bigfoot.com
A man's life does not consist in the abundance of his possessions