当前位置:网站首页>Tanabata confession introduction: teach you to use your own profession to say love words, the success rate is 100%, I can only help you here ~ (programmer Series)
Tanabata confession introduction: teach you to use your own profession to say love words, the success rate is 100%, I can only help you here ~ (programmer Series)
2022-07-01 15:39:00 【Gu Muzi acridine】
Introduction
hello ! Hello everyone ~ I'm kimiko ! Since I wrote some small scripts of confession type 、 After the applet , More and more unacceptable
Yes , Ha ha ha .
Little fans often say : this ...... Not enough applets ! Just confessed to go , But it was black .
Then I won't promise , I have to work hard : The more, the better. Let's develop some more interesting and various small programs suitable for confession !
Let everyone strive to bring their girlfriend home before Tanabata ~ Hey, hey, hey
today , Mumuzi recommends a customized project to express love : Love dialogue applet
This simple project , It's actually quite interesting —— How to operate ? Come and understand .
Text
One 、 Brief introduction
turtle: Drawing module
PySimpleGUI: Bullet frame making module ( A very simple and easy to use Python Graphical interface library (PysimpleGUI))
1) Environmental installation
The environment used in this article :Python3、Pycharm、PySimpleGUI、Turtle、time modular .
Environmental installation :pip install + Module name Or with watercress mirror source pip install -i
https://pypi.douban.com/simple/ + Module name
On the safety of blooms —— But slowly return !
Two 、 Code demonstration
1)
The import module
from turtle import *
import time
import PySimpleGUI as sg
2) count down
def draw_count_down(i): # Reciprocal
bgcolor('black')
speed(0)
up()
goto(-50,-100)
color('white')
write(i, align="center",font=('Times New Roman', 200, 'bold'))
time.sleep(1)
3)
draw 2 A different gift
def draw_people(): # Draw a villain
up()
fillcolor()
begin_fill()
color('black','white')
goto(-300, 50) # Neck coordinates
down()
circle(75) # The radius is 75 My head
end_fill()
right(90)
forward(175) # The length of the body 175 Pixels
right(45)
forward(100) # Leg length 100 Pixels
up()
goto(-300, -120) # Draw the other leg
down()
left(90)
forward(100)
up()
goto(-300, -5) # Arm coordinates
down()
left(45)
forward(100) # The length of the first arm
left(45)
forward(67) # Palm length
up()
goto(-300, -40) # Coordinates of the second arm
down()
right(45)
forward(100) # The length of the second arm
right(45)
forward(67)
up()
goto(-330, 155) # The starting coordinate of the first eye
down()
right(45)
forward(50) # The length of the eyes is 50
up()
goto(-270, 155) # The starting coordinate of the second eye
down()
forward(50)
up()
pencolor('#F39F79')
goto(-340,100) # Red faced first eye
seth(0)
down()
backward(40)
up()
goto(-260, 100) # Red faced second eye
down()
forward(40)
time.sleep(1)
def draw_heart(size): # Draw love
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(): # Launch love
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(' Surprise ', font=(' Regular script ', 60, 'bold'))
up()
goto(50,-200)
write(' No ', font=(' Regular script ', 60, 'bold'))
up()
goto(150,-200)
write(' Surprise ', font=(' Regular script ', 60, 'bold'))
up()
goto(250,-200)
write(' xi ', font=(' Regular script ', 60, 'bold'))
def draw_pupu(): # draw 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) The two options are different. After the countdown, draw the gift you answered .
def present_good(): # Choice is a gift
setup(1000,700)
pensize(10)
hideturtle()
numbers=[5,4,3,2,1] # Count down
for i in numbers:
draw_count_down(i)
undo()
draw_moon()
draw_people()
send_heart()
wr_character()
done()
def present_bad(): # Choice is not a gift
setup(1000, 700)
pensize(10)
hideturtle()
numbers=[5,4,3,2,1] # Count down
for i in numbers:
draw_count_down(i)
undo()
draw_moon()
draw_people()
draw_pupu()
wr_character()
done()
5) Pop up window design text ( Modifiable )
layout=[ # Bullet box content design
[sg.Text(' Please enter your name :')],[sg.Input()],
[sg.Text(' Please answer the following question !')],
[sg.Text(' I'm your type ?')],
[sg.Button(' Yes it is. ')],[sg.Button(' No ')]
]
sg.popup(' How are you? ! I am your best friend's exclusive boyfriend customized for you ',' Please press OK Key continuation ') # This is a simple bullet box
time.sleep(1)
window=sg.Window(' Cutie ',layout)
event,value=window.read()
window.close()
if event == ' Yes it is. ':
sg.popup(f'{value[0]} Please press OK Key to receive gifts from your boyfriend !') # This is a simple bullet box # there value[0], Because value The returned content is dictionary
time.sleep(1)
present_good()
else:
sg.popup(f'{value[0]} Actually have a problem with me , Broken heart !!',' But your boyfriend is a generous person , Give you a small gift ',' Please press OK Key to receive my heartbroken gift !')
present_bad()
3、 ... and 、 Effect display
1) Video shows ——
Maybe the video I recorded is rough , I feel a little confused !
Turtle series : I'm your favorite type of love dialogue applet ?
2) Screenshot display ——
2.1 Pop up interface :
2.2 count down 5 second
2.3 The choice here is “ Yes it is. ” A gift from —— choice “ No ” I won't take screenshots of your gift , yourselves Try the source code
try Hahaha, keep the catenary . If you choose not, you will be surprised
summary
Meet in the vast sea of people —— Thanks for reading ! Meeting is fate , If it helps you , Remember Sanlian ~
I'm kimiko , A female coder who can not only program , And teach you to play games 、 Make holiday surprises 、 Even flirting with my little sister 、 Little brother's confession applet Oh ......
At the end —— There are also many wonderful contents in previous periods , Welcome to ! Pay attention to me , Daily update
Complete free source code collection office : Public at the end of the article hao Get it !
Your support is my biggest motivation !! Remember Sanlian ~mua Welcome to read more articles in previous issues !
I recommend previous articles ——
project 1.0 Chinese chess game
project 1.1 Ancient poetry appreciation applet
Objective 2.1 Cherry blossoms will shine , The wind is warm in winter
project 2.2 Source code collection ( Confession )
A summary of the article ——
project 1.0 Python—2021 | Summary of existing articles | Continuous updating , Just read this article directly
( More + The source code is summarized in the article !! Welcome to ~)
边栏推荐
- 软件测试的可持续发展,必须要学会敲代码?
- Rhcsa fourth day operation
- Survey of intrusion detection systems:techniques, datasets and challenges
- Qt+pcl Chapter 6 point cloud registration ICP series 3
- 三星率先投产3nm芯片,上海应届硕士生可直接落户,南开成立芯片科学中心,今日更多大新闻在此...
- 厦门灌口镇田头村特色农产品 甜头村特色农产品蚂蚁新村7.1答案
- STM32ADC模拟/数字转换详解
- Flink 系例 之 TableAPI & SQL 与 Kafka 消息获取
- 《QT+PCL第六章》点云配准icp系列4
- 《QT+PCL第六章》点云配准icp系列6
猜你喜欢
【Pygame实战】你说神奇不神奇?吃豆人+切水果结合出一款你没玩过的新游戏!(附源码)
【一天学awk】条件与循环
Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
智能运维实战:银行业务流程及单笔交易追踪
STM32ADC模拟/数字转换详解
The solution to turn the newly created XML file into a common file in idea
k8s部署redis哨兵的实现
STM32F411 SPI2输出错误,PB15无脉冲调试记录【最后发现PB15与PB14短路】
Reading notes of top performance version 2 (V) -- file system monitoring
Go语学习笔记 - gorm使用 - 表增删改查 | Web框架Gin(八)
随机推荐
Qt+pcl Chapter 6 point cloud registration ICP series 4
"Qt+pcl Chapter 6" point cloud registration ICP Series 6
MySQL backup and restore single database and single table
TensorFlow团队:我们没被抛弃
MySQL审计插件介绍
Hardware design guide for s32k1xx microcontroller
Day 3 of rhcsa study
厦门灌口镇田头村特色农产品 甜头村特色农产品蚂蚁新村7.1答案
将ABAP On-Premises系统连接到中央检查系统以进行自定义代码迁移
Tableapi & SQL and MySQL grouping statistics of Flink
An intrusion detection model
入侵检测模型(An Intrusion-Detection Model)
她就是那个「别人家的HR」|ONES 人物
软件测试的可持续发展,必须要学会敲代码?
Junda technology indoor air environment monitoring terminal PM2.5, temperature and humidity TVOC and other multi parameter monitoring
重回榜首的大众,ID依然乏力
ABAP-屏幕切换时,刷新上一个屏幕
远程办公经验?来一场自问自答的介绍吧~ | 社区征文
[one day learning awk] conditions and cycles
Redis秒杀demo