Question

I would like see the Tkinter Entry value live. When I'm typewriting, i see print 'downkey';. If i'm typing 4 character the one entry i see live the bottom in window ok,ok,ok,ok,etc.

from email . mime . multipart import MIMEMultipart
from email . mime . text import MIMEText
from Tkinter import *
from ttk import *

import ConfigParser
import smtplib

class Example ( Frame ):

    def __init__ ( self, parent ):

        self . ini ()
        Frame . __init__ ( self, parent )
        self . parent = parent
        self . initUI ()

    def initUI ( self ):

        self . parent . title ( "Quit button" )
        self . style = Style ()
        self . style . theme_use ( "default" )
        self . pack ( fill = BOTH, expand = 1 )
        inputfield = Entry ( self ) # I would like see this entry the app. window bottom in live, when i'm typewriter. If i key down/press call one function is class.
        inputfield . place ( x = 10, y = 10 )
        quitButton = Button ( self, text = "Quit", command = self . quit )
        quitButton . place ( x = 50, y = 50 )

def main ():

    root = Tk ()
    root . geometry ( "250x150+300+300" )
    app = Example ( root )
    root . mainloop ()

if __name__ == '__main__':

    main ()
Was it helpful?

Solution

If you want to call a function after typing in the entry field, you will have to use event handler and bind the entry field to event like press of return and some function xyz. which means after pressing return, a function xyz can be called.

To update a message according to entry, you will need a variable string as argument to entry.

define a text variable globally:

m=StringVar()

in Eample class add:

you could add variable text to entry field

inputfield = Entry ( self,textvariable=m )

self.inputfield.bind('<Return>',self.xyz)  #to call xyz which you may want to define

and add textvariable to message to update it

message = Message(self,textvariable=m) #to update continuously the message which i hope you meant by "live"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top