Graphical Widgets

The components that make up apps

To create a GUI or Graphical User Interface, we can use a set of ready-made widgets which come with Python.

These widgets can be combined in any layout to create a basic app.

App Window

Basic Example

window = tkinter.Tk()
window.mainloop()

Complex Example

window = tkinter.Tk()

window.title("App of Awesomeness")
window.geometry(300, 300)

window.mainloop()

Properties

None of note

Functions

  • mainloop
  • title
  • geometry

Label

Basic Example

my_label = tkinter.Label(app_window)
my_label.config(text="Hello!")
my_label.grid()

Complex Example

my_label = tkinter.Label(app_window)
my_label.config(text="Hello!", fg="red", font="Comic Sans MS 16 bold")
my_label.grid()

Properties

  • text
    The words to display on the label.
  • fg
    The text colour. The letters “fg” stand for “foreground”.
  • font
    Font properties including the actual font, size in pixels, and whether it should be bold or italic.

Functions

None of note

Entry

Basic Example

Complex Example

Properties

None of note

Functions

None of note

Text

Basic Example

Complex Example

Properties

None of note

Functions

None of note

Button

Basic Example

Complex Example

Properties

None of note

Functions

None of note

Listbox

Basic Example

Complex Example

Properties

None of note

Functions

None of note