FishHook, по моему давать такое же имя экземпляру класса, как и самому классу, вполне допустимо и не только в Python. И как я говорил, код рабочий, пока не меняете имя класса. Но если Вы так настаиваете, то меняю Frame1 на Frame01 и привожу варианты рабочего кода и нерабочего кода.
Вот рабочий код:
from tkinter import *
from tkinter import ttk
root = Tk()
root.geometry('400x400')
root.title('Title')
notebook = ttk.Notebook(root)
class Frame1(Frame):
def __init__(self, container):
super().__init__(container)
self.Frame1 = Frame(container)
self.Frame1.config(bg='blue')
self.Frame1.place(x=0, y=24, relwidth=0.9, relheight=0.9)
class Frame2(Frame):
def __init__(self, container):
super().__init__(container)
self.Frame2 = Frame(container)
self.Frame2.config(height=200, width=203, bg= 'green')
self.Frame2.place(x=0, y=24)
Frame01 = Frame1(notebook)
notebook.add(Frame01, text = "Connection")
Frame02 = Frame2(notebook)
notebook.add(Frame02, text = "Transient Response")
notebook.place(x=10, y=10)
root.mainloop()
А вот нерабочий код (точнее работающий неправильно):
from tkinter import *
from tkinter import ttk
root = Tk()
root.geometry('400x400')
root.title('Title')
notebook = ttk.Notebook(root)
class Frame1(Frame):
def __init__(self, container):
super().__init__(container)
self.Frame1 = Frame(container)
self.Frame1.config(bg='blue')
self.Frame1.place(x=0, y=24, relwidth=0.9, relheight=0.9)
class Frame3(Frame):
def __init__(self, container):
super().__init__(container)
self.Frame3 = Frame(container)
self.Frame3.config(height=200, width=203, bg= 'green')
self.Frame3.place(x=0, y=24)
Frame01 = Frame1(notebook)
notebook.add(Frame01, text = "Connection")
Frame02 = Frame3(notebook)
notebook.add(Frame02, text = "Transient Response")
notebook.place(x=10, y=10)
root.mainloop()
Как говорится, найдите 10 отличий. Единственное отличие, что я имя класса Frame2 поменял на Frame3, а результат разный.