猫史档案馆


【Python作品分享】【36强进10】

用户:SunSetSunSet查看:0 回复:0 评论:0 创建时间:2021-05-23T16:31:20


【作品展示】

center_image

 

【作品介绍】

用tkinter做的明信片。

素材在百度云盘上

链接:https://pan.喵/s/1nKmUQAVgyZJJ5WnqEHiucA

提取码:1234

 

【作品源代码】

# 素材 链接:https://pan.喵/s/1nKmUQAVgyZJJ5WnqEHiucA  提取码:1234
from tkinter import *
import sys
import math
import time
import random
from PIL import Image
from PIL import ImageTk
import os

root = Tk()
root.title('明信片')
root.geometry('1000x620+100+100')
root.resizable(1,1)
FPS = 60



current = 0
path = '..\\素材包\\'
img_list = os.listdir(path)
img = Image.open(path+img_list[current])
pic = ImageTk.PhotoImage(img)


a = ['1970年4月24日,中国第1颗人造地球卫',
     '星东方红1号发射成功,拉开了中国人探索宇宙',
     '奥秘、和平利用太空、造福人类的序幕。经过',
     '几代航天人的不懈努力,2003年10月15日,    ',
     '航天员杨利伟乘”神舟五号”飞船首次进入太 ',
     '空,实现了中华民族的千年飞天梦,此后,手',
     '持红旗漫步太空的翟志刚,巾帼不让须眉的刘',
     '洋,三次出征太空的景海鹏,让太空中有了越',
     '来越多的中国身影,面对星辰大海,中国人永',
     '不停步。--《人民日报》                   ']

bea = ['祝中国航天事业更创辉煌!', 
        '祝中国的航天事业取得更惊人的成就!']


text = ['']
xiangshu = 0
chongshu = 0


def headline():
    for x in range(len(a)):
        label_title = Label(root, text=a[x], font=('楷体', 32))
        label_title.grid(row=x, column=0)


def quit():
    Button(root, text='退出', font=('黑体', 25), command=root.quit).place(x=900, y=560)


def postcarts():
    delete()
    picture()
    butt()
    quit()
    text()
    index()


def butt():
    Button(root, text='生成明信片', font=('黑体', 25), command=postcarts).place(x=400, y=560)


def delete():
    xiangshu = 0
    label_title = Label(root, text='                                                                             ', font=('楷体', 20))
    label_title.place(x=0, y=0)
    for a in range(1, 50):
        label_title = Label(root, text='                                                                             ', font=('楷体', 20))
        label_title.place(x=0,y=a*30)


def picture():
    if xiangshu == 0:
        label_img = Label(root, image=pic)
        label_img.grid(row=0, column=0,rowspan = 12)

        new_img = Image.open(path+img_list[current])
        new_pic = ImageTk.PhotoImage(new_img)
        label_img.configure(image=new_pic)
        label_img.image = new_pic
        
    if xiangshu == 1:
        label_img = Label(root, image=pic)
        label_img.grid(row=0, column=0, rowspan=12)

        new_img = Image.open(path+img_list[current+1])
        new_pic = ImageTk.PhotoImage(new_img)
        label_img.configure(image=new_pic)
        label_img.image = new_pic


def text():
    label_title = Label(root, text=random.choice(bea), font=('楷体', 20))
    label_title.place(x=530,y=320)
    label_title = Label(root, text='董子芾', font=('楷体', 20))
    label_title.place(x=760, y=395)


def index_deo():
    delete()
    headline()
    butt()
    quit()


def index():
    Button(root, text='首页', font=('黑体', 25),command=index_deo).place(x=0, y=560)


butt()
quit()
headline()


root.mainloop()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页