python - How to use QThreads with libtorrent in PyQt? -


i want write simple pyqt torrent client, i've got snag that. run loop takes care of downloading files (simple code using libtorrent) in pyqt code. although, when torrent downloading works, ui doesn't show , when change order of called functions, ui shows downloading doesn't work. read qthreads it's bit hard me - explain how qthread work , how use libtorrent? here's example of torrent client code:

import libtorrent lt import time import sys  ses = lt.session() ses.listen_on(6881, 6891)  info = lt.torrent_info(sys.argv[1]) h = ses.add_torrent({'ti': info, 'save_path': './'}) print 'starting', h.name()  while (not h.is_seed()):    s = h.status()     state_str = ['queued', 'checking', 'downloading metadata', \       'downloading', 'finished', 'seeding', 'allocating', 'checking fastresume']    print '\r%.2f%% complete (down: %.1f kb/s up: %.1f kb/s peers: %d) %s' % \       (s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, \       s.num_peers, state_str[s.state]),    sys.stdout.flush()     time.sleep(1)  print h.name(), 'complete' 

i imagine qt runs message loop doesn't return until application terminated.

what believe want move loop body (that polls libtorrent status) message handler that's called regularly qt. say, timer function.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -