Sorry if it's a stupid question but I'm a beginner and couldn't find the answer on google, so I thought on asking here to learn. When I write
Class Buttons:
def play_b(self):
self.play_button = Button(main_window, text="Play")
self.play_button.grid(row=0, column=0)
It returns TypeError: play_b() missing 1 required positional argument: 'self'
However, when I write the following it works perfectly:
class Buttons:
def play_b():
play_button = Button(main_window, text="Play")
play_button.grid(row=0, column=0)
My question is: Why this happen? shouldn't functions always have the self keyword?
Edit: This is all the code so far: this is all the code so far:
from tkinter import *
main_window = Tk()
main_window.geometry("720x480")
class Buttons:
def play_b():
play_button = Button(main_window, text="Play")
play_button.grid(row=0, column=0)
Buttons.play_b()