Slofware
Posts: 11
Joined: Tue Jul 26, 2016 5:06 pm

Runn python code in a loop after GUI start

Thu Jul 28, 2016 3:36 pm

Hello,

After I start a GUI in python that I made in Qt creator 5 with the instruction app.exec_() I still want to loop some other python code.
How can I do that?

scotty101
Posts: 3958
Joined: Fri Jun 08, 2012 6:03 pm

Re: Runn python code in a loop after GUI start

Thu Jul 28, 2016 3:42 pm

It depends on whether you just want the task to happen periodically or or an event.

If you want to do it periodically in the background then I'd suggest a timer.

http://stackoverflow.com/questions/3236 ... ng-a-timer

The timer will periodically call a function that contains the code that you wish to run.

Your code should not contain an infinite loop, you are relying on the QT timer to call your function again and again periodically.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

Slofware
Posts: 11
Joined: Tue Jul 26, 2016 5:06 pm

Re: Runn python code in a loop after GUI start

Fri Jul 29, 2016 12:15 pm

Thanx that worked perfect!!

Now the next thing, how can I read or write in python to for example a Slider in the GUI?

Return to “Graphics programming”