please help, I am trying to create a button on a tkinter window with the use of python class inheritance but it does not show the button. I am new to inheritance in python and not sure how do this. please see my code. thanks in advance
from tkinter import *
class A:
def __init__(self):
self.root = Tk()
self.root.mainloop()
class B(A):
def __init__(self):
super().__init__()
self.my_button = Button(self.root,text="test")
self.my_button.pack()
d = B()
mainloop()
inside__init__()
. For your case,super().__init__()
inside classB
will return only after you close the main window, then you try to create button which raises the exception.