小玩具:1. 生成爱心图案 2.windows 随机弹窗傻狍子 3. windows弹窗显示爱心图案

This commit is contained in:
chenyinhua 2022-05-11 10:37:46 +08:00
parent c8ec1cdfe1
commit 6340bb072e
11 changed files with 191 additions and 2 deletions

3
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@ -0,0 +1,27 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="14">
<item index="0" class="java.lang.String" itemvalue="yagmail" />
<item index="1" class="java.lang.String" itemvalue="pytest" />
<item index="2" class="java.lang.String" itemvalue="PyYAML" />
<item index="3" class="java.lang.String" itemvalue="allure_python_commons" />
<item index="4" class="java.lang.String" itemvalue="requests" />
<item index="5" class="java.lang.String" itemvalue="loguru" />
<item index="6" class="java.lang.String" itemvalue="click" />
<item index="7" class="java.lang.String" itemvalue="selenium" />
<item index="8" class="java.lang.String" itemvalue="Faker" />
<item index="9" class="java.lang.String" itemvalue="locustio" />
<item index="10" class="java.lang.String" itemvalue="jsonpath" />
<item index="11" class="java.lang.String" itemvalue="PyMySQL" />
<item index="12" class="java.lang.String" itemvalue="urllib3" />
<item index="13" class="java.lang.String" itemvalue="openpyxl" />
</list>
</value>
</option>
</inspection_tool>
</profile>
</component>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

8
.idea/makefun.iml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

4
.idea/misc.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/makefun.iml" filepath="$PROJECT_DIR$/.idea/makefun.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -1,2 +1,3 @@
# makefun
# 生成exe程序
1. 安装pyinstaller: pip install pyinstaller
2. 生成单个可执行文件pyinstaller -F 需要生成可执行文件的目标文件

60
alertlover.py Normal file
View File

@ -0,0 +1,60 @@
# -*- coding: utf-8 -*-
# @Version: Python 3.9
# @Time : 2022/5/11 10:05
# @Author : chenyinhua
# @File : alertlover.py
# @Software: PyCharm
# @Desc: windows弹窗显示爱心
import time
import random
import threading
import tkinter as tk
import time
def lover():
"""
返回爱心
:return:
"""
target = ""
for char in target.split():
all_char = []
for y in range(12, -12, -1):
lst = []
lst_con = ""
for x in range(-30, 30):
formula = ((x * 0.05) ** 2 + (y * 0.1) ** 2 - 1) ** 3 - (x * 0.05) ** 2 * (y * 0.1) ** 3
if formula <= 0:
lst_con += char[x % len(char)]
else:
lst_con += " "
lst.append(lst_con)
all_char += lst
time.sleep(1)
return "\n".join(all_char)
def boom():
"""
爆炸弹窗
:return:
"""
window = tk.Tk()
window.title("今天是友爱的一天")
# 弹窗位置随机
# width = window.winfo_screenwidth()
# height = window.winfo_screenheight()
# a = random.randrange(0, width)
# b = random.randrange(0, height)
# window.geometry("860x600+10+10" + "+" + str(a) + "+" + str(b))
# 弹窗位置 距离上100 距离左100
window.geometry("860x600+100+100")
tk.Label(window, text=lover(), bg="white", font=("宋体", 17), fg="red", width=150, height=40).pack()
window.mainloop()
if __name__ == '__main__':
boom()

33
lover.py Normal file
View File

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# @Version: Python 3.9
# @Time : 2022/5/11 9:57
# @Author : chenyinhua
# @File : lover.py
# @Software: PyCharm
# @Desc: 使用Python打印爱心图案
import time
def lover():
target = ""
for char in target.split():
all_char = []
for y in range(12, -12, -1):
lst = []
lst_con = ""
for x in range(-30, 30):
formula = ((x * 0.05) ** 2 + (y * 0.1) ** 2 - 1) ** 3 - (x * 0.05) ** 2 * (y * 0.1) ** 3
if formula <= 0:
lst_con += char[x % len(char)]
else:
lst_con += " "
lst.append(lst_con)
all_char += lst
time.sleep(1)
return "\n".join(all_char)
if __name__ == '__main__':
print(lover())

33
randomalert.py Normal file
View File

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# @Version: Python 3.9
# @Time : 2022/4/26 13:35
# @Author : chenyinhua
# @File : randomalert.py
# @Software: PyCharm
# @Desc: windows弹窗傻狍子
import tkinter as tk
import random
import threading
import time
def boom():
window = tk.Tk()
width = window.winfo_screenwidth()
height = window.winfo_screenheight()
a = random.randrange(0, width)
b = random.randrange(0, height)
window.title("你是一个傻狍子")
window.geometry("260x50" + "+" + str(a) + "+" + str(b))
tk.Label(window, text="你是一个傻狍子", bg="green", font=("宋体", 17), width=150, height=40).pack()
window.mainloop()
threads = []
for i in range(100):
t = threading.Thread(target=boom)
threads.append(t)
time.sleep(0.1)
threads[i].start()