[Tkinter-discuss] Entry Widget - Setting a Default Text

Amit Finkler amit.finkler at gmail.com
Mon Dec 31 15:07:55 CET 2007


Godson Gera wrote:
>
>
> On Dec 31, 2007 6:26 PM, Amit Finkler <amit.finkler at gmail.com
> <mailto:amit.finkler at gmail.com>> wrote:
>
>     Hi,
>
>
>     I'm building a GUI for my system using Tkinter. I created the
>     following Entry and Label widgets:
>
>
>         from Tkinter import *
>
>
>         win         = Tk()
>
>         f2            = Frame(win, bd = 2, relief = 'groove')
>
>
>         Lake_adr = StringVar()
>
>         LakeAdr = Entry(f2, textvariable = Lake_adr)
>
>         LakeAdrLabel = Label(f2, text = 'Lakeshore address')
>
>
>         LakeAdr.grid(row          = 1, column = 0)
>         LakeAdrLabel.grid(row = 0, column = 0)
>
>
>         f2.pack()
>
>
>     What I want to do is to have a default value already appearing in
>     this entry widget, which other functions can take using something like
>
>
> Hi Amit,
>  
> just call the set method of StringVar  with the default value before
> you use it. Like below
>
> from Tkinter import*
>
> win= Tk()
>
> f2= Frame(win, bd = 2, relief = 'groove')
>
> Lake_adr = StringVar()
> Lake_adr.set("123")
> LakeAdr = Entry(f2, textvariable = Lake_adr)
>
> LakeAdrLabel = Label(f2, text = 'Lakeshore address')
>
>
> LakeAdr.grid(row= 1, column = 0)
> LakeAdrLabel.grid(row = 0, column = 0)
>
>
> f2.pack()
>
> How ever if you are only dealing with integers you can use IntVar
> -- 
> Godson Gera,
> http://godson.in

Beautiful! It works.

Thanks,

Amit.
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20071231/1638a16e/attachment.htm 


More information about the Tkinter-discuss mailing list