3

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??

Jamie Fernandes
  • 33
  • 1
  • 1
  • 3

3 Answers3

3

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@192.168.1.20   # Replace 192.168.1.20 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.
MadMike
  • 603
  • 5
  • 19
3

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

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

VLC

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

crasic
  • 3,033
  • 1
  • 11
  • 20
0

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.

Ricardo
  • 1,068
  • 8
  • 7