how to do this?

Justin Straube JustinStraube at notmymailbox.com
Sun Sep 4 01:08:36 EDT 2005


Greetings Pythonistas.
Im looking for a way to write this but not sure where or how to begin.
As the user enters or removes characters into/from sEnt I would like
for set_info() to set infVar with the correct value. The same as how
IDLE shows the line and column in the lower right corner.

#### Code Example ####
from time import localtime
from Tkinter import *

def set_info():
     x = len(strVar.get())
     infVar.set('Length: %i' % (x))

ROOT = Tk()
strVar = StringVar()
infVar = StringVar()

sLab = Label(ROOT, text='String')
sLab.grid(row=0, column=0)
sEnt = Entry(ROOT, textvariable=strVar, width=15)
sEnt.grid(row=0, column=1, columnspan=2)
qBut = Button(ROOT, text='Quit', command=ROOT.quit)
qBut.grid(row=1, column=2, pady=2, padx=2, sticky=E)
iLab = Label(ROOT, textvariable=infVar, width=21,
              relief=SUNKEN, anchor=W)
iLab.grid(row=2, column=0, columnspan=3)

set_info() # example to show what will be displayed.
ROOT.mainloop()
#### End Example ####

Can anyone point me in the right direction for how to do this?

Regards,

Justin



More information about the Python-list mailing list