Но в ответ получаю ошибку ‘AttributeError: ’function' object has no attribute ‘entry’'
import tkinter as tk class Window(tk.Tk): def __init__(self): self.root = tk.Tk() def const(self): self.entry = tk.Entry(self.root).pack() self.button = tk.Button(self.root, text="Get", command=self.on_button).pack() def on_button(self): print(self.const.entry.get()) def run(self): self.const() self.root.mainloop() win = Window() win.run()
Если объединить в одном методе, то всё работает, но нужно, чтобы было в отдельных