def center(widget, width, height):
    """
    Center the given widget.
    """
    screen_width = widget.winfo_screenwidth()
    screen_height = widget.winfo_screenheight()
    x_offset = int(screen_width / 2 - width / 2)
    y_offset = int(screen_height / 2 - height / 2)
    widget.geometry('{}x{}+{}+{}'.format(width, height, x_offset, y_offset))
