pythontkinterraspberry-pidisplayopenbox

Raspberry Pi - Raspbian Lite - Waveshare 2.8 Inch Display - Openbox/nodm - Tkinter dispaly error


I followed the steps by tjohnson in his post here:

https://raspberrypi.stackexchange.com/questions/57128/how-to-boot-into-own-python-script-gui-only

and was able to get a Python3 Tkinter app running at startup on a raspberry pi using Raspbian Lite. This was using an external HDMI display.

I then installed a Waveshare 2.8 inch display and installed the drivers referenced on their site. The display itself works fine for interacting with the console.

Now, when the pi boots, the Tkinter app does not load as it did with an HDMI-connected display. I just see the console login prompt.

If, on the pi (directly at the device, not over SSH) I run:

python3 /home/pi/App/my_script.py

I get the the following:

tkinter.TclError: no display name and no DISPLAY environment variable

Clearly there is something about the configuration of the Waveshare display that is making it so that I can't run a tkinter app on it. I did a good amount of troubleshooting there but could not find a solution. Any help would be greatly appreciated.


Solution

  • Thanks to stovfl (who went above and beyond in helping me troubleshoot)... I got the display and the tkinter app working with Openbox/nodm/Raspbian Lite.

    Used this article as a resource: https://www.raspberrypi.org/forums/viewtopic.php?p=1050620

    Because it did not exist, I created the dir and file: /etc/X11/xorg.conf.d/99-calibration.conf

    Contents of the file:

    Section "InputClass" 
    Identifier "calibration" 
    MatchProduct "ADS7846 Touchscreen" 
    Option "Calibration" "160 3723 3896 181" 
    Option "SwapAxes" "1" 
    EndSection 
    
    Section "Device" 
    # WaveShare SpotPear 3.5", framebuffer 1 
    Identifier "uga" 
    driver "fbdev" 
    #Option "fbdev" "/dev/fb1" 
    Option "ShadowFB" "off" 
    EndSection 
    
    Section "Monitor" 
    # Primary monitor. WaveShare SpotPear 480x320 
    Identifier "WSSP" 
    EndSection
    
    Section "Screen" 
    Identifier "primary" 
    Device "uga" 
    Monitor "WSSP" 
    EndSection 
    
    Section "ServerLayout" 
    Identifier "default" 
    Screen 0 "primary" 0 0
    EndSection
    

    Note that commenting out this line:

    Option "fbdev" "/dev/fb1" 
    

    was key to making things work.