0
prompt = ">>"
from tkinter import *

root = Tk()
userName = Entry()
myLabel = Label(root, text="UserName")

userName.grid(row=0)
myLabel = Label.grid(row=0, column=1)
root.mainloop()

TypeError: grid_configure() missing 1 required positional argument: 'self'

MasonBitByte
  • 33
  • 1
  • 7

2 Answers2

1

This statement is incorrect:

myLabel = Label.grid(row=0, column=1)

At the very least it needs to be this:

myLabel = Label().grid(row=0, column=1)

Though, if you want mayLabel to be anything other than None you need to use two lines:

myLabel = Label()
myLabel.grid(row=0, column=1)

Though, if you want to use the previous definition of myLabel, maybe you need to simply omit myLabel = Label(), since that creates a new empty label.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
0

Label.grid() is the name of the method/function in the documentation. To use .grid(), do mylabel.grid(...).

This is because Label represents the Class itself - you want to use a certain label, namely mylabel.