1from tkinter import *
2
3def alert_popup(title, message, path):
4 """Generate a pop-up window for special messages."""
5 root = Tk()
6 root.title(title)
7 w = 400 # popup window width
8 h = 200 # popup window height
9 sw = root.winfo_screenwidth()
10 sh = root.winfo_screenheight()
11 x = (sw - w)/2
12 y = (sh - h)/2
13 root.geometry('%dx%d+%d+%d' % (w, h, x, y))
14 m = message
15 m += '\n'
16 m += path
17 w = Label(root, text=m, width=120, height=10)
18 w.pack()
19 b = Button(root, text="OK", command=root.destroy, width=10)
20 b.pack()
21 mainloop()
1import tkinter as tk
2
3def popupmsg(msg, title):
4 root = tk.Tk()
5 root.title(title)
6 label = ttk.Label(root, text=msg)
7 label.pack(side="top", fill="x", pady=10)
8 B1 = tk.Button(root, text="Okay", command = root.destroy)
9 B1.pack()
10 popup.mainloop()