Python Forum
[PyGUI] Threading in gui - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [PyGUI] Threading in gui (/thread-29836.html)



Threading in gui - razor23 - Sep-22-2020

Hello fellow programers

I am new to python and i have a Rasberry PI 4 , 2 GB.

I am building a button matrix with 80 buttons, (matrix style is 8x12) and want to implement to work with GUI.

Matrix is in WHILE loop and if i put it anywhere in program, program is not responding, it stays in matrix loop.

Next thing i have tried to make a matrix loop run in THREAD (only one thread, that checks for button presses) but i dont know how to call a thread to start when i start GUI.

Also i want that GUI reads button matrix and if a button is pressed it should update it in text widget or similar.

I will later implement matematics behind button matrix.

Can you please help, or refer to some resources so i can learn.

Best regards, and thanks in advance,
Josip


RE: Threading in gui - DPaul - Sep-23-2020

The while loop detects the GPIO event-changes when a button is pressed.
What stops you from calling a function outside the while loop?
while ...
if GPIO.event_detected(16):
do_something():
Paul