0

私はpythonが初めてです。

以下のようにコーディングしました。ユーザーが「Click button to setup CPE」をクリックしたとき。ボタンをクリックすると、ダイアログ ウィンドウが表示され、顧客リストが表示されます。

私の問題は、ユーザーが「クリックボタンをクリックして CPE を設定する」をクリックしたときです。ボタン、Listing()機能が最初に働いています。その時点で、メイン ウィンドウは死んでいます。が完了するListing()と、ダイアログが表示されます。

ダイアログ ボックスを最初に表示し、ダイアログ ボックスが表示された後に情報を表示するにはどうすればよいですか。

import Tkinter

class myWindow:
    addr = ''
    def __init__(self):

        self.mw = Tkinter.Tk()
        self.mw.option_add("*font", ("Arial", 15, "normal"))
        self.mw.geometry("+250+200")
        self.mw.title("Example of Custom Dialog-Window")

        # CPE
        self.btn_cpe = Tkinter.Button(self.mw, text = "Click button to setup CPE.", command = self.btnCPE)
        self.btn_cpe.pack(padx = 20, pady = 20)
        self.mw.mainloop()


    def btnCPE(self):

        self.dialogwindow = Tkinter.Toplevel()
        self.dialogwindow.title("Dialog Window")
        self.dialogwindow.geometry("+500+350")
        self.dialogwindow.maxsize(500, 350)
        self.dialogwindow.minsize(500, 350)

        self.lab1 = Tkinter.Label(self.dialogwindow, text = "Checking info")
        self.lab1.pack()

        self.lab_addr = Tkinter.Label(self.dialogwindow, text = "Address : ")
        self.lab_addr.pack()

        # Refresh
        self.btn_refresh = Tkinter.Button(self.dialogwindow, text = "Refresh", command = self.refresh)
        self.btn_refresh.pack()

        self.btn_cpe_exit = Tkinter.Button(self.dialogwindow, text = "Exit", command = self.dialogwindow.destroy )
        self.btn_cpe_exit.pack()

        # This is the important line: It tells the main-window to lock:
        self.dialogwindow.grab_set() 

        self.Listing()
        self.lab_addr['text'] = "address : " + self.addr;

    def Listing(self):
        # access the db and set the address into self.addr
4

1 に答える 1