python制作个性签名(最后有彩蛋)

用tkinter制作了可视化界面
python制作个性签名(最后有彩蛋)_第1张图片

python制作个性签名(最后有彩蛋)_第2张图片

# -*- coding = utf-8 -*-
# @Time : 2021/1/29 20:09
# @Author :老七疯狂吸氧
# @file Makename.py
# @Software:PyCharm
import requests
import re
import random
import tkinter as tk
window=tk.Tk()              #创建一个窗口
window.title("定制签名")     #window标题
window.geometry('800x500')  #定义window界面大小
name = tk.Label(window,text="请输入您的名字:")
name.place(x=220,y=80)
getname = tk.Entry(window,show="")
getname.place(x=350,y=80)
def ys():
    sel = '艺术'
    n='1.ttf'
    getp(n,sel)
    pname=getp(n,sel)
    newlen(pname)
def lb():
    sel = '连笔'
    n='zql.ttf'
    getp(n,sel)
    pname = getp(n, sel)
    newlen(pname)
def sw():
    sel = '商务'
    n='8.ttf'
    getp(n,sel)
    pname = getp(n, sel)
    newlen(pname)
def ks():
    sel = '楷书'
    n='6.ttf'
    getp(n,sel)
    pname = getp(n, sel)
    newlen(pname)
def xs():
    sel = '潇洒'
    n='bzcs.ttf'
    getp(n,sel)
    pname = getp(n, sel)
    newlen(pname)
def cs():
    sel = '草书'
    n='lfc.ttf'
    getp(n,sel)
    pname = getp(n, sel)
    newlen(pname)
def xshu():
    sel = '行书'
    n='2.ttf'
    getp(n,sel)
    pname = getp(n, sel)
    newlen(pname)
def gx():
    sel = '个性'
    n='3.ttf'
    getp(n,sel)
    pname = getp(n, sel)
    newlen(pname)
def ka():
    sel = '可爱'
    n='yqk.ttf'
    getp(n,sel)
    pname = getp(n, sel)
    newlen(pname)
chance = tk.Label(window,text="请选择您喜欢的风格")
chance.place(x=220,y=110)
f1=tk.Button(window,text='艺术',command=ys)
f1.place(x=220,y=140)
f2=tk.Button(window,text='连笔',command=lb)
f2.place(x=260,y=140)
f3=tk.Button(window,text='商务',command=sw)
f3.place(x=300,y=140)
f4=tk.Button(window,text='楷书',command=ks)
f4.place(x=340,y=140)
f5=tk.Button(window,text='潇洒',command=xs)
f5.place(x=380,y=140)
f6=tk.Button(window,text='草书',command=cs)
f6.place(x=420,y=140)
f7=tk.Button(window,text='行书',command=xshu)
f7.place(x=460,y=140)
f8=tk.Button(window,text='个性',command=gx)
f8.place(x=500,y=140)
f9=tk.Button(window,text='可爱',command=ka)
f9.place(x=540,y=140)

def getp(n,sel):
    name = getname.get()
    url = 'http://m.uustv.com'
    data = {
     
        'word': name,
        'sizes': '60',
        'fonts': n,
        'fontcolor': '#000000'
    }
    res = requests.post(url=url, data=data)
    src = re.findall('
', res.text)[0] endurl = url + '/' + src picture = requests.get(endurl) pname = name + '的' + sel + '签名.jpg' with open(pname, "wb") as f: f.write(picture.content) f.close() return pname # img_open = Image.open(pname) # img_png = ImageTk.PhotoImage(img_open) def newlen(pname): window.destroy() windows = tk.Tk() windows.title("个性签名") # window标题 pictures = tk.PhotoImage(file=pname) show = tk.Label(windows,image=pictures) show.pack() windows.mainloop() window.mainloop()

彩蛋:
将代码封装为exe文件。没有python环境也可以运行。
exe文件

你可能感兴趣的:(爬虫,python,tkinter,python)