2

I tried

textEntry = Entry(root, width=115, textvariable=text, height=12)

but I got an error invloving the height.

Then I tried using the Text widget:

textEntry = Text(root, width=115, textvariable=text, height=12)

but I got an error involving textvariable=text

Any way I could adjust the height of the Entry or the variable of the Text?

Cœur
  • 37,241
  • 25
  • 195
  • 267
jjguidry
  • 43
  • 1
  • 1
  • 9
  • 3
    You will get errors if you just guess what arguments a method accepts, see for example http://effbot.org/tkinterbook/text.htm – J.J. Hakala Apr 02 '16 at 02:24
  • why do you need to use a variable with the text widget? – Bryan Oakley Apr 02 '16 at 11:02
  • Does this answer your question? [How do I set the width of an Tkinter Entry widget in pixels?](https://stackoverflow.com/questions/6881010/how-do-i-set-the-width-of-an-tkinter-entry-widget-in-pixels) – DaniyalAhmadSE Dec 25 '19 at 11:31
  • 1
    Does this answer your question? [tkinter python entry height](https://stackoverflow.com/questions/24501606/tkinter-python-entry-height) – Baryon Dec 17 '20 at 10:05

4 Answers4

5

To change an entry widget's size you have to change its font to a larger one.

For example:

import tkinter as tk

large_font = ('Verdana',30)
small_font = ('Verdana',10)

root = tk.Tk()

entry1Var = tk.StringVar(value='Large Font!')
entry1 = tk.Entry(root,textvariable=entry1Var,font=large_font)
entry1.pack()    

entry2Var = tk.StringVar(value='Small Font!')
entry2 = tk.Entry(root,textvariable=entry2Var,font=small_font)
entry2.pack()

root.mainloop()
user5925113
  • 61
  • 1
  • 1
  • You don't have to, you just have to invoke the ```-height``` parameter. –  Jan 26 '19 at 21:14
3

No, there is no way to set the height of an Entry widget,and no, there is no way to use a variable with the text widget.

If you need a widget that allows you to enter more than one line of text your only option is a Text widget, and there's simply no reason to associate a variable with the widget because a text widget can contain more than just characters (images, embedded widgets, styling information)

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
1

You can set height of an Entry by using ipady. Here's an example :

from tkinter import *

root = Tk() # make window

entry = Entry() # make entry object
entry.grid(ipady=5) # display and set height of Entry object

root.mainloop() # run the code

sidenote = You cannot type multiple lines in an Entry. If thats what you want, you will have to use the Text widget.

David Buck
  • 3,752
  • 35
  • 31
  • 35
0

It looks like you are having the same problem as in the following link, there is an answer posted there: tkinter python entry height

Community
  • 1
  • 1
  • If you think it is a duplicate, flag it as such. If you click the `flag` link, there is `should be closed`. If you click that, you will see `Duplicate of`. If you click that, paste the link into the bar. – zondo Apr 02 '16 at 11:22