0

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 ()
Cœur
  • 37,241
  • 25
  • 195
  • 267
sosdaniel
  • 35
  • 1
  • 6
  • 1
    What's with the space between the `.`'s? Although it's grammatically correct, it's ugly... But anyway - what exactly is your question? – Jon Clements Oct 30 '12 at 20:58
  • @JonClements I was going to start tinkering with an answer, but I had no idea you could use dots like that, so maybe I'm not the best person to do so :) – RocketDonkey Oct 30 '12 at 21:12
  • @RocketDonkey Yeah, also: `1.__str__` isn't valid attribute access, it's an invalid float, but `(1).__str__` or `1 . __str__` will work... Good ol' Python – Jon Clements Oct 30 '12 at 21:16
  • @JonClements Haha, had no idea. Learn something new every day! – RocketDonkey Oct 30 '12 at 21:19
  • 2
    Could you translate "I would like see this entry the app. window bottom in live, when i'm typewriter. If i key down/press call one funtion is class" to English please? – Junuxx Oct 30 '12 at 21:23
  • If I keyboard press the inputfield Entry i would like call xyz function in the Example class. Sorry, I speak a very little english. – sosdaniel Oct 30 '12 at 21:43
  • duplicate of http://stackoverflow.com/q/6548837/ (see the answer there) – FabienAndre Oct 31 '12 at 12:13

1 Answers1

1

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"
Saurabh7
  • 710
  • 1
  • 5
  • 18