当前位置:网站首页>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 ~)
边栏推荐
- The solution to turn the newly created XML file into a common file in idea
- [cloud trend] new wind direction in June! Cloud store hot list announced
- 【目标跟踪】|模板更新 时间上下文信息(UpdateNet)《Learning the Model Update for Siamese Trackers》
- 6.2 normalization 6.2.6 BC normal form (BCNF) 6.2.9 normalization summary
- 如何写出好代码 - 防御式编程指南
- Implementation of deploying redis sentry in k8s
- 《QT+PCL第六章》点云配准icp系列5
- Pnas: brain and behavior changes of social anxiety patients with empathic embarrassment
- 雷神科技冲刺北交所,拟募集资金5.4亿元
- Zhang Chi Consulting: lead lithium battery into six sigma consulting to reduce battery capacity attenuation
猜你喜欢
厦门灌口镇田头村特色农产品 甜头村特色农产品蚂蚁新村7.1答案
Stm32f411 SPI2 output error, pb15 has no pulse debugging record [finally, pb15 and pb14 were found to be short circuited]
点云重建方法汇总一(PCL-CGAL)
Pico,能否拯救消费级VR?
《性能之巅第2版》阅读笔记(五)--file-system监测
【一天学awk】函数与自定义函数
重回榜首的大众,ID依然乏力
新出生的机器狗,打滚1小时后自己掌握走路,吴恩达开山大弟子最新成果
三星率先投产3nm芯片,上海应届硕士生可直接落户,南开成立芯片科学中心,今日更多大新闻在此...
TensorFlow团队:我们没被抛弃
随机推荐
【一天学awk】函数与自定义函数
Tableapi & SQL and MySQL grouping statistics of Flink
【STM32学习】 基于STM32 USB存储设备的w25qxx自动判断容量检测
[advanced ROS] lesson 5 TF coordinate transformation in ROS
Rhcsa fourth day operation
使用swiper制作手机端轮播图
[300 + selected interview questions from big companies continued to share] big data operation and maintenance sharp knife interview question column (III)
ThinkPHP advanced
ABAP-屏幕切换时,刷新上一个屏幕
Implementation of wechat web page subscription message
Beilianzhuguan joined the dragon lizard community to jointly promote carbon neutralization
Tiantou village, Guankou Town, Xiamen special agricultural products Tiantou Village special agricultural products ant new village 7.1 answer
[antenna] [3] some shortcut keys of CST
TensorFlow团队:我们没被抛弃
TS reports an error don't use 'object' as a type The `object` type is currently hard to use
《QT+PCL第六章》点云配准icp系列5
Recommendation of data acquisition tools and detailed graphic process of data acquisition list
《性能之巅第2版》阅读笔记(五)--file-system监测
Phpcms background upload picture button cannot be clicked
Introduction to MySQL audit plug-in