tksheet - Copy and Paste with headers

Thomas Passin list1 at tompassin.net
Sun Apr 16 09:53:03 EDT 2023


On 4/16/2023 9:01 AM, Alan Gauld wrote:
> 
>> 在 2023/4/15 2:33, angela vales 写道:
>>> I have recently created a tkinter app and need the ability to copy and
>> paste data from tksheet table into an Excel file.
> 
> First thanks for drawing my attention to tksheet. I've long
> been desiring a decent table widget in tkinter and was on the
> verge of trying to create one of my own. tksheet looks like
> it will do all I need.
> 
> As to copy/paste I couldn't see any explicit mention but
> it does say the underlying data is in a Tk Canvas so it may
> be that copy/paste will just work, did you try it? What
> happened if you paste into a text editor in the first
> instance? And Excel in the second?
> 
> If all else fails you can probably write handlers and bind
> to Ctrl-C and Ctrl-V to do something yourself that mimics
> cut/paste.

I have not used tksheet, but in its documentation at 
https://github.com/ragardner/tksheet/wiki#14-getting-selected-cells, 
there is the method

     get_currently_selected()

     Returns namedtuple of (row, column, type_) e.g. (0, 0, "column")
     type_ can be "row", "column" or "cell"

There are companion methods for rows, columns, etc.  That would be a 
good starting point.


More information about the Python-list mailing list