Ah yes, that Informit article helped endlessly - I'm all done now - got
the backend to fetch the info from the server every 2secs using a
QThread, then it pass the data back to the GUI frontend by raising a
custom event!
Thanks for all the help folks, now I'm off to compile the new PyQt 3.14
;-)
OK, I've implemented the 2sec threaded update, but I'm having some
problems with it.
Basically the thread will have to just run constantly, never exiting
(just sleeping for 2secs), which seems to work OK except when I try to
get the thread to do anything with the main program's window.
As the
Simon John napisa(a):
Damn, seems Qt GUI objects (windgets) aren't thread-safe:
http://doc.trolltech.com/3.3/threads.html#11
Like most (if not all) others GUI toolkits.
So I'm going to have to find a way of using a thread to fetch the data,
and then using the main program to update the GUI...
import time
play_something()
time.sleep(LengthOfSongInSeconds)
do_something()
Have you tried that? I'd be interesting in seeing this app you have. !
--
http://mail.python.org/mailman/listinfo/python-list
I don't think time.sleep() will work too well, I think it will cause
the program to hang around in the foreground, and prevent the GUI
updating.
I'll give it a try just to make sure, as I can't figure out the
signal/alarm thing (the alarm only seems to trigger when I click a
button, not after
Damn! signal is not supported on Windows.
time.sleep() doesn't work, as I suspected::
def info(self):
sleep(5)
self.info()
Basically causes the function to pause, then call itself again, all in
the foreground :-(
I'm thinking some sort of thread timer is the way to go, but really
don't
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
Hmm, yes I had thought of looking around PyQt for a timer, forgot about
it though.
As far as querying the server every few seconds, it does make sense
(you don't miss events) and is the recommended way of doing things with
InetCtrl, but I'd prefer to save the bandwidth/server load than have
Simon John wrote:
As far as querying the server every few seconds, it does make sense
(you don't miss events) and is the recommended way of doing things with
InetCtrl, but I'd prefer to save the bandwidth/server load than have
realtime status updates.
The amount of bandwidth and server load that
Jeff Shannon wrote:
[snip]
The amount of bandwidth and server load that will be used by a
once-a-second query is probably pretty trivial (unless you're
expecting this to run over internet or dialup networks -- and even
then, it's probably not going to be worth worrying about). Even on
an
I'm writing a PyQt network client for XMMS, using the InetCtrl plugin,
that on connection receives a track length.
To save on bandwidth, I don't want to be continually querying the
server for updates (e.g. has the current track finished yet?) so I
figured the best thing to do is just update after
Simon John [EMAIL PROTECTED] writes:
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)?
See the signal module and use the alarm signal.
--
12 matches
Mail list logo