Please consider that these instructions may not be the ideal solution depending on the needs of a given project. Adafruit’s forums are a valuable resource for help regarding their products.

These are the steps I used in order to run a fullscreen Python app on a Raspberry Pi with an Adafruit 2.8” resistive TFT display.

Raspberry Pi With an Adafruit TFT Display

The first thing we need to do is enable support for the TFT on our Raspberry Pi.

Adafruit PiTFT Support

As of time of writing, Adafruit offers an installation script that is designed to work with the latest standard/official Raspbian images. Adafruit previously offered custom Raspbian images with TFT support built in. Those images are now deprecated and the use of the script is encouraged.

Unless otherwise noted, or the process changes over time, one should use the installation script as instructed by Adafruit to enable a PiTFT with touch support!


For this process, I am using Raspbian Lite as the base image for my Pi and then installing an X11 environment.

Enable the nonfree Raspbian repository. The Adafruit script requires this, and as of time of writing, this repo is not enabled by default..

cat << EOF | sudo tee /etc/apt/sources.list.d/nonfree.list
deb stretch main contrib non-free rpi firmware

Install required packages for our fullscreen app.

sudo apt-get update && \
sudo apt-get install --no-install-recommends \
    sudo \
    cmake \
    xorg \
    openbox \
    lightdm \
    python3 \
    python3-tk \
    xserver-xorg-legacy \

Modify the lightdm config script at /etc/lightdm/lightdm.conf to enable autologin if it is not already enabled.

cat << EOF | sudo tee /etc/lightdm/lightdm.conf
# Prevent the screen from shutting off automatically.
xserver-command=X -s 0 dpms

Run the Adafruit TFT install script as described on their site.

cd ~ && \
wget && \
chmod +x && \
sudo ./

Reboot the Pi. It should log in as pi automatically to openbox. Your screen will most likely be blank at this point with only a mouse cursor.


Create the openbox config directory for the pi user if it does not exist.

mkdir -p $HOME/.config/openbox

Create a script at $HOME/.config/openbox/autostart for the pi user. This script will be run at login.

cat << EOF > $HOME/.config/openbox/autostart
# redirect all output to a log file
# -u so that output is flushed immediately to the log
python3 -u $HOME/ > $HOME/app.log 2>&1 &

The & at the end is required for every command in the autostart script.

Create a file $HOME/ for our python application code.

import tkinter as tk

class FullScreenApp(object):

    def __init__(self, master, **kwargs):
        master.geometry(self.dimensions.format(width, height))

        b = tk.Button(self.master, text="Press me!", command=lambda: self.pressed()), rely=0.5, anchor=tk.CENTER)

    def pressed(self):




Reboot. The app should launch automatically in fullscreen mode.

Screen On / Off

You can use a script like this to enable or disable the LCD with the first two GPIO buttons tied to the TFT.

#!/usr/bin/env python3

import RPi.GPIO as GPIO
import time
import os

apt-get install python3-rpi.gpio


GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP)

while True:
    # Screen on
    input_state = GPIO.input(17)
    if input_state == False:
        print('screen on', flush=True)
        print('1', file=open('/sys/class/backlight/soc:backlight/brightness', 'w'))

    # Screen off
    input_state = GPIO.input(22)
    if input_state == False:
        print('screen off', flush=True)
        print('0', file=open('/sys/class/backlight/soc:backlight/brightness', 'w'))

    # Screen off and power off
    input_state = GPIO.input(27)
    if input_state == False:
        print('screen off and power off', flush=True)
        print('0', file=open('/sys/class/backlight/soc:backlight/brightness', 'w'))
        os.system('shutdown -h now')

You could potentially have the script run at boot by appending the following to /etc/rc.local at the end of the file before it calls the exit command.

python3 -u /home/pi/

It seems there may be a few reasons the TFT/LCD will automatically shut off, and changing the brightness does nothing in that case. So those buttons and the accompanying script would be useless at that point.

The lightdm.conf above should disable the auto-off behavior of the TFT, but other methods may be required as well.