I have written a Python Tkinter program which uses buttons to control a Motor which is linked to the GPIO pins, It also displays any changes as a tkiner label e.g Button pressed will change the label to "Button Pressed". I want to know how to run a python file in Ubuntu to show the GUI in Ubuntu but the commands will run from Python will be directly linked to the Raspberry Pi.

I don't know if I explained it well??


My understanding, you have a script/program that collects data and displays this data on the screen. You would like to have the display on a desktop PC, but the data collection code executing on raspberry PI.

This is the beginning of industrial control and automation, which is a very wide topic.

Software Engineering

You may split the program into a client/server where you have one application acting as a server, accepting commands to control the motor.

There are a variety of approaches, a simple web server may be enough. In industrial systems, PLCs are used to interface controllers and sensors.


xpra (docs) is a X11 forwarder that allows remote code to run against a local X Server, and allows for connect/disconnect like screen or tmux. It has better performance and ability to reconnect compared to ssh -X, but the principle is the same.

start a remote terminal

xpra start ssh:SERVERHOSTNAME --start=xterm

reattach to a remote display

xpra attach ssh:serverhostname


A simple solution is to have the desktop act as a full fledged remote display to the raspberry PI.

  • A nice good answer. X11 forwarding will get you going quickly without changing your script. But long term solution is to seperate to a server and interface view. – Angry 84 Oct 27 '18 at 2:39

Use ssh with X-Forwarding

When you access raspberrypi from a Linux-machine with a XServer (as Ubuntu does) you have the possibility to use ssh and tell it use X-Forwarding like this:

ssh -X pi@   # Replace with the current IP of your PI.

Now when run your program in the new ssh-shell all the UI will be presented on your Ubuntu machine.

There are downsides to this technique worth mentioning:

  • This only works as long as the ssh-session is running and both your RaspberrPI and Ubuntu. You can't (easily) loose the connection and reconnect.
  • It will be only fast enough for simple programs. It will be pretty slow if you try to use that with bigger applications.
  • xpra is a very good alternative to x-forwarding which runs over SSH, the primary advantage in that it doesn't require X11 on the server. The performance is much better and it runs under user privilege (better security) – crasic Sep 22 '17 at 2:11
  • @crasic sounds pretty useful. How about posting a answer about it? – MadMike Sep 22 '17 at 4:31

If I understand correctly, you want to remotely run your Tkinter. In that case, you could look into Paramiko, which hopefully allows you to do that from Ubuntu.

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.