答案 0 :(得分:0)
或多或少:
import tkinter as tk
# --- function ---
def on_confirm():
print('Mapwidth:', e1.get())
print('Mapheight:', e2.get())
root.destroy()
# --- main ---
root = tk.Tk()
l = tk.Label(root, text="Width")
l.grid(row=0, column=0)
e1 = tk.Entry(root)
e1.grid(row=0, column=1)
l = tk.Label(root, text="Height")
l.grid(row=1, column=0)
e2 = tk.Entry(root)
e2.grid(row=1, column=1)
b = tk.Button(root, text="Confirm", command=on_confirm)
b.grid(row=2, column=0, columnspan=2)
root.mainloop()