figure - example - pp \gui\intro\gui py from tkinter import class hello(frame)def __init__(selfparent=none)frame __init__(selfparentself pack(self data self make_widgets(an extended frame do superclass init attach widgets to self def make_widgets(self)widget button(selftext='hello frame world!'command=self messagewidget pack(side=leftdef message(self)self data + print('hello frame world % !self dataif __name__ ='__main__'hello(mainloop(figure - custom frame in action this example pops up single-button window when pressedthe button triggers the self message bound method to print to stdout again here is the output after pressing this button four timesnotice how self data ( simple counter hereretains its state between pressesc:\pp \gui\intropython gui py hello frame world hello frame world hello frame world hello frame world this may seem like roundabout way to show button (we did it in fewer lines in examples - - and - but the hello class provides an enclosing organizational structure for building guis in the examples prior to the last sectionwe made guis using function-like approachwe called widget constructors as though they were functions and hooked widgets together manually by passing in parents to widget construction calls there was no notion of an enclosing contextapart from the global graphical user interfaces