これを「スレッド化」と呼びます。pythons スレッド モジュールを使用します。
2 つの例:
例 1 :
from threading import Thread
class MyCollector(Thread):
def __init__(self, collect_from):
Thread.__init__(self) # must be called !
self.collect_from = collect_from
def run(self):
while True:
# .. collect ur things
collector_thread = MyCollector(my_source_to_collect_from)
collector_thread.start()
# go on with gui
例 2 :
from threading import Thread
def collector(collect_from):
while True:
# .. collect ur things
collector_thread = Thread(target = collector, args = (my_source_to_collect_from,))
collector_thread.start()
# go on with gui