[Tkinter-discuss] can't set height in entry?

Michael Lange klappnase at web.de
Wed Aug 24 20:32:52 CEST 2011


Hi,

Thus spoketh Lion Kimbro <lionkimbro at gmail.com> 
unto us on Wed, 24 Aug 2011 09:50:08 -0700:

>   Entry's don't have height;  They only have width.
> 
>   You might be interested in a Text.

That's of course true if the OP meant to create a multi-line Entry
widget.

> 
> 2011/8/24 守株待兔 <1248283536 at qq.com>
> 
> > when i run:
> > from Tkinter import *
> > root = Tk()
> > Entry(root,text = 'input your text here',width = 100,height=20).pack()
> > root.mainloop()
> >
> > tkinter.TclError: unknown option "-height"
> >
> > can i have a higher entry?

However if you just want to change the Entry's visual appearance, you can
use a trick and use the geometry manager to vertically stretch the Entry
widget (this works at least here on linux, it might depend on the WM's
behavior though):

from Tkinter import *
root = Tk()
e=Entry(root,text = 'input your text here',width = 100)
e.pack(ipady=10)
root.mainloop()

BTW, you won't have much luck with the "text" option either, although it
does not produce an error message. If you want some default string you
will to have to insert it explicitely with the insert() method.

A quick overview on the Entry widget's options can be found at:

http://www.pythonware.com/library/tkinter/introduction/x4447-options.htm

and much more excellent documentation about most of the other Tkinter
widgets and the main concepts in Tkinter programming is available at:

http://www.pythonware.com/library/tkinter/introduction/

There is also an updated (however not yet complete) version of this book,
which also covers some of the newer Tkinter widgets) available at:

http://effbot.org/tkinterbook/tkinter-index.htm#class-reference

The most complete and up-to-date documentation is of course always the
collection of Tk man pages :

http://www.tcl.tk/man/tcl8.5/TkCmd/  or, depending on your Tk-version:
http://www.tcl.tk/man/tcl8.6/TkCmd/

Of course these require the additional effort to "translate" them into
Python, but that is not too hard, and once you got the point, they are
quite straightforward to use.

I hope this helps

Michael


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

What kind of love is that?  Not to be loved; never to have shown love.
		-- Commissioner Nancy Hedford, "Metamorphosis",
		   stardate 3219.8


More information about the Tkinter-discuss mailing list