-1
from tkinter import *

window = Tk()
window.title("GUI")

l1 = Label(window, text = "Hello!" ,font = ("Arial Bold",20)).pack()

bt = Button(window, text = "Enter").pack()

l1.grid(row = 0, column = 0)

window.geometry('350x200')

window.mainloop() 

I got an error with:

AttributeError: 'NoneType' object has no attribute 'grid'
Zephyr
  • 11,891
  • 53
  • 45
  • 80
  • 1
    It is because `l1` is the result of `pack()` which is `None`. Also you cannot use `pack()` and `grid()` together on widgets with same parent. – acw1668 Dec 03 '20 at 08:53

1 Answers1

0

It is because the variable l1 is using pack() and you cannot use pack() and grid() on widgets that on the same parents/root (Tk() class)

To fix this you need to choose what layout system you want to use, if you want to use pack() layout system then remove the l1.grid(row = 0, column = 0). If you want to use the grid() layout system remove the .pack() function on l1