鱼C论坛

 找回密码
 立即注册
查看: 2284|回复: 3

[作品展示] 抖音表白小程序

[复制链接]
发表于 2020-5-20 14:39:07 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. from tkinter import *
  2. import tkinter.messagebox
  3. import time
  4. import pygame
  5. import threading
  6. import sys
  7. from pygame.locals import *

  8. def love():
  9.     master = Toplevel()

  10.     master.title("同道中人")
  11.     screenWidth = master.winfo_screenwidth()  
  12.     screenHeight = master.winfo_screenheight()  
  13.     width = 600  
  14.     height = 500
  15.     left = (screenWidth - width) / 2
  16.     top = (screenHeight - height) / 2
  17.     master.geometry("%dx%d+%d+%d" % (width, height, left, top))
  18.     w = Label(master, image=lphoto)
  19.     w.pack()
  20.     Button(master,text='确定',command=master.quit).pack()

  21. def dislove():
  22.     master = Toplevel()

  23.     master.title("让你认清自己!!!")
  24.     screenWidth = master.winfo_screenwidth()  
  25.     screenHeight = master.winfo_screenheight()  
  26.     width = 600
  27.     height = 380
  28.     left = (screenWidth - width) / 2
  29.     top = (screenHeight - height) / 2
  30.     master.geometry("%dx%d+%d+%d" % (width, height, left, top))
  31.     w = Label(master, image=disphoto)
  32.     w.pack()
  33.     Button(master,text='确定',command=master.destroy).pack()

  34. def callbackClose():
  35.     tkinter.messagebox.showwarning(title='警告', message='不许关闭,好好回答!!!')

  36. def biaobai():
  37.     pygame.mixer.init()
  38.     pygame.mixer.music.load("D:\\KuGou\\任然 - 山外小楼夜听雨.mp3")
  39.     pygame.mixer.music.set_volume(0.2)
  40.     pygame.mixer.music.play(-1)
  41.     bg_size = width,height = 200,190
  42.     screen = pygame.display.set_mode(bg_size)
  43.     pygame.display.set_caption('Music')
  44.     clock = pygame.time.Clock()
  45.     root = Tk()

  46.     root.title("居中的窗口")
  47.     screenWidth = root.winfo_screenwidth()  # 获取显示区域的宽度
  48.     screenHeight = root.winfo_screenheight()  # 获取显示区域的高度
  49.     width = 600  # 设定窗口宽度
  50.     height = 400  # 设定窗口高度
  51.     left = (screenWidth - width) / 2
  52.     top = (screenHeight - height) / 2

  53.     # 宽度x高度+x偏移+y偏移
  54.     # 在设定宽度和高度的基础上指定窗口相对于屏幕左上角的偏移位置
  55.     root.geometry("%dx%d+%d+%d" % (width, height, left, top))

  56.     frame1 = Frame(root)
  57.     frame2 = Frame(root)

  58.     textlable = Label(frame1,text='祢豆子真漂亮')
  59.     textlable.pack()

  60.     global lphoto
  61.     global disphoto
  62.     lphoto = PhotoImage(file=r"E:\P.py\课堂练习.py\tkinter\喜欢.png")
  63.     disphoto = PhotoImage(file=r"E:\P.py\课堂练习.py\tkinter\眼瞎.png")
  64.     photo = PhotoImage(file=r"E:\P.py\课堂练习.py\tkinter\1.png")
  65.     w = Label(frame1, image=photo)
  66.     w.pack()

  67.     Button(frame2,text='喜欢',command=love,width=15)\
  68.         .grid(row=0,column=0,sticky=W,padx=50,pady=5)

  69.     Button(frame2,text='不喜欢',command=dislove,width=15)\
  70.         .grid(row=0,column=1,sticky=E,padx=50,pady=5)

  71.     frame1.pack()
  72.     frame2.pack()


  73.     root.protocol("WM_DELETE_WINDOW", callbackClose)

  74.     mainloop()

  75. biaobai()
复制代码

喜欢

喜欢

眼瞎

眼瞎

1

1

评分

参与人数 1荣誉 +5 鱼币 +5 收起 理由
Twilight6 + 5 + 5 无条件支持楼主!

查看全部评分

小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-5-21 08:37:13 | 显示全部楼层
!!!你应该发Python 的作品展示  人才多,不然很少人看得见的~
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-5-21 08:39:36 | 显示全部楼层
晚上给你评分,评分还在CD中哈

而且其实你可以打包成exe文件,就可以不用python都可以运行了 ~
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-5-22 14:20:56 | 显示全部楼层
Twilight6 发表于 2020-5-21 08:39
晚上给你评分,评分还在CD中哈

而且其实你可以打包成exe文件,就可以不用python都可以运行了 ~

用pyinstaller是吧,但是打包成的。exe文件太大了,而且图片什么的路径有点麻烦
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-4-30 02:18

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表