import tkinter as tk
class Form(tk.Frame):
def __init__(self, root):
super().__init__(root)
self.master = root
self.master.title('Window #1')
self.master.resizable(False, False)
self.master.geometry('500x600')
self.build()
def build(self):
frame = tk.Frame(self, width = 500, height = 600, bg = 'green')
frame.pack()
def main():
root = tk.Tk()
form = Form(root)
form.pack()
root.mainloop()
if __name__ == '__main__':
main()
Объяснение:
import tkinter as tk
class Form(tk.Frame):
def __init__(self, root):
super().__init__(root)
self.master = root
self.master.title('Window #1')
self.master.resizable(False, False)
self.master.geometry('500x600')
self.build()
def build(self):
frame = tk.Frame(self, width = 500, height = 600, bg = 'green')
frame.pack()
def main():
root = tk.Tk()
form = Form(root)
form.pack()
root.mainloop()
if __name__ == '__main__':
main()
Объяснение: