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

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.

Hi Ron,

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 wxPython API Documentation — wxPython Phoenix 4.2.2 documentation (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.

I haven't done much with drag/drop, only a bit of text and image stuff and never on a listctrl. But I think it should work as one basically uses the "setvalue" method of the widget you want to paste into.

Maybe the wxPython demo for the drag/drop functionality will help you, I had based my code on it.

Werner

Hi Werner,

I tried creating the below application, to try figure how to use accelerators (later, when it's working, I'll use its lessons in my application it to support cut-and-paste).
However, the accelerators don't work.

Bye,
Ron.

     1 #!/usr/bin/env python
     2
     3 import wx
     4
     5 class ListControl(wx.Frame):
     6 def __init__(self, parent, id, title):
     7 wx.Frame.__init__(self,parent,id,title,size=(-1,-1))
     8 self.set_accelerators()
     9 self.Raise()
    10 self.Show()
    11
    12 def set_accelerators(self):
    13 print "set_accelerators started"
    14 EVT_TEST_ID = wx.NewId()
    15
    16 self.Bind(wx.EVT_MENU, self.on_test_event, id=EVT_TEST_ID)
    17
    18 aTable = wx.AcceleratorTable([
    19 (wx.ACCEL_CTRL, ord('L'), EVT_TEST_ID),
    20 (wx.ACCEL_ALT, ord('L'), EVT_TEST_ID),
    21 (wx.ACCEL_SHIFT, ord('L'), EVT_TEST_ID),
    22 (wx.ACCEL_CMD, ord('L'), EVT_TEST_ID),
    23 (wx.ACCEL_NORMAL, wx.WXK_F3, EVT_TEST_ID),
    24 ])
    25
    26 self.SetAcceleratorTable(aTable)
    27
    28 def on_test_event(self, event):
    29 print "on_test_event started"
    30
    31 if __name__ == "__main__":
    32
    33 app = wx.App(redirect=False)
    34 list_control = ListControl(None, -1, "events")
    35 app.MainLoop()

accelerator_demo01.py (978 Bytes)

···

-----Original Message-----
From: Werner F. Bruhin [mailto:werner.bruhin@free.fr]
Sent: Sunday, February 15, 2009 17:21
To: wxpython-users@lists.wxwidgets.org
Subject: Re: [wxpython-users] Can cut-and-paste be added to a wxPython application globally/to ListCtrl ?

Hi Ron,

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 wxPython API Documentation — wxPython Phoenix 4.2.2 documentation
(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.

I haven't done much with drag/drop, only a bit of text and image stuff and never on a listctrl. But I think it should work as one basically uses the "setvalue" method of the widget you want to paste into.

Maybe the wxPython demo for the drag/drop functionality will help you, I had based my code on it.

Werner