-1

I'm learning tkinter and trying to make a button but when I run my code an error comes up saying

.TclError: cannot use geometry manager grid inside . which already has slaves managed by pack

This is my code:

import tkinter
from tkinter import Button
window=tkinter.Tk()
#title
window.title("Elvoria")
#text
label=tkinter.Label(window, text = "Welcome To Elovria").pack()
#button
bt = Button(window,text="Start")
bt.grid(column=1,row=1)
window.mainloop()
acw1668
  • 40,144
  • 5
  • 22
  • 34
  • 1
    You cannot use both `.grid` and `.pack` in the same container (window,frame...). And also your import statement is wrong – PCM Jul 19 '21 at 05:32
  • Does this answer your question: https://stackoverflow.com/questions/54315989/cant-understand-pack-and-grid-geometry-with-tkinter –  Jul 19 '21 at 05:46
  • Does this answer your question? [Cannot use geometry manager pack inside](https://stackoverflow.com/questions/23584325/cannot-use-geometry-manager-pack-inside) – PCM Jul 19 '21 at 07:31
  • @PCM I agree for the first part but what do you mean by the *import statement is wrong*? – TheLizzard Jul 19 '21 at 08:34
  • @TheLizzard `import tkinter` was not there when I commented ;) – PCM Jul 19 '21 at 08:36
  • @PCM That makes sense. My bad. I should have checked the edits :D – TheLizzard Jul 19 '21 at 08:37

1 Answers1

0

You have to use only grid or pack so change the label placement to grid

new_to_code
  • 37
  • 1
  • 12