The second code does what you want with the following changes
fix the import by removing the capitol t and don't use * import
remove the
fix the import by removing the capitol t and don't use * import
remove the
()
from command = self.OnButtonClick()
import tkinter as tk class Window(tk.Tk): def __init__(self, parent): tk.Tk.__init__(self, parent) self.parent = parent self.initialize() def initialize(self): self.geometry("600x400+30+30") wButton = tk.Button(self, text='text', command = self.OnButtonClick) wButton.pack() def OnButtonClick(self): top = tk.Toplevel() top.title("title") top.geometry("300x150+30+30") topButton = tk.Button(top, text="CLOSE", command = top.destroy) topButton.pack() if __name__ == "__main__": window = Window(None) window.title("title") window.mainloop()