Python GUI,用户输入区域类似于excel



我正在尝试创建一个GUI,允许用户直接将数据复制和粘贴到界面中。将有三列和1 - 500行之间的任何地方与3000 +的可能性的原始文本将通过电子邮件,word, PDF或excel,所以我需要用户输入字段类似于excel,你可以复制/粘贴超过1行在同一时间。

我遵循了几个YouTube指南,使用tkinter创建表格/网格,但我无法找到一种方法,允许通过复制/粘贴输入文本。

由于tktable不是tkinter的一部分,我发现用tkinter创建表的唯一方法之一是下面的例子。这仍然不允许用户通过复制/粘贴进行输入。



class Table: 

def __init__(self,root): 

# code for creating table 
for i in range(total_rows): 
for j in range(total_columns): 

self.e = Entry(root, width=20, fg='blue', 
font=('Arial',16,'bold')) 

self.e.grid(row=i, column=j) 
self.e.insert(END, lst[i][j]) 

# take the data 
lst = [(1,'Raj','Mumbai',19), 
(2,'Aaryan','Pune',18), 
(3,'Vaishnavi','Mumbai',20), 
(4,'Rachna','Mumbai',21), 
(5,'Shubham','Delhi',21)] 

# find total number of rows and 
# columns in list 
total_rows = len(lst) 
total_columns = len(lst[0]) 

# create root window 
root = Tk() 
t = Table(root) 
root.mainloop() 

谁能建议一个替代的tkinter或指出我在这类用户输入指南的方向?

我终于明白为什么我不能让python允许我使用tkinter,并且能够或多或少地做我想做的事情。

import tkinter as tk
from tkinter import *
from tkinter import BOTH, END, LEFT
HEIGHT = 970
WIDTH = 1500
root = tk.Tk()
root.title( 'Daves Generator')
canvas = tk.Canvas(root, height=HEIGHT, width=WIDTH)
canvas.pack()
background_image = tk.PhotoImage(file='david.png')
background_label = tk.Label(root, image=background_image)
background_label.place(relwidth=1, relheight=1)
frame_one = tk.Frame(root, bg='#003d70',bd=5)
frame_one.place(relx=0.17, rely=.15, relwidth=0.3,relheight=0.8, anchor='n')
customer_description = tk.Text(frame_one, state=NORMAL, width=125, wrap=WORD, height=500,font=("Courier", 8))
customer_description.place(relwidth=1, relheight=1)
frame_two = tk.Frame(root, bg='#003d70',bd=5)
frame_two.place(relx=0.5, rely=.15, relwidth=0.3,relheight=0.8, anchor='n')
dave_description = tk.Text(frame_two, width=125, height=500,font=("Courier", 8))
dave_description.place(relwidth=1, relheight=1)
frame_three = tk.Frame(root, bg='#003d70',bd=5)
frame_three.place(relx=0.83, rely=.15, relwidth=0.3,relheight=0.8, anchor='n')
sap_code = tk.Label(frame_three, width=125, height=500,font=("Courier", 8))
sap_code.place(relwidth=1, relheight=1)
header_frame_one = tk.Label(root, text="Customer Descriptions", font=("Courier", 14), fg='#003d70')
header_frame_one.place(relx=0.17, rely=0.13, relwidth=0.2, relheight=0.025, anchor='n')
header_frame_two = tk.Label(root, text="PJ Descriptions", font=("Courier", 14), fg='#003d70')
header_frame_two.place(relx=0.5, rely=0.13, relwidth=0.2, relheight=0.025, anchor='n')
header_frame_three = tk.Label(root, text="SAP Code", font=("Courier", 14), fg='#003d70')
header_frame_three.place(relx=0.83, rely=0.13, relwidth=0.2, relheight=0.025, anchor='n')
generate_button = tk.Button(root,text="Generate!", font=("Courier", 14), fg='white', bg='#003d70', command=lambda: get_customer_description())
generate_button.place(relx=0.5, rely=0.08, relwidth=0.15, relheight=0.025, anchor='n')

相关内容

  • 没有找到相关文章

最新更新