Oct-15-2023, 03:06 PM
(This post was last modified: Oct-15-2023, 03:07 PM by deanhystad.)
If all you want to do is display a block of text and an ok button, look at tkinter.dialog.Dialog, the parent class for tkinter common dialogs.
import tkinter as tk from tkinter.dialog import Dialog, DIALOG_ICON class Window(tk.Tk): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.title("Basic Dialog Demo") tk.Button( self, text='Push me! Push me! Push me!', command=self.opendialog ).pack(padx=80, pady=(100, 10)) def opendialog(self): with open(__file__, "r") as file: text = file.read() Dialog( self, title="Popup Dialog", text=text, bitmap=DIALOG_ICON, default=0, strings=("OK",) ) print("Dialog closed.") Window().mainloop()