This error can occur if you mix pack()
and grid()
in the same master window. According the docs, it is a bad idea:
Warning: Never mix grid and pack in the same master window. Tkinter
will happily spend the rest of your lifetime trying to negotiate a
solution that both managers are happy with. Instead of waiting, kill
the application, and take another look at your code. A common mistake
is to use the wrong parent for some of the widgets.
For example, this code is working for Python 3.3.x, but isn't working on Python 3.4.x (throws the error you mentioned):
from tkinter import *
from tkinter import ttk
root = Tk()
mainframe = ttk.Frame(root)
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
nb = ttk.Notebook(root)
nb.pack()
root.mainloop()
And this code isn't working for both Python versions:
from tkinter import *
root = Tk()
Label(root, text="First").grid(row=0)
Label(root, text="Second").pack()
root.mainloop()
To avoid this, use only one geometry manager for all children of a given parent, such as grid()
.