import tkinter
import webbrowser
import re
win = tkinter.Tk()
win.title("中文字符检测工具 "+"by qianxiao996"+" -----博客地址:https://blog.csdn.net/qq_36374896 QQ:1919010193-----")
def showInfo():
returntext.delete(0.0, tkinter.END)
str=text.get(0.0, tkinter.END)
list=[',','。',':','¥',';','“','‘']
endstr=""
zhPattern = re.compile(u'[\u4e00-\u9fa5]+')
for i in str:
if i in list:
endstr+=i
elif zhPattern.search(i):
endstr += i
if endstr !='':
returntext.insert(tkinter.INSERT, "中文字符:"+endstr)
else:
returntext.insert(tkinter.INSERT, "恭喜您,文本中没有中文字符")
def clearText():
text.delete(0.0, tkinter.END)
returntext.delete(0.0, tkinter.END)
def click():
webbrowser.open("https://blog.csdn.net/qq_36374896")
scroll = tkinter.Scrollbar()
text = tkinter.Text(win,width =80,height = 50,bg='#F0FFFF',fg="#FF00FF")
scroll.pack(side =tkinter.RIGHT,fill = tkinter.Y)
text.pack(side =tkinter.LEFT,fill = tkinter.Y,)
scroll.config(command =text.yview)
text.config(yscrollcommand =scroll.set)
label = tkinter.Label(win,text= "作者QQ:1919010193",bg='#F0F8FF',fg="green").pack(side="bottom",ipady="8",ipadx="44")
zuozhe=tkinter.Button(win,text= "作者主页",command =click,bg='#F0F8FF',fg="green").pack(side="bottom",ipady="30",ipadx="80")
close = tkinter.Button(win,text= "关闭程序",command =win.quit,bg='#F0F8FF',fg="green").pack(side="bottom",ipady="30",ipadx="80")
clear = tkinter.Button(win,text= "清空文本",command = clearText,bg='#F0F8FF',fg="green").pack(side="bottom",ipady="30",ipadx="80")
button = tkinter.Button(win,text= "检查文本",command = showInfo,bg='#F0F8FF',fg="green").pack(side="bottom",ipady="30",ipadx="80")
returntext = tkinter.Text(win,width = 30,height=30,bg='#F0FFFF',fg="red")
returntext.pack(side="top",ipadx="3")
win.mainloop()