def errorpopup(code): tl = Toplevel(root) tl.title("Error") tl.tkraise() if (code == "Date"): message = "Invalid Date, use format YYYY-MM-DD" elif (code == "Connection"): message = "Connection Error, try again" elif (code == "Credentials"): message = "Invalid username/password, try again" tl.Label = Label(tl, text=message) tl.Label.grid(row=1, column=1, pady=10) tl.Button = Button(tl, text="Ok", command=tl.destroy) tl.Button.grid(row=2, column=1)