1

I would like to run a tkinter-generated GUI generated on a Raspberry Pi while connected via SSH on a Mac. I have tried several suggestions (e.g. https://stackoverflow.com/questions/37604289/tkinter-tclerror-no-display-name-and-no-display-environment-variable) but none seem to work. All of the variations including modifications to /etc/sudoers and ~./bashrc have failed with consistent messages "_tkinter.TclError: no display name and no $DISPLAY environment variable" or something similar on the remote machine. The tkinter GUI works fine on the host Raspberry Pi running Raspbian Stretch. All I want to do is project the GUI onto the remote client. I'd appreciate any help including referrals to previous discussions that I might have missed.

0

Tkinter is an X Window System application and needs an X Display to show itself on. In X Windows you can specify a local or remote display using the DISPLAY environment variable or -display parameter. How you do this depends on your system but if you want to display on the local display it needs to be running a desktop session and you need permission (typically via xauth) to connect to that display. The local display will most likely be DISPLAY=:0.0 and you can configure this for your Tkinter application. Permission is usually handled via tokens stored in $HOME/.Xauthority so if you are using ssh as the same user that is logged into the desktop then just setting DISPLAY will be sufficient. If not you can copy the token from the logged in user to your ssh user using:

export DISPLAY=:0.0
sudo xauth -f ~xuser/.Xauthority extract - $DISPLAY | xauth merge -

If you want the Tkinter application to appear on your local display then you can tunnel the X protocol using ssh -X user@remotehost which will setup a tunnel and configure the DISPLAY environment variable on the server so that X Window applications will draw on your local desktop. Works if you are using X Windows locally (ie: linux desktop or Windows with an X Windows implementation)

0

Simple answer - you can’t.

The Mac doesn’t have an X client, although there are options to install one (which is off-topic).

Viable options are to use RealVNC to display a virtual screen on the Mac or run a tkinter program on the Mac remotely accessing the Pi.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.