Passing variables between windows
Two different windows may need to share information during program execution. While this data might be saved to disk and read from the window that consumes it, in some circumstances it is more straightforward to handle it in memory and simply pass this information as variables.
Getting ready
The main window will contain three radio buttons to select the type of user that we want to create, and the secondary window will open the form to fill in the user data:

How to do it...
To hold the user data, we create namedtuple
with fields that represent each user instance. This function from the collections
module receives the type name and a sequence of field names, and returns a tuple subclass to create lightweight objects with the given fields:
import tkinter as tk from collections import namedtuple User = namedtuple("User", ["username", "password", "user_type"]) class UserForm(tk.Toplevel): def __init__(self, parent, user_type): super().__init__(parent...