User avatar
Posts: 1
Joined: Thu Jun 14, 2018 12:42 pm

Tkinter - show images in GUI depending on "robot"-state (in real time)

Thu Jun 14, 2018 2:21 pm

Hello folks,

for a long time I was more one of those silent readers, but now I might need some help, because the internet research wasn't that helpful.

I'm working on a desk companion for university research, which is able to track sitting time via face recognition.
That's the part of the program which works perfect.

My current output is terminal based and I'm able to get sitting time, break time and so on.
Also the current "robot" communicates via terminal if he's happy/neutral/sad and so on; depending on the time the person is sitting. Also I get a logfile, which contains break time duration and so on. Overall the robot has seven states, which I can view via terminal.
If the person makes a break, the robot also gets more happy. So the state is always changing.

So far so good; - but that's not enough for my purpose, so I'm working on a GUI for the robot.
The GUI should (atleast) display a robot face (with different emotions) and a health bar.

I choose tkinter for my GUI and I'm able to do basic stuff. I also made the images and know how to display my images in general.

There is always the problem: If I try to run my whole program which contains both parts, it really doesn't work.

My main script contains the logic about the robot state and it's also really important for the logfiles.
So my question is: How can I make a picture based GUI which updates at the same time as the main script.
And what is the best solution? Should I use the after-method, threading or trying to work without a mainloop (Tkinter).

Also; - If someone has maybe some small examples or even a much better solution/suggestion, I would really appreciate it. Tkinter is new for me; - so maybe it's simple to do and I just don't get it. :D

Note: I don't want that some of you do my work for me; - I just simply want to collect some suggestions what would/could work best for my purpose. :)

General info: I'm using a RasPi3b+, a camera module (obviously) and the official RasPi-display for this project.
~ ~ ~ Just an android dreaming of electric sheep. ~ ~ ~

User avatar
Posts: 312
Joined: Mon Dec 15, 2014 7:14 pm
Location: Noo Joysey, USA

Re: Tkinter - show images in GUI depending on "robot"-state (in real time)

Thu Jun 14, 2018 6:10 pm

Using the after method is good solution. I did just that for the xibot project
This robot is using an Arduino controller, but I replaced the Arduino with an Rpi 3 in the razmq project
This project provides for a Kivy and a remi (web based) GUI.

If you have any questions, I would be glad to try and answer them.

Posts: 55
Joined: Mon Jun 18, 2018 11:01 pm

Re: Tkinter - show images in GUI depending on "robot"-state (in real time)

Tue Jun 19, 2018 12:59 am

root.update() worked well for me with afew issues. unsure exactly what is going on with your stuff though. i ran into an issue that mainloop() was hanging and not executing some code... read about using module for threading which actually seemed pretty easy too.

Return to “Python”