部分参考:
1. 3种系统信息提示方式
showinfo('greeting','Greeting') #(提示信息的标题,提示信息的内容)
showerror('Not Implemented','Not yet available')#错误提示消息
if askyesno('Verify quit','Are you sure you want to quit?'):#选择信(ask yes no=>askyesno)
Frame(self).quit
2.改变光标显示
#Frame
toolbar=Frame(self,cursor='hand2')#cursor->光标
3.禁用button与检测输入
#禁用buuton
self.button_ok['state']='disable'#tkinter.DISABLED
检测输入,解锁button_ok:
def active_btn(self, event=None):
'''
active the button_ok
'''
def validate():
return self.entry_id and self.entry_passwd.get()
if validate():
self.button_ok['state'] = ACTIVE
##############
self.button_ok.configure(command=self.apply)
注册管理还可以参考:
4. quit 与 destroy区别
"quit() stops the TCL interpreter. This is in most cases what you want, because your Tkinter-app will also stop. It can be a problem, if you e.g. call your app from idle. idle is itself a Tkinker-app, so if you call quit() in your app and the TCL interpreter gets terminated, idle will also terminate (or get confused ).
destroy() just terminates the mainloop and deletes all widgets. So it seems to be safer if you call your app from another Tkinter app, or if you have multiple mainloops."
taken from
5. button 风格
tkinter.button #更多选择
tkinter.ttk.button #设置风格button.config(style='Toolbutton')
TkUtil.button()<=>tkinter.ttk.button
6.几个常见弹窗
from tkinter.filedialog import Open,SaveAs,Directory
filename=Open(title='open').show()
filename=SaveAs().show()
filename=Directory().show()
from subprocess import call
call(filename)