我无法从用户输入中获取多行并将其显示回给他们。我正在使用 OOP 制作一个窗口,让用户输入他们的文章,并有一个窗口将其显示给他们。当我使用 时.get()
,什么都没有出现。有什么建议么?
import tkinter
from tkinter import *
class userInterface:
def __init__(self):
pass
def uploadWindow(self):
#Generic window that is used for each new window
self.essayAdd = tkinter.Tk()
self.essayAdd.geometry("1500x900")
self.essayAdd.title("Text Analysis")
self.essayAdd.mainloop
def copyPasteCommand(self):
#Creates a new window with space to copy and paste text
self.uploadWindow()
#Title of window
tkinter.Label(self.essayAdd, text = "Uploading your essay", fg = "white", bg = "purple", font=("Helvetica", 20)).pack(fill = "x")
#Creating an input for user to paste their essay
tkinter.Label(self.essayAdd, text="Please paste your essay below.", font=("Helvetica", 16)).place(x = 50, y=40)
self.userEssayLabel = Text()
self.scrollBar = Scrollbar(self.essayAdd)
self.scrollBar.config(command=self.userEssayLabel.yview)
self.userEssayLabel.config(yscrollcommand=self.scrollBar.set)
self.scrollBar.pack(side=RIGHT, fill=Y)
self.userEssayLabel.pack(expand=YES, fill=BOTH)
self.userEssay = self.userEssayLabel.get("1.0", END)
#Creating buttons to quit and move on to next step
#Quit
self.quitting = tkinter.Button(self.essayAdd, text = "Quit", fg = "purple", font =("Helvetica", 16), command = self.essayAdd.destroy).place(x=50, y=600)
#Next step
self.enter = tkinter.Button(self.essayAdd, text = "Enter", fg = "purple", font =("Helvetica", 16), command = self.essayWindow).place(x=1235, y=600)
def essayWindow(self):
self.essayAdd.destroy()
self.uploadWindow()
tkinter.Label(self.essayAdd, text = "Essay Analysis", fg = "white", bg = "purple", font=("Helvetica", 20)).pack(fill = "x")
tkinter.Label(self.essayAdd, text = self.userEssay, fg = "white", bg = "purple", font=("Helvetica", 16)).place(x=1235, y=600)
execute = userInterface()
execute.copyPasteCommand()