I'm a relatively new Python programmer, but I have all the basics down. Currently I'm working on a program that sends and receives serial input and receives video input. I have gotten this to work in a basic command prompt structured code however I want to be able to implement a Tkinter GUI to lessen the complication of using a command prompt. However the big problem I am having is updating things after I have created the GUI. for example I have Label widget that displays an image from the webcam, but the image is constantly being updated so it only shows the very first image. Also I have to be able to repeatedly send and receive serial information and change certain variables after obtaining that information; these variables affect many of the widgets, what they display, and what they do. I have tried doing an infinite loop so that I can get input but when I do the GUI disappears. Do I have to remake the widgets each time something is updated? Is there a different way to go about implementing a GUI? I have also heard that threading may be able to solve my problem. If anyone could steer me in the right direction that would be fantastic. Also please forgive me if I was overly vague.

Well if your running your tkinter gui by calling: root.mainloop() or something similiar then you should change that to:

while 1:
    root.update()
    #repeat code here

You do everything as normal but then when you get to the displaying part, you enter a loop which updates the gui and runs whatever code you need running... there is a rather nasty drawback to that, if some code in that loop either hangs or takes a while to execute then your gui is also going to freeze. In my opinion the easiest way would be to use threads, and just thread either the gui or whatever function you have that blocks the rest of the program

Thanks for the information, however the problem is that when I use the serial ser.readLine() it will wait for input. This means that whenever it attempts to read in the serial input it freezes. I think threads would be the best way to go about this, the problem is I what threads are I just don't know how to use them. If anyone can point me to a hand-holding tutorial on threads that would be fantastic.

This article has been dead for over six months. Start a new discussion instead.