我想在OS X上的父级上面保留一个子窗口
我试过搜索谷歌,但我找不到任何有用的东西。
我是python和OS X的新手,所以我可能会错过一些简单的东西。
我正在使用python3.4和OS X 10.7
#!/usr/bin/python
# -*- coding: utf-8 -*-
from tkinter import *
from tkinter.ttk import *
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def childWindow (self,parent):
window = Toplevel(parent)
self.style = Style()
self.style.theme_use("default")
window.wm_title('Child')
message = "This is the child window"
Label(window, text=message).pack()
Button(window, text='Close', command=window.destroy).pack(padx=2.5,pady=2.5)
# Lift above parent
window.lift(aboveThis=parent)
# Disable parent
window.grab_set()
def initUI(self):
self.parent.title("Root")
self.style = Style()
self.style.theme_use("default")
b1 = Button(self, text='Quit', command=self.quit)
b2 = Button(self, text='test: Child Window', command=lambda: self.childWindow (self))
b1.pack(side=LEFT,padx=2.5,pady=2.5)
b2.pack(side=LEFT,padx=2.5,pady=2.5)
self.pack(fill=BOTH, expand=1)
def main():
root = Tk()
app = Example(root)
root.mainloop()
if __name__ == '__main__':
main()