Mar-23-2019, 10:47 PM
Here are some buttons added to two different frames, 1 button is added inside the class the other is added outside of it.
import tkinter as tk class MainFrame(tk.Frame): def __init__(self, parent=None): super().__init__(parent) self.pack() button = tk.Button(self, text='button1') button.pack(side="top") class AnotherFrame(tk.Toplevel): def __init__(self, parent=None): super().__init__(parent) button = tk.Button(self, text='button3') button.pack(side="top") root = tk.Tk() main_frame = MainFrame(root) button = tk.Button(main_frame, text='button2') button.pack(side="top") another_frame = AnotherFrame(main_frame) button = tk.Button(another_frame, text='button4') button.pack(side="top") root.mainloop()