为什么我的tkinter顶级' X'没有调用按钮覆盖方法?

时间:2015-06-19 17:54:56

标签: python tkinter

我创建了一个顶级窗口小部件类,并希望它调用方法'关闭'当窗口是' X' (关闭)。我收到错误 - 姓名'关闭'没有定义的。有人帮我在顶层窗口关闭时运行此方法吗?

焦点代码:

SELECT * FROM(
(SELECT A1.*, A2.ID2, A2.ID3, A2.TYPE1, A2.TYPE2, A2.TYPE3 FROM(
(SELECT A.ID, A.ID1, A.ID2, A.ID3, A.ID4,  B.ID5, B.ID6, B.ID7, B.ID8, B.ID8, B.ID9, B.ID10 from(
(SELECT ID, ID1, ID2, ID3, ID4 FROM RECORD1) AS a left join
(SELECT ID, ID1, ID2, ID3, ID4, ID5, ID6, ID7 FROM RECORD2) AS b 
ON a.ID = b.ID1)) as A1 left join
(select ID, ID1, ID2, ID3, ID4, ID5, ID6, ID7, ID8, Type1, Type2, e.ttype3 as Type3 FROM(
(select ID, ID1, ID2, ID3, ID4, ID5, ID6, ID7, ID8, BB.Type1, CC.D.type AS Type2 from(
(select ID, ID1, ID2, ID3, ID4, ID5, ID6, ID7, ID8, BB.C.Type AS Type1 from(
(SELECT A.*, B.ID1, B.type, b.ID3, b.ID4, ID5 FROM(
(SELECT * FROM record) as a left join
(SELECT * FROM record2) as b on a.ID = b.ID1)) as AA left join
(SELECT Type, ID as ttype1 from record2 where Type='SMALL') as c on aa.id = c.ttype1)) as BB left join **strong text**
(SELECT Type, ID as ttype2 from record2 where Type='MEDIUM') as d on BB.id = d.ttype2)) as CC left join
(SELECT Type, ID as ttype3 from record2 where Type='LARGE') as e on cc.id = e.ttype3)) as A2
on A1.ID3 = A2.ID3)) as A3 left join   # A3 is the first part with 4919 rows
(SELECT a.ID1, a.ID2, b.ID3, b.ID4, b.ID5, b.ID6, b.ID7, b.ID8, b.ID9, b.ID1, b.ID2, b.ID3, b.ID4, b.ID5, b.ID6, b.ID7 from(
(SELECT * FROM record1) as a left join
(SELECT * FROM record3) as b on a.ID1 = b.ID)) AS A4 on A3.ID1 = A4.ID1) on A3.ID1 = A4.ID1)) AS A5 LEFT join #A4 has 4919 rows, and A5 has 50000 rows.

完整代码:

class questions_window():
    def __init__(self, master):
        self.master = master
        self.master.geometry("300x300")
        self.master.title("Questions")
        self.master.protocol("WM_DELETE_WINDOW", close)

    def focus(self):
        self.master.attributes("-topmost", 1)
        self.master.grab_set()

    def close(self):
        global paused
        paused = False
        self.master.grab_release()
        self.master.destroy()

1 个答案:

答案 0 :(得分:2)

close更改为self.close

self.master.protocol("WM_DELETE_WINDOW", self.close)