[英]tkinter through VNC without physical display
My setup is: 我的设置是:
I'm AFP-ed, SSH-ed and VNC-ed to my RPi, and I can run all the command-line scripts I wrote, and also I can open any installed GUI applications, however, when I want to run a tkinter-based GUI app, to control some hardwares connected to the GPIO, I'm having this error message: 我是AFP-ed,SSH-ed和VNC-ed到我的RPi,我可以运行我写的所有命令行脚本,也可以打开任何已安装的GUI应用程序,但是,当我想运行tkinter时基于GUI的应用程序,以控制连接到GPIO的一些硬件,我有这样的错误消息:
Client is not authorized to connect to ServerTraceback (most recent call last):
...
_tkinter.TclError: couldn't connect to display ":1"
My guess is, that this is related to the fact, that there is no physical display attached to the RPi, although I don't know how to solve this situation. 我的猜测是,这与RPi没有附加物理显示的事实有关,虽然我不知道如何解决这种情况。
Thanks in advance! 提前致谢!
I asked this question on RaspberryPi Stack Exchange site, and @hildred had a beautiful solution for this: 我在RaspberryPi Stack Exchange网站上提出了这个问题 , @ hildred为此提供了一个漂亮的解决方案:
Write these few lines to etc/sudoers
*: 把这几行etc/sudoers
*:
Defaults env_reset
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Defaults env_keep += "DISPLAY"
Defaults env_keep += "XAUTHORITY"
And these few lines to ~/.bashrc
: 这几行到~/.bashrc
:
if [ -z "$XAUTHORITY" ]; then
if [ -e $HOME/.Xauthority ]; then
export XAUTHORITY=$HOME/.Xauthority;
fi;
fi
**On a Raspbian this will be etc/sudoers.d/README
for example* **在Raspbian上,这将是etc/sudoers.d/README
例如*
A person on the Raspberry Pi forums solved a similar problem with tkinter : Raspberry Pi论坛上的一个人用tkinter解决了类似的问题 :
A simple work around is to give root the proper authorization to use the X11 connection. 一个简单的解决方法是为root提供使用X11连接的正确授权。 Again, within a LXTerminal window: 同样,在LXTerminal窗口中:
pi@raspberrypi ~ $ sudo xauth add `xauth list`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.