It sounds like you are looking for tkinter.Text, which allows you to adjust both the height and width of the widget. Below is a simple script to demonstrate:
from tkinter import Text, Tk
r = Tk()
r.geometry("400x400")
t = Text(r, height=20, width=40)
t.pack()
r.mainloop()
Answer from user2555451 on Stack OverflowIt sounds like you are looking for tkinter.Text, which allows you to adjust both the height and width of the widget. Below is a simple script to demonstrate:
from tkinter import Text, Tk
r = Tk()
r.geometry("400x400")
t = Text(r, height=20, width=40)
t.pack()
r.mainloop()
Another way would be to increase the internal padding by adding this in the pack method:
...
e = Entry(f,textvariable=1,height=20)
e.pack(ipady=3)
...
for instance. This worked for me for an 'Entry' and it also works with .grid()
Videos
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()
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)
so I have been building a calculator for a game and so far things have been going alright, however, upon adding some entry boxes I found I am unable to set their width in pixels but it instead seems to set it based on text size. it also seems to force the width of the parent even if I set the expand property of pack() to false.
https://github.com/Shain-Allen/Wizard101DamageCalculator
class ArmorSpec(): def __init__(self, baseWidget , schoolName, schoolImgFile): self.Name = schoolName self.imgFile = schoolImgFile self.specHolder = tk.Frame(baseWidget) self.img = ImageTk.PhotoImage(Image.open(schoolImgFile)) self.schoolLogo = tk.Label(self.specHolder, image=self.img) self.armorPercent = tk.Entry(self.specHolder) self.armorFlat = tk.Entry(self.specHolder) def pack(self): self.specHolder.pack(side=tk.LEFT, expand=tk.FALSE) self.schoolLogo.pack() self.armorPercent.pack() self.armorFlat.pack() def imgFileResize(self, newWidth): baseimage = Image.open(self.imgFile) wpercent = (newWidth / float(baseimage.width)) hsize = int(float(baseimage.height) * float(wpercent)) self.img = ImageTk.PhotoImage(baseimage.resize((newWidth, hsize), Image.LANCZOS)) self.schoolLogo.config(image=self.img) self.specHolder.config(width=newWidth) armorStatsFrameOuter = tk.Frame(modificationsFrame, height=200, width=MAXWINDOWWIDTH/2, borderwidth=2, relief=tk.SOLID) fireDamage = ArmorSpec(armorStatsFrameOuter, "Fire", "Images/SchoolIcons/Fire-School.gif") iceDamage = ArmorSpec(armorStatsFrameOuter, "Ice", "Images/SchoolIcons/Ice-School.gif") stormDamage = ArmorSpec(armorStatsFrameOuter, "Storm", "Images/SchoolIcons/Storm-School.gif") mythDamage = ArmorSpec(armorStatsFrameOuter, "Myth", "Images/SchoolIcons/Myth-School.gif") lifeDamage = ArmorSpec(armorStatsFrameOuter, "Life", "Images/SchoolIcons/Life-School.gif") deathDamage = ArmorSpec(armorStatsFrameOuter, "Death", "Images/SchoolIcons/Death-School.gif") balanceDamage = ArmorSpec(armorStatsFrameOuter, "Balance", "Images/SchoolIcons/Balance-School.gif") # Armor Stats placement armorStatsImgWidth = floor(armorStatsFrameOuter.winfo_width()/7) #resize images to fit space fireDamage.imgFileResize(armorStatsImgWidth) iceDamage.imgFileResize(armorStatsImgWidth) stormDamage.imgFileResize(armorStatsImgWidth) mythDamage.imgFileResize(armorStatsImgWidth) lifeDamage.imgFileResize(armorStatsImgWidth) deathDamage.imgFileResize(armorStatsImgWidth) balanceDamage.imgFileResize(armorStatsImgWidth) #pack all elements fireDamage.pack() iceDamage.pack() stormDamage.pack() mythDamage.pack() lifeDamage.pack() deathDamage.pack() balanceDamage.pack() root.mainloop()
image for reference https://imgur.com/a/FZstU9W of the size of input boxes. the input boxes should be the size of the images just above them
You can also use the Place geometry manager:
entry.place(x=10, y=10, width=100) #width in pixels
You cannot specify the width in pixels using the '-width' option, but there are ways to accomplish the same thing. For example, you could pack an entry in a frame that has no border, turn off geometry propagation on the frame, then set the width of the frame in pixels.