
只要你离开了学校,基本上写字的机会就变得很少了,但是签名的机会却很多,如果写字不好好看的话,但是能签的一手好的名字,也是很不错的选择。
基础环境配置
版本:Python3.6
模块:tkinter、PIL、requests
tkinter是内置模块不需要安装
PIL:pip install pillow
requests:pip install requests
from tkinter import *
from tkinter import messagebox
root = Tk()
root.title('Python学习群:516107834')
root.geometry('600x300')
root.geometry('-500+200')
label = Label(root,text = '签名',font = ('华文行楷',20),fg = 'blue')
label.grid(row =0,column=0)
entry = Entry(root,font=('微软雅黑',20))
entry.grid(row =0,column=1)
button = Button(root,text = '设计签名',font=('微软雅黑',22)
,command =download)
button.grid(row =1,column=0)
root.mainloop()
import requests
import re
def download():
startUrl ='http://www.uustv.com/'
name = entry.get()
name = name.strip()
if name =='':
messagebox.showinfo('提示:','请输入用户名')
else:
date = {
'word':name,
'sizes':'60',
'fonts':'jfcs.ttf',
'fontcolor':'#000000'
}
result = requests.post(startUrl,data=date)
result.encoding = 'utf-8'
html =result.text
reg = '.
![]()
'
imagePath = re.findall(reg,html)
imgUrl = startUrl + imagePath[0]
print(imgUrl)
response = requests.get(imgUrl).content
f = open('{}.gif'.format(name),'wb')
f.write(response)
bm = ImageTk.PhotoImage(file ='{}.gif'.format(name))
label2= Label(root,image = bm)
label2.bm = bm
label2.grid(row = 2,columnspan= 2)
from tkinter import *
from tkinter import messagebox
from PIL import Image,ImageTk
import requests
import re
def download():
startUrl ='http://www.uustv.com/'
name = entry.get()
name = name.strip()
if name =='':
messagebox.showinfo('提示:','请输入用户名')
else:
date = {
'word':name,
'sizes':'60',
'fonts':'jfcs.ttf',
'fontcolor':'#000000'
}
result = requests.post(startUrl,data=date)
result.encoding = 'utf-8'
html =result.text
reg = '.
![]()
'
imagePath = re.findall(reg,html)
imgUrl = startUrl + imagePath[0]
print(imgUrl)
response = requests.get(imgUrl).content
f = open('{}.gif'.format(name),'wb')
f.write(response)
bm = ImageTk.PhotoImage(file ='{}.gif'.format(name))
label2= Label(root,image = bm)
label2.bm = bm
label2.grid(row = 2,columnspan= 2)
root = Tk()
root.title('Python学习群:516107834')
root.geometry('600x300')
root.geometry('-500+200')
label = Label(root,text = '签名',font = ('华文行楷',20),fg = 'blue')
label.grid(row =0,column=0)
entry = Entry(root,font=('微软雅黑',20))
entry.grid(row =0,column=1)
button = Button(root,text = '设计签名',font=('微软雅黑',22)
,command =download)
button.grid(row =1,column=0)
root.mainloop()