File size: 1,014 Bytes
9df4cc0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import tkinter as tk
from tkinter import filedialog, messagebox, simpledialog

def ynbox(title, message):
    response = messagebox.askyesno(title, message)
    return response

def fileopenbox(title, filetypes):
    root = tk.Tk()
    root.withdraw()
    filepath = filedialog.askopenfilename(title=title, filetypes=[(filetypes, filetypes)])
    root.destroy()
    return filepath

def buttonbox(title, message, choices):
    choice = None

    def on_choice(c):
        nonlocal choice
        choice = c
        root.quit()

    root = tk.Tk()
    root.title(title)
    tk.Label(root, text=message).pack()
    for c in choices:
        tk.Button(root, text=c, command=lambda c=c: on_choice(c)).pack()
    root.mainloop()
    root.destroy()

    return choice

def enterbox(message, title, default):
    return simpledialog.askstring(title, message, initialvalue=default)

def msgbox(message):
    messagebox.showinfo("Information", message)

def exceptionbox(message):
    messagebox.showerror("Error", message)