pythonuser-interfacetkintersshraspberry-pi4

Is it possible to access a GUI over SSH terminal?


I am writing a python script on a windows pc which I intend to be used on a Raspberry Pi 4B with an MPU6050 sensor attached to it, the core feature of this script is to have a GUI be created using tkinter.

While I can easily connect the RasPi to one of my (2) monitors I only have 1 keyboard and mouse, the crux of my problem is I have a sensor attached to the RasPi which the script is interacting with and I need to see if the GUI is being updated properly and make adjustments more easily without having to constantly swap out cables and connections every time I want to test and fix my code. I am using Git to transfer the files between the devices.

I found a suggestion of SSHing into the RasPi by typing ssh -Y ras@ip but only get an error in response _tkinter.TclError: no display name and no $DISPLAY environment variable, I'm not sure if I'm running the file the wrong way or there is something else I may need to install to have it work as intended.


Solution

  • I finally pieced together the solution.

    First of I was supposed to be using PuTTY which I believe allows for X11 forwarding as opposed to using powershell as I had been doing already, I also found I needed to install a software called Xming which is used to run the X server on my pc(I am not sure what exactly it does but it works).

    On running Xming and turning on X11 forwarding in PuTTY and connecting to the remote RasPi I was able to run the test script I had and the GUI appeared on my pc's monitor which I could interact with like any other windows.