TkInter在调用winfo后显示额外窗口。
选择 | 换行 | 行号
- #! /usr/bin/python
- # This one creates three windows because of the Tk().winfo_screenwidth(),
- # Tk().winfo_screenheight() call
- from Tkinter import *
- def quit(): sys.exit(0)
- root = Tk()
- root.title("Test screen")
- w, h = Tk().winfo_screenwidth(), Tk().winfo_screenheight()
- h = h * 0.75
- paper = Canvas(root, width = h, height = h, bg = "#000020")
- a = h / 10
- b = h - a
- paper.create_line(a, a, b, b, fill="white")
- paper.create_line(a, b, b, a, fill="white")
- exitB = Button(text="Exit", width=15, command=quit)
- exitB.pack()
- paper.pack()
- mainloop()
选择 | 换行 | 行号
- #! /usr/bin/python
- # This one creates only a single window.
- from Tkinter import *
- def quit(): sys.exit(0)
- root = Tk()
- root.title("Test screen")
- h = 400
- paper = Canvas(root, width = h, height = h, bg = "#000020")
- a = h / 10
- b = h - a
- paper.create_line(a, a, b, b, fill="white")
- paper.create_line(a, b, b, a, fill="white")
- exitB = Button(text="Exit", width=15, command=quit)
- exitB.pack()
- paper.pack()
- mainloop()
你知道怎么轻松解决这个问题吗?先谢谢你……
格雷格