私は現在、Tkinter EntryボックスをGoogleカレンダーに挿入する小さなプログラムを作成しています。その部分は問題ではありません。 私はTkinterウィンドウ中に「ホールド」したくないときに同時にターミナルを起動しているので、開いています。Python - Tkinterウィンドウがself.destroyで閉じないのはなぜですか?
私は、ウィンドウのすべての部分
def quit(self):
self.thread.stop()
self.destroy()
を使用して、ウィンドウを閉じて消えるが、ウィンドウが画面に残ります。
class window(Frame):
def __init__(self, parent, thread):
Frame.__init__(self, parent)
self.parent = parent
self.w = 600
self.h = 400
self.initUI()
self.center()
self.thread = thread
私は、クラスを作成するには、このfuncitonを使用します。
def main(thread):
root = Tk()
root.resizable(width=False, height=False)
app = window(root, thread)
root.mainloop()
myThreadクラス。
class myThread(threading.Thread):
def __init__(self,threadType):
threading.Thread.__init__(self)
self.threadType = threadType
self.event = threading.Event()
def stop(self):
self.event.set()
def run(self):
if self.threadType == "new_app":
newappoint.main(self)
elif self.threadType == "main":
main()
ウィンドウが正しく閉じるようにしていないかどうかを誰かに教えてもらえますか? self.quit()
tkinterとスレッドはよく混ざりません。たとえば、http://stackoverflow.com/questions/10556479/running-a-tkinter-form-in-a-separate-thread –
@shivsnを参照してください。 ) –
@JJHakalaしたがって、元のメイン関数をスレッド化し、Tkinterを変更して起動する変数を探すために 'if __name__ == __main __:'ループを保つ方が良いでしょうか? –