如何实现点击button之后 显示一个新的窗口并且使button那个窗口直接消失
先贴上代码
#coding:utf-8
import Tkinter as tk
from Tkinter import *
import tkMessageBox
root = tk.Tk()
root.title('Test')
e = StringVar()
def callback():
#tkMessageBox.showinfo('title','hello world')
entry = Entry(root,textvariable = e)
e.set('请输入')
entry.pack()
def bnt():
Button(root,text = '确认使用',fg='red',bd = 2,width =28,
command = callback).pack()
root.withdraw()
bnt()
root.mainloop()
但比较蛋疼的是。。用了withdraw之后button窗口就直接匿了。。。点都点不了
Same as shomy, I rarely use Tkinter, so I wrote a PyQt4 version. You can try it, and it runs without any problem in my own test
PS: If there are no special requirements, it is recommended to use PyQt4/PyQt5 for development. Reasons:
1) With the help of Qt’s powerful class library, PyQt can do many things, such as graphics drawing, XML parsing, Network programming, database reading and writing, etc. In other words, PyQt is not only a GUI library, but also includes non-GUI parts.
2) With the help of Qt Designer, you can drag and drop the graphical interface part, which is very efficient.
3) Strong community support. For example, there is a Python IDE developed based on PyQt. This is more popular in the open source community than Tkinter currently seems to be.