python Tkinter get() value from Entry Field

前端 未结 3 1178
感情败类
感情败类 2020-12-10 09:31

I have getting confused in getting the value from the Tkinter() Entry Field. I have this kind of code...

from Tkinter import*

def valueGET(val1, val2):
             


        
3条回答
  •  执笔经年
    2020-12-10 10:18

    from tkinter import *
    import tkinter as tk
    root =tk.Tk()
    mystring =tk.StringVar(root)
    def getvalue():
        print(mystring.get())
    e1 = Entry(root,textvariable = mystring,width=100,fg="blue",bd=3,selectbackground='violet').pack()
    button1 = tk.Button(root, 
                    text='Submit', 
                    fg='White', 
                    bg= 'dark green',height = 1, width = 10,command=getvalue).pack()
    
    root.mainloop()
    

提交回复
热议问题