Python Forum
[Tkinter] Override the paste function(copy from excel file - paste in separate tkinter entryes)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Override the paste function(copy from excel file - paste in separate tkinter entryes)
#1
If I`m copying the data from a excel file (as exemple 2x rows and 2x columns, or more) and paste them in a tkinter table interface, everything will be pasted in a single entry. The excel cells wil not be spread in tkinter entries (ex: excel A1, A2, B1, B2 are going in the same entry and the point is to make them go in different entries: A1 cell data to be paste in mouse selected row * col; A2 cell data to be paste in mouse selected row + 1 * col + 1; B1 on row + 2 * col + 1 and B2 on row + 2 * col + 2).

I'm wondering if anyone had the same difficulty and if a solution was found.

An exemple bellow:

try:
    from tkinter import * 
except ImportError:
    from Tkinter import *
"""    
import pyperclip

a = pyperclip.paste()
print(a)
space = 0
tabs = 0
newline = 0

first = ""

for character in a:
    if character == " ":
        space +=1
    elif character == '\t': 
        tabs += 1
        print(first)
    elif character == '\n': 
        newline += 1
print(space)
print(tabs)
print(newline)
"""
root = Tk()

my_entries = [] #list for storing entries

height = 10
width = 5
for r in range(10): #numbers of rows
    for c in range(14): #number of columns
        my_entry = Entry(root, width=14)
        my_entry.grid(row=r+2, column=c, pady=1, padx=1, ipady=4)
        my_entries.append(my_entry)
        
root.mainloop()
Reply


Messages In This Thread
Override the paste function(copy from excel file - paste in separate tkinter entryes) - by AndreiV - Jun-01-2020, 07:49 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Using Tkinter inside function not working Ensaimadeta 5 5,083 Dec-03-2023, 01:50 PM
Last Post: deanhystad
  Tkinter won't run my simple function AthertonH 6 3,897 May-03-2022, 02:33 PM
Last Post: deanhystad
  [Tkinter] tkinter best way to pass parameters to a function Pedroski55 3 4,896 Nov-17-2021, 03:21 AM
Last Post: deanhystad
  Creating a function interrupt button tkinter AnotherSam 2 5,564 Oct-07-2021, 02:56 PM
Last Post: AnotherSam
  [Tkinter] Have tkinter button toggle on and off a continuously running function AnotherSam 5 5,037 Oct-01-2021, 05:00 PM
Last Post: Yoriz
  [PyQt] How to Copy-Paste a table from Office apps to QTableView? Vittorio 5 7,273 Aug-05-2021, 11:14 AM
Last Post: Axel_Erfurt
  tkinter get function finndude 2 2,968 Mar-02-2021, 03:53 PM
Last Post: finndude
  tkinter -- after() method and return from function -- (python 3) Nick_tkinter 12 7,469 Feb-20-2021, 10:26 PM
Last Post: Nick_tkinter
  [PyGUI] Python Application Not Finding Excel File dseals26 2 2,875 Feb-17-2021, 01:45 AM
Last Post: thewolf
Bug [PyQt] Qt app won't crash after sys.excepthook override Alfalfa 3 2,686 Dec-28-2020, 01:55 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020