私はメモを取るアプリケーションを作っています(Windowsの付箋に似ています)。複数の音符を同時に表示する必要があるので、私はThreadから継承したクラスを使用し、tkinterウィンドウも作成しました。問題は、私のウィンドウが同時に開かないということです。 2番目は最初のものが閉じられた後に開きます。ここにコードがあります。私は間違って何をしていますか?私が使用できる別の方法がありますか? [今の私はちょうど私がハードコーディングされているノートを表示しています。]Pythonで複数のtkinterウィンドウを同時に実行するにはどうしたらいいですか?
from tkinter import *
from threading import Thread
class Note(Thread):
nid = 0
title = ""
message = ""
def __init__(self, nid, title, message):
Thread.__init__(self)
self.nid = nid
self.title = title
self.message = message
def display_note_gui(self):
'''Tkinter to create a note gui window with parameters '''
window = Tk()
window.title(self.title)
window.geometry("200x200")
window.configure(background="#BAD0EF")
title = Entry(relief=FLAT, bg="#BAD0EF", bd=0)
title.pack(side=TOP)
scrollBar = Scrollbar(window, takefocus=0, width=20)
textArea = Text(window, height=4, width=1000, bg="#BAD0EF", font=("Times", "14"))
scrollBar.pack(side=RIGHT, fill=Y)
textArea.pack(side=LEFT, fill=Y)
scrollBar.config(command=textArea.yview)
textArea.config(yscrollcommand=scrollBar.set)
textArea.insert(END, self.message)
window.mainloop()
def run(self):
self.display_note_gui()
new_note1 = Note(0, "Hello", "Hi, how are you?")
new_note1.start()
new_note1.join()
new_note2 = Note(1, "2", "How's everyone else?")
new_note2.start()
new_note2.join()
'Toplevel'ウィジェットを使用しますか? –