Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tkinter Entry height [duplicate]

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?

like image 550
jjguidry Avatar asked Sep 10 '26 09:09

jjguidry


2 Answers

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()
like image 68
user5925113 Avatar answered Sep 12 '26 15:09

user5925113


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)

like image 43
Bryan Oakley Avatar answered Sep 12 '26 17:09

Bryan Oakley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!