How to stop automatic resizing of frames
<p>I have three frames, but when a new label appears the frames automatically readjust to a new size. How do I stop the readjustment and have the size of each frame set and immutable.</p>

<pre><code>#Import tkinter to make gui
from tkinter import *
from tkinter import ttk
import codecs

#Program that results when user attempts to log in
def login(*args):
    file = open("rot13.txt", "r")
    lines = file.readlines()
    uname = user.get()
    pword = pw.get()

    for i in lines:
        x = i.split()
        if codecs.encode(uname,'rot13') == x[0] and codecs.encode(pword,'rot13') == x[1]:
            result.set("Successful")
            break;
        else:
            result.set("Access Denied")

root = Tk()
root.title("Login")

#Configures column and row settings and sets padding
mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe['borderwidth'] = 5
mainframe['relief'] = "solid"
mainframe.grid(column=1, row=1, columnspan=3, rowspan=2)
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)

mainframe2 = ttk.Frame(root, padding="3 3 12 12")
mainframe2['borderwidth'] = 5
mainframe2['relief'] = "solid"
mainframe2.grid(column=1, row=3, columnspan=1, rowspan=3)
mainframe2.columnconfigure(0, weight=1)
mainframe2.rowconfigure(0, weight=1)

mainframe3 = ttk.Frame(root, padding="3 3 12 12")
mainframe3['borderwidth'] = 5
mainframe3['relief'] = "solid"
mainframe3.grid(column=2, row=5)
mainframe3.columnconfigure(0, weight=1)
mainframe3.rowconfigure(0, weight=1)

#anchors for widgets
user = StringVar()
pw = StringVar()
result = StringVar()

#Asks user input
user_entry = ttk.Entry(mainframe, width=20, textvariable=user)
user_entry.grid(column=2, row=1, sticky=(W, E))

pw_entry = ttk.Entry(mainframe, width=20, textvariable=pw)
pw_entry.grid(column=2, row=2, sticky=(W, E))


#Labels to make user-friendly and able to understand
ttk.Label(mainframe, text="Username ").grid(column=1, row=1, sticky=W)
ttk.Label(mainframe, text="Password ").grid(column=1, row=2, sticky=W)
ttk.Label(mainframe2, text="").grid(column=1, row=3, sticky=W)
ttk.Label(mainframe2, text="Result").grid(column=1, row=4, sticky=W)
ttk.Label(mainframe2, text="").grid(column=1, row=5, sticky=W)

#Button to log in
ttk.Button(mainframe3, text="Login", command=login).grid(column=3, row=5, sticky=(W,E))

#Makes a spot to put in result
ttk.Label(mainframe2, textvariable=result).grid(column=2, row=4, sticky=(W, E))
#Opens up with item selected and allows you to enter username without having to click it
user_entry.focus()
#Runs calculate if click enter
root.bind('&lt;Return&gt;', login)
root.mainloop()
</code></pre>

<p>Here is the before and after picture of the results:</p>

<p><a href="http://i.stack.imgur.com/aB1VS.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/aB1VS.jpg" alt="beginning"></a></p>

<p><a href="http://i.stack.imgur.com/qpxAD.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/qpxAD.jpg" alt="and then after a result appears this happens"></a></p>

<p>As you can see the frames change sizes after the program runs its course. How do i stop this re-size and stick to a predetermined size?</p>

<p>The simplest solution in this specific case is to give the label with the text a fixed width. When you specify a fixed width for a label, tkinter will do it's best to honor that width (though a lot depends on how you place it on the screen with <code>pack</code>, <code>place</code> or <code>grid</code>).</p>

<pre><code>ttk.Label(..., width=12).grid(...)
</code></pre>

<p>Another solution is to turn off geometry propagation, which means you're responsible for giving the frame an explicit width and height: </p>

<pre><code>mainframe2 = ttk.Frame(..., width=200, height=100)
...
mainframe2.grid_propagate(False)
</code></pre>

<p>I do not recommend turning geometry propagation off. Tkinter is usually very good at computing the right size for widgets, and this usually results in very poor behavior if you change fonts, screen resolutions, or root window sizes. </p>

python tkinter