Simon John wrote:

I'm writing a PyQt network client for XMMS, using the InetCtrl plugin,
that on connection receives a track length.

[...]

So, how would I make a Python program automatically call a function
after a preset period of time, without the Python process running in
the foreground (effectively single-tasking)?

I'm not familiar with Qt/PyQt myself, but the GUI toolkits I *am* familiar with all have a concept of a timer. Basically, you create a timer that, when the specified amount of time has elapsed, will either deliver an event/message to your application's event queue or will directly call the callback function you provide.


However, I'd suggest that you may not want to wait for the entire length of the current track, especially if some other process or user (on any machine) may have access to the same XMMS application. What happens when, after the song's been playing for a few seconds, someone skips to the next track? Presumably, you'll want your network client to detect that and update appropriately. This implies that you should check back in with the XMMS "server" every few seconds at least. (You can still use a timer to do this; just have it fire periodically every second or so, rather than only after several minutes.)

Jeff Shannon

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to