PDA

View Full Version : Tkinter Mainloop vs My Socket Loop



era86
April 30th, 2008, 07:23 AM
I wrote some code for a client (using sockets of course) to stream an mp3 file from a server. The loop is pretty basic:

connect to server
loop:
get 512 bytes at a time
play the data in speakers
close the connection

Now I want to use Tkinter to make a GUI for my streamer. The problem is, I can't have the Tk.mainloop() running at the same time as my stream loop. Obviously, it will do one or the other first. I would like them to work at the same time.

Would threading solve this?

Any input helps. Thanks.

LaRoza
April 30th, 2008, 10:17 AM
I wrote some code for a client (using sockets of course) to stream an mp3 file from a server. The loop is pretty basic:

connect to server
loop:
get 512 bytes at a time
play the data in speakers
close the connection

Now I want to use Tkinter to make a GUI for my streamer. The problem is, I can't have the Tk.mainloop() running at the same time as my stream loop. Obviously, it will do one or the other first. I would like them to work at the same time.

Would threading solve this?

Any input helps. Thanks.

Yes, threading is the answer.

era86
May 1st, 2008, 07:11 PM
I have tried the threading, but then there is no way to tie the GUI to the runnning process of the stream. Does anybody know any other ways to work around this?