0

我按照 tjohnson 在他的帖子中的步骤操作:

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

并且能够使用 Raspbian Lite 在启动时在树莓派上运行 Python3 Tkinter 应用程序。这是使用外部 HDMI 显示器。

然后我安装了 Waveshare 2.8 英寸显示器并安装了他们网站上引用的驱动程序。显示器本身可以很好地与控制台交互。

现在,当 pi 启动时,Tkinter 应用程序不会像连接 HDMI 的显示器那样加载。我只看到控制台登录提示。

如果在 pi 上(直接在设备上,而不是通过 SSH)我运行:

python3 /home/pi/App/my_script.py

我得到以下信息:

tkinter.TclError:没有显示名称,也没有 DISPLAY 环境变量

显然,Waveshare 显示器的配置导致我无法在其上运行 tkinter 应用程序。我在那里进行了大量的故障排除,但找不到解决方案。任何帮助将不胜感激。

4

1 回答 1

0

感谢 stovfl(他帮助我排除故障)...我得到了显示器和 tkinter 应用程序与 Openbox/nodm/Raspbian Lite 一起使用。

使用这篇文章作为资源: https ://www.raspberrypi.org/forums/viewtopic.php?p=1050620

因为它不存在,所以我创建了目录和文件:/etc/X11/xorg.conf.d/99-calibration.conf

文件内容:

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

请注意,注释掉这一行:

Option "fbdev" "/dev/fb1" 

是让事情顺利进行的关键。

于 2019-11-23T16:27:20.170 回答