can make for brittle code when building up larger gui structures but by subclassing frame as we've done herethe class becomes an enclosing context for the guiwidgets are added by attaching objects to selfan instance of frame container subclass ( buttoncallback handlers are registered as bound methods of selfand so are routed back to code in the class ( self messagestate information is retained between events by assigning to attributes of selfvisible to all callback methods in the class ( self datait' easy to make multiple copies of such gui componenteven within the same processbecause each class instance is distinct namespace classes naturally support customization by inheritance and by composition attachment in senseentire guis become specialized frame objects with extensions for an application classes can also provide protocols for building widgets ( the make_widgets method here)handle standard configuration chores (like setting window manager options)and so on in shortframe subclasses provide simple way to organize collections of other widget-class objects attaching class components perhaps more importantlysubclasses of frame are true widgetsthey can be further extended and customized by subclassing and can be attached to enclosing widgets for instanceto attach the entire package of widgets that class builds to something elsesimply create an instance of the class with real parent widget passed in to illustraterunning the script in example - creates the window shown in figure - example - pp \gui\intro\gui py from sys import exit from tkinter import from gui import hello parent frame(noneparent pack(hello(parentpack(side=rightget tk widget classes get the subframe class make container widget attach hello instead of running it button(parenttext='attach'command=exitpack(side=leftparent mainloop(reusable gui components with classes