TKinter Entry question

Jørgen Cederberg jorgencederberg at
Fri Jan 31 09:25:56 CET 2003

vector wrote:
> Q1 can I put some pre text in the entry box?. How?
> Q2 how do I know when/if to get the users entry?

This is the second time you ask these questions. Eric Brunel gave you a 
hint to use StringVar() and a button. Here is an example that reacts to 
all that is entered in the entry field.

--- Start ---
from Tkinter import *

def textentered(event):

class EntryTester:
     def __init__(self, parent, deftext):
         self.fanon = StringVar()
         e = Entry(parent, textvariable=self.fanon)
         e.bind('<Key>', self.keybhit)

     def keybhit(self, event):
         print self.fanon.get()

if __name__ == '__main__':
     import sys
     root = Tk()
     EntryTester(root, sys.argv[1])

--- End ---

it should be runned as: python DefaultText

But reading your posting again, suggest that the fanon variable is a 
switch perhaps? In that case, consider using a radiobutton or 
checkbutton instead.

Execellent Tkinter documentation is found at: and

Jørgen Cederberg

More information about the Python-list mailing list