Creating a basic GUI window (Python)

So far my Python programs have been very much text input based, i.e. users would need to use a command line to input values or progress in the program. This is okay for some users but the majority of modern computer users prefer using a Graphical User Interface (GUI), and Python does allow for a GUI.

I have created a quick little program just to show off a very basic GUI window interface, displaying some text and having an action carried out when a button is pressed.




#Making a GUI window

#libraries to import

from tkinter import *

#create window

window = Tk()

#create window with text in it


text_in_window.insert(END,’We have made a window containing text’)


#create a window containing a button

#define an action  for the button

def button_action():



#put action and button together

button = Button(window, text=”Exit”, command=button_action)



This program makes use of the Tkinter library to create the GUI.

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

Comments are closed.