tkinter杂记=>长期更新

来源:互联网 发布:女生学软件测试 编辑:程序博客网 时间:2024/04/30 02:04

部分参考:

http://tieba.baidu.com/p/3082739560?pn=1

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.改变光标显示

#Frametoolbar=Frame(self,cursor='hand2')#cursor->光标              

3.禁用button与检测输入

#禁用buutonself.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)

注册管理还可以参考:

http://blog.csdn.net/bnanoou/article/details/38434443

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

http://www.daniweb.com/forums/thread66698.html

5. button 风格

tkinter.button #更多选择tkinter.ttk.button #设置风格button.config(style='Toolbutton')TkUtil.button()<=>tkinter.ttk.button

6.几个常见弹窗

from  tkinter.filedialog import Open,SaveAs,Directoryfilename=Open(title='open').show()filename=SaveAs().show()filename=Directory().show()from subprocess import callcall(filename)
0 0
原创粉丝点击