当前位置:网站首页>七夕表白攻略:教你用自己的专业说情话,成功率100%,我只能帮你们到这里了啊~(程序员系列)
七夕表白攻略:教你用自己的专业说情话,成功率100%,我只能帮你们到这里了啊~(程序员系列)
2022-07-01 15:35:00 【顾木子吖】
导语
哈喽!大家好~我是木木子啦!自从写了一些表白类型的一些小脚本、小程序之后,越发不可收
拾了,哈哈哈。
常常会有小粉丝说:这......小程序不够啊!刚表白去了,但是被拉黑了。
那我不答应了,我得努努力:多多益善给大家开发一些更有趣的各种各样的适合表白的小程序!
让每个人都争取七夕之前带着女朋友回家哈~嘿嘿嘿
今天,木木子推荐一个定制表白恋爱的项目:恋爱对话小程序
这个简单的项目,居然还蛮有趣的——如何操作?快来了解下。
正文
一、小简介
turtle:绘图模块
PySimpleGUI:弹框制作模块(一个非常简单好用的Python图形界面库(PysimpleGUI))
1)环境安装
本文所用到的环境:Python3、Pycharm、PySimpleGUI、Turtle、time模块。
环境安装:pip install +模块名 或带豆瓣镜像源pip install -i
https://pypi.douban.com/simple/ +模块名
陌上花开——可缓缓归矣!
二、代码演示
1)
导入模块
from turtle import *
import time
import PySimpleGUI as sg
2)倒计时
def draw_count_down(i): #倒数
bgcolor('black')
speed(0)
up()
goto(-50,-100)
color('white')
write(i, align="center",font=('Times New Roman', 200, 'bold'))
time.sleep(1)
3)
画2份不同的礼物
def draw_people(): #画小人
up()
fillcolor()
begin_fill()
color('black','white')
goto(-300, 50) # 脖子坐标
down()
circle(75) # 半径为75的脑袋
end_fill()
right(90)
forward(175) # 身体的长度175像素
right(45)
forward(100) # 腿长100像素
up()
goto(-300, -120) # 画另一条腿
down()
left(90)
forward(100)
up()
goto(-300, -5) # 手臂坐标
down()
left(45)
forward(100) # 第一只手臂长度
left(45)
forward(67) # 手掌长度
up()
goto(-300, -40) # 第二只手臂坐标
down()
right(45)
forward(100) # 第二只手臂长度
right(45)
forward(67)
up()
goto(-330, 155) # 第一只眼睛起始坐标
down()
right(45)
forward(50) # 眼睛长度为50
up()
goto(-270, 155) # 第二只眼睛起始坐标
down()
forward(50)
up()
pencolor('#F39F79')
goto(-340,100) #红脸蛋第一只眼
seth(0)
down()
backward(40)
up()
goto(-260, 100) # 红脸蛋第二只眼
down()
forward(40)
time.sleep(1)
def draw_heart(size): # 画爱心
color('red', 'red')
down()
setheading(150)
begin_fill()
forward(size)
circle(size * -3.745, 45)
circle(size * -1.431, 165)
left(120)
circle(size * -1.431, 165)
circle(size * -3.745, 45)
forward(size)
end_fill()
def send_heart(): #发射爱心
up()
goto(-50, -22)
draw_heart(14)
up()
goto(120, -22)
draw_heart(25)
penup()
goto(305, -22)
draw_heart(43)
def wr_character():
up()
goto(-50,-200)
pencolor('black')
write('惊', font=('行楷', 60, 'bold'))
up()
goto(50,-200)
write('不', font=('行楷', 60, 'bold'))
up()
goto(150,-200)
write('惊', font=('行楷', 60, 'bold'))
up()
goto(250,-200)
write('喜', font=('行楷', 60, 'bold'))
def draw_pupu(): #画xxxx
up()
shapesize(10, 2)
speed(2)
fillcolor()
color('#805140','#805140')
begin_fill()
goto(-50, -20)
down()
circle(20)
end_fill()
begin_fill()
up()
goto(-50, -80)
down()
circle(40)
end_fill()
begin_fill()
up()
goto(10, -110)
seth(90)
down()
circle(60,180)
seth(0)
forward(120)
end_fill()
4)二种选择是不同的绘图倒计时之后就是绘制你回答的那个礼物。
def present_good(): #选择是送的礼物
setup(1000,700)
pensize(10)
hideturtle()
numbers=[5,4,3,2,1] #进行倒数
for i in numbers:
draw_count_down(i)
undo()
draw_moon()
draw_people()
send_heart()
wr_character()
done()
def present_bad(): #选择不是送的礼物
setup(1000, 700)
pensize(10)
hideturtle()
numbers=[5,4,3,2,1] #进行倒数
for i in numbers:
draw_count_down(i)
undo()
draw_moon()
draw_people()
draw_pupu()
wr_character()
done()
5)弹窗设计的文字(可修改)
layout=[ #弹框内容设计
[sg.Text('请输入你的名字:')],[sg.Input()],
[sg.Text('请回答下面这个问题哦!')],
[sg.Text('我是你喜欢的类型嘛?')],
[sg.Button('是的是的')],[sg.Button('不是')]
]
sg.popup('你好呀!我是你的好朋友为你定制的专属男朋友','请按OK键继续') #这是一个简易弹框
time.sleep(1)
window=sg.Window('小可爱',layout)
event,value=window.read()
window.close()
if event == '是的是的':
sg.popup(f'{value[0]}请按OK键接收男朋友的礼物!') #这是一个简易弹框 #这里的value[0],是因为value返回内容为字典
time.sleep(1)
present_good()
else:
sg.popup(f'{value[0]}竟然对我有意见,心碎了!!','但你的男友是个大度的人,送你一个小礼物吧','请按OK键接收我心碎的礼物!')
present_bad()
三、效果展示
1)视频展示——
可能视频的话我录制的比较粗糙,感觉有点儿看不清楚!
Turtle系列: 恋爱对话小程序之我是你喜欢的类型嘛?
2)截图展示——
2.1 弹窗界面:
2.2 倒计时5秒
2.3这里选择的是“是的是的”的礼物——选择“不是”的礼物我就不截图了,你们自己拿源码试
试 哈哈哈保留悬链。选择不是的话超惊喜滴
总结
于茫茫人海相遇——感谢你的阅读!相遇即是缘分,如有帮助到你,记得三连哦~
我是木木子,一个不止能编程的女码农,还能教你玩游戏、制作节日惊喜、甚至撩小姐姐、小哥哥的表白小程序哦......
写在最后——往期也有很多精彩内容,欢迎阅读!关注我,每日更新
完整的免费源码领取处:文末公众hao领取哦!
你们的支持是我最大的动力!!记得三连哦~mua 欢迎阅读往期更多文章哦!
推荐往期文章——
项目1.0 中国象棋游戏
Pygame实战:中国象棋人机对抗赛今开战、谁占上风?要不要来一盘试试?
项目1.1 古诗词鉴赏小程序
【Python古诗词鉴赏小程序】千古绝唱,精选中国最美古诗句,经典咏流传~
目 2.1 樱花将灿,冬尽风暖
漫天樱花表白小程序:“樱花将灿,冬尽风暖“一樱花和你我都想念~(内含多份源码)
项目 2.2 源码合集(表白)
Turtle系列:小人发射爱心、文字表白、一箭穿心你想要的都在这个小程序哦~(超值)
文章汇总——
项目1.0 Python—2021 |已有文章汇总 | 持续更新,直接看这篇就够了
(更多内容+源码都在文章汇总哦!!欢迎阅读~)
边栏推荐
- 说明 | 华为云云商店「商品推荐榜」
- MySQL审计插件介绍
- Junda technology indoor air environment monitoring terminal PM2.5, temperature and humidity TVOC and other multi parameter monitoring
- [target tracking] |stark
- 【一天学awk】条件与循环
- Zhang Chi Consulting: household appliance enterprises use Six Sigma projects to reduce customers' unreasonable return cases
- Qt+pcl Chapter 6 point cloud registration ICP Series 5
- Qt+pcl Chapter 6 point cloud registration ICP series 4
- Implementation of wechat web page subscription message
- MySQL service is starting. MySQL service cannot be started. Solution
猜你喜欢
C#/VB.NET 合并PDF文档
MySQL审计插件介绍
Basic use process of cmake
Tiantou village, Guankou Town, Xiamen special agricultural products Tiantou Village special agricultural products ant new village 7.1 answer
MySQL backup and restore single database and single table
张驰课堂:六西格玛数据的几种类型与区别
《QT+PCL第六章》点云配准icp系列6
【一天学awk】函数与自定义函数
Photoshop plug-in HDR (II) - script development PS plug-in
华为发布HCSP-Solution-5G Security人才认证,助力5G安全人才生态建设
随机推荐
Connect the ABAP on premises system to the central inspection system for custom code migration
Logical analysis of automatic decision of SAP CRM organization model
6.2 normalization 6.2.6 BC normal form (BCNF) 6.2.9 normalization summary
Summary of week 22-06-26
Using swiper to make mobile phone rotation map
Pnas: brain and behavior changes of social anxiety patients with empathic embarrassment
《QT+PCL第六章》点云配准icp系列2
[STM32 learning] w25qxx automatic judgment capacity detection based on STM32 USB storage device
Don't ask me again why MySQL hasn't left the index? For these reasons, I'll tell you all
Tableapi & SQL and Kafka message acquisition of Flink example
S32K1xx 微控制器的硬件设计指南
Rhcsa fourth day operation
【天线】【3】CST一些快捷键
《QT+PCL第六章》点云配准icp系列3
【目标跟踪】|模板更新 时间上下文信息(UpdateNet)《Learning the Model Update for Siamese Trackers》
Fix the failure of idea global search shortcut (ctrl+shift+f)
【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(三)
Qt+pcl Chapter 6 point cloud registration ICP series 3
MySQL高级篇4
Qt+pcl Chapter 6 point cloud registration ICP series 4