Oliver
Oliver

Reputation: 94

tkinter.place() method: TypeError: place_configure() takes from 1 to 2 positional arguments

When running this code involving tkinter.place():

from tkinter import *

HEIGHT = 500
WIDTH = 800
MID_X = HEIGHT/2
MID_Y = WIDTH/2
...
window = Tk()
...
def main_menu():
    ...
    label.place(MID_X, MID_Y)
    button.place(HEIGHT-50, MID_Y)
    ...

main_menu()
window.mainloop()

The code fails with a TypeError:

Traceback (most recent call last):
  File "/Users/.../program.py", line 22, in <module>
    main_menu()
  File "/Users/.../program.py", line 19, in main_menu
    label.place(MID_X, MID_Y)
TypeError: place_configure() takes from 1 to 2 positional arguments but 3 were given

(I'm not telling you the full file path, for privacy reasons.)

But only 2 arguments were given! The documentation does not say anything about this. How can this be fixed?

Upvotes: 0

Views: 432

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 385900

place generally needs named arguments.

label.place(x=MID_X, y=MID_Y)

Upvotes: 2

Related Questions