Simple GUI with Tkinter

 

from tkinter import * # Import all definitions from tkinter

window = Tk()   # Create a window
label = Label(window, text = "Welcome to Python")   # Create a label
button = Button(window, text = "Click Me")  # create a button
label.pack() #Palce the lebel in the window
button.pack() # Place the button in the window

window.mainloop() # Create an event loop
  • window.mainloop()
    The statement creates an event loop. The event loop processes events continuously until
    you close the main window.