tkinter--gui工具:MD5
#!/usr/bin/env python # -*- coding: utf-8 -*- import hashlib import tkinter class TkinterMd5: def __init__(self): self.tk = tkinter.Tk() # 实例化object self.tk.title('my md5') self.tk.geometry('800x900+10+10') self.login = tkinter.Text(self.tk) self.login1 = tkinter.Text(self.tk) self.login2 = tkinter.Text(self.tk, width=170) def three_pages(self): # tkinter属性放置时在对应row,column内的对齐方式;sticky属性的参数有n,s,e,w,ne,nw,se,sw可选,默认居中 tkinter.Label(self.tk, text='输入值').grid(row=1, column=0, sticky='sw') tkinter.Label(self.tk, text='结果值').grid(row=1, column=3, sticky='sw') tkinter.Label(self.tk, text='日志').grid(row=3, column=0, sticky='sw') self.login.grid(row=2, column=0) self.login1.grid(row=2, column=3) # columnspan适用于合并列所使用的 self.login2.grid(row=4, column=0, columnspan=100) tkinter.Button(self.tk, text='确定', bg='gray', height=1, width=8, command=self.to_md5).grid(row=2, column=2) tkinter.mainloop() def to_md5(self): text = self.login.get('1.0', tkinter.END).strip().replace("\n", "") if text: print(text, '----------') myMd5 = hashlib.md5() myMd5.update(text.encode(encoding='utf-8')) myMd5_Digest = myMd5.hexdigest() self.login1.delete(1.0, 'end') self.login1.insert(1.0, myMd5_Digest) # self.loggingTest.delete(1.0, 'end') self.login2.insert('insert', text+':成功转换,转换后的值为:---'+myMd5_Digest+'\n') else: # self.loggingTest.delete(1.0, 'end') self.login2.insert(tkinter.END, 'error,请输入有效的值') if __name__ == '__main__': TkinterMd5().three_pages()