我应该继续使用这样的线程还是应该使用多处理?我试着让while循环通过按下按钮来切换。你知道吗
线程:
class workingthread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
def run(self):
while 1:
chat = skype.CreateChatWith(name)
chat.SendMessage(message)
t.sleep(timeou)
开始线程:
def this(self,event):
t = workingthread()
t.start()
你的问题有点不清楚。我试着把注意力集中在“我试着让while循环通过按下按钮来切换”部分。据我所知,您希望一直有线程活动(通过活动我认为不会终止线程),但您只希望偶尔执行while循环体。最简单的解决方案是实现一个布尔变量并像这样扩展
workingthread
:现在,您可以使用按钮事件(无论您使用的是什么UI工具箱),将方法绑定到它,并且可以切换
workingthread
的doit
-变量。根据doit
,while循环体是否执行。你知道吗相关问题 更多 >
编程相关推荐