使用grab_set()最小化Python顶级窗口

时间:2017-01-04 12:30:17

标签: python python-2.7 tkinter minimize

我有一个问题,当我在主窗口上使用grab_set()时,我的顶部窗口不能最小化。

这是一个代码示例:

import Tkinter as tk

class mainApView(tk.Frame):
    def __init__(self, master):
        tk.Frame.__init__(self,master)
        self.master = master
        self.master.title("Mainwindow")
        self.master.geometry("300x100")

        self.frame = tk.Frame(self.master)

        self.button = tk.Button(self.frame,text="create top level", command=self.createTopLevel)
        self.button.pack()

        self.frame.pack()

    def createTopLevel(self):
        popupWindow = tk.Toplevel(self.master)

        # this function disables the minimize button
        self.master.grab_set() 
        newTopLevel(popupWindow)

class newTopLevel():
    def __init__(self,master):
        self.master = master
        self.master.title("New Top Level Window")
        self.master.geometry("300x100")

        self.frame = tk.Frame(self.master)

        self.button = tk.Button(self.frame, text="useless button")
        self.button.pack()

        self.frame.pack()

def main():
    root = tk.Tk()
    app = mainApView(root)
    root.mainloop()

if __name__ == '__main__':
    main()

有解决方法吗?或者类似于grab_set的函数? 或者我如何覆盖最小化按钮?

编辑我的目标是从顶部窗口启用最小化按钮并禁用主窗口

0 个答案:

没有答案