-1
#writing introduction text
mn=tk.Label(window,text="WELCOME TO \n AAROGYA SETU \n SELF EXAMINATION FRONT",font=("Bookman old style",30,'bold','italic')).pack()


#linking sign up form
sig=tk.Label(window,text="click button to sign up",font=("Bookman old style",20,"bold")).pack()

Error message:

'Nonetype' has no attribute .grid()

I am unable to position my label (that I created using Tkinter) in my program. it doesn't take .grid() or .place() either.

What can be the possible reasons? my code execution otherwise is perfect.

3
  • 1
    Please share your code (and any error messages) so that we might be able to help you.
    – scotty3785
    Feb 10, 2021 at 11:40
  • 1
    Your error message says that you are using grid, but the code says pack. Which are you using?
    – scotty3785
    Feb 10, 2021 at 13:21
  • I don't see .grid() in your code - so using this code you could get this error. Always show code which generates error. And always put full error message (starting at word "Traceback") in question (not comment) as text (not screenshot, not link to external portal). There are other useful information.
    – furas
    Feb 10, 2021 at 14:53

2 Answers 2

0

You do the most common mistake

variable = Widget().pack()

which assign None to variable because pack()/grid()/place() returns None.

You have to do it in two steps:

variable = Widget()
variable.pack()

But it seems you may create other problem.

pack()/grid()/place() are different layout managers and you shouldn't use two layout managers on one widget.

So use pack() OR grid() OR place().

You don't need pack() if you want to use grid() or place().

variable = Widget()
variable.grid()

or

variable = Widget()
variable.place(...)

or

variable = Widget()
variable.pack()
1
  • yes thank you! i changed to .grid() and .place() and things were fine! appreciate your efforts! Feb 11, 2021 at 3:28
-1
from tkinter import *


main = Tk()

name = Label(main,text="WELCOME TO \n AAROGYA SETU \n SELF EXAMINATION FRONT",font=("Bookman old style",30,'bold','italic'),bg="light blue").pack() 
#linking sign up form 
sign=Label(main,text="click button to sign up",font=("Bookman old style",20,"bold"),bg="light blue").pack()

main.mainloop()

this should work

3
  • At the moment sign will be set to None since the .pack() method will return zero. Generally bad practice to create and layout your widgets on the same line.
    – scotty3785
    Feb 10, 2021 at 13:01
  • @scotty3785 though without .pack () my program anyways doesn't display anthing Feb 10, 2021 at 13:16
  • @KavyaSingh Please share your code and any error messages
    – Alby
    Feb 10, 2021 at 13:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.