小玩具:1. 生成爱心图案 2.windows 随机弹窗傻狍子 3. windows弹窗显示爱心图案
This commit is contained in:
parent
c8ec1cdfe1
commit
6340bb072e
|
@ -0,0 +1,3 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
|
@ -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>
|
|
@ -0,0 +1,6 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -1,2 +1,3 @@
|
|||
# makefun
|
||||
|
||||
# 生成exe程序
|
||||
1. 安装pyinstaller: pip install pyinstaller
|
||||
2. 生成单个可执行文件:pyinstaller -F 需要生成可执行文件的目标文件
|
|
@ -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()
|
|
@ -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())
|
|
@ -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()
|
Loading…
Reference in New Issue