how to insert a widget to another, if they are from different classes. and how to create a universal function of closing the child widgets?
<p>this is my code. I can't put label2 to self.main, and I don't know, how to write a generic function code, that would close the child widgets, that can be specified in the arguments.</p>

<pre><code>import tkinter


class mainwin:
    def __init__(self):
        self.root = tkinter.Tk()
        self.main = tkinter.Canvas(self.root, width=200, height=400)
        self.main.place(x=0, y=0, relwidth=1, relheight=1)
        self.main.config(bg='green')
        self.root.mainloop()


class addlabel:
    def __init__(self):
        self.label2 = tkinter.Label(mainwin.main, height=2, width=50,   text='Hello Noob!!') 
        #can't put on the canvas 'main'
        self.label2.place(x=0, y=50)
        self.exit_button = tkinter.Button(self.label2, text='Exit')
        self.exit.button.bind('&lt;1&gt;', quit_from_widget)

'''
class quit_from_widget:

  def __init__(self):
    # what code should be written here, to quit any child widget.
'''

mainwin()
addlabel()
</code></pre>

<pre><code>import tkinter

class mainwin:
    def __init__(self):
        self.root = tkinter.Tk()
        self.main = tkinter.Canvas(self.root, width=200, height=400)
        self.main.place(x=0, y=0, relwidth=1, relheight=1)
        self.main.config(bg='green')
        self.root.mainloop()


class CustomLabel(tkinter.Frame):
    def __init__(self, parent):
        tkinter.Frame.__init__(self, parent)

        self.label = tkinter.Label(self, height=20, width=30, bg='Red', fg='white', text='Hello')
        self.exit_button = tkinter.Button(self, command=self.destroy)

        # pack these widgets into this frame. You can use grid or
        # place, but pack is easiest for such a simple layout
        self.exit_button.pack(side="right")
        self.label.pack(side="left", fill="both", expand=True)



window = mainwin()

label = CustomLabel(window.main)
</code></pre>

<p>nothing happens. gives green background and the child widget is not visible. but when closing, he writes an error:<br>
....
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: can't invoke "frame" command: application has been destroyed</p>

<p>Process finished with exit code 1</p>

python class tkinter widget