Creating a basic GUI window V2 (Python)

My previous attempt at creating a GUI window worked but I’ve since learned that when TKinter creates a window it uses a class structure that creates a super (root) window. Frames can then be created within this window to hold applications (buttons, labels etc). I’ve updated my (basic) program so that it now uses these concepts.




#Making a GUI window V2

#libraries to import

from tkinter import *

#create window

root = Tk()

#sets the windows title


#sets windows width x height


#frame to hold the labels / buttons

app = Frame(root)


#create label

text_label = Label(app,text=”GeekTechStuff window now contains text”)


#define an action for the button, in this case it closes the root window

def button_action():


#Add button

button_1 = Button(app,text=”GeekTechStuff Button!”, command=button_action)



#start event loop – creates the window with the above labels and buttons



One thought on “Creating a basic GUI window V2 (Python)

Comments are closed.