How to specify the dimensions of a Tkinter text box in pixels?
Question: **Question**

How would I specify the dimensions of a Tkinter text box using pixels? I am
not trying to change the font size - I am using this to help me scale it to
the size of the window.

**Tech Specs**

OS: Windows 7 Python 2.7.3


Answer: You can do it by putting it inside a frame, forcing the frame to a fixed size
by deactivating size propagation and configuring the entry to stick to the
frame borders. Should work in a similar way with pack, too.

    
    
    import Tkinter  # tkinter with small t for python 3
    #import ttk  # nicer widgets
    
    root = Tkinter.Tk()
    
    mainFrame = Tkinter.Frame(root)
    mainFrame.grid()
    button = Tkinter.Button(mainFrame, text="dummy")
    button.grid()
    
    
    entryFrame = Tkinter.Frame(mainFrame, width=454, height=20)
    entryFrame.grid(row=0, column=1)
    
    # allow the column inside the entryFrame to grow    
    entryFrame.columnconfigure(0, weight=10)  
    
    # By default the frame will shrink to whatever is inside of it and 
    # ignore width & height. We change that:
    entryFrame.grid_propagate(False)
    # as far as I know you can not set this for x / y separately so you
    # have to choose a proper height for the frame or do something more sophisticated
    
    # input entry
    inValue = Tkinter.StringVar()
    inValueEntry = Tkinter.Entry(entryFrame, textvariable=inValue)
    inValueEntry.grid(sticky="we")
    
    
    root.mainloop()
    

