I'm using a virtual ListCtrl in wxpython. I am trying to select several rows from the list and then copy / paste the row value to a text file, or possibly spreadsheet. How would I copy the selected rows to clipboard (using CTRL-C)? Which event should I bind? Thanks!
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
Mike's link on accelerators was really helpful. Along with this, I used pyperclip.copy() to complete my copy operation. With this, selected contents are copied to clipboard; and it can be pasted to any of the files.
Hope it helps someone..
Looking at the wxPython demo for the list control, I think you'd have to do something like the following:
You would need to use an AcceleratorTable if you want to use CTRL-C, which means that you'd bind to EVT_MENU and put the code I mentioned in that handler. Here's a tutorial on Accerators in wx: http://www.blog.pythonlibrary.org/2010/12/02/wxpython-keyboard-shortcuts-accelerators/
On the other hand, I almost always use ObjectListView instead of ListCtrl as it gives me an object model of each row which I find a lot easier to access than using row and column indexes. It takes a slightly different approach and mindset, but I think it's worth it: http://www.blog.pythonlibrary.org/2009/12/23/wxpython-using-objectlistview-instead-of-a-listctrl/