如何从Entry返回值,同时销毁寡妇?

我的英语不好。 我想使用一个按钮同时从Entry,tkinter返回值,破坏根。 像Vba功能输入一样。 我的代码:

import tkinter as tk

class InputBox:

    def __init__(self,title,default):
        self.HEIGHT = 150
        self.WIDTH = 300
        self.root = tk.Tk()
        self.root.width = self.WIDTH
        self.root.height = self.HEIGHT
        self.canvas = tk.Canvas(self.root,height=self.HEIGHT,width=self.WIDTH)
        self.canvas.pack()

        self.label = tk.Label(self.root,text=title)
        self.label.config(font=('helvetica',20))
        self.label.place(relx=0.5,rely=0.1,relwidth=0.4,relheight=0.2,anchor="center")

        self.content=tk.StringVar()
        self.content.set(default)
        self.entry = tk.Entry(self.root,font=('helvetica',20),justify='center',textvariable=self.content)
        self.entry.place(relx=0.5,rely=0.4,relwidth=0.8,relheight=0.3,anchor="center")
        self.entry.focus_set()

        # Here is the button call to the getInfo() function
        self.buttonInputBox = tk.Button(self.root,text="Yes",bg='#cccccc',font=60,command=lambda: self.getInfo())
        self.buttonInputBox.place(relx=0.5,rely=0.8,relwidth=0.3,anchor="center")

        self.root.mainloop()

    def getInfo(self):
        return self.entry.get()
        self.root.destroy()

def main():
    print(InputBox('RP','haha'))

if __name__ == '__main__':
    main()
zhangjuntu 回答:如何从Entry返回值,同时销毁寡妇?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3060403.html

大家都在问