From 87d584ed46438c53a078027f8c57ac2f8de12dd5 Mon Sep 17 00:00:00 2001 From: 10_2 Date: Wed, 8 Jan 2025 10:06:29 +0800 Subject: [PATCH] =?UTF-8?q?Signed-off-by:=2010=5F2=20=20?= =?UTF-8?q?=E8=BF=99=E6=98=AF=E4=B8=80=E4=B8=AA10=5F2=E7=94=B5=E8=84=91?= =?UTF-8?q?=E7=9A=84=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2025-1-8-1.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 2025-1-8-1.py diff --git a/2025-1-8-1.py b/2025-1-8-1.py new file mode 100644 index 0000000..c3604f9 --- /dev/null +++ b/2025-1-8-1.py @@ -0,0 +1,41 @@ +import tkinter as tk +import random +import threading +import time +from PIL import Image,ImageTk + +class MovingLabel(threading.Thread): + def __init__(self,window,text): + threading.Thread.__init__(self) + self.text=text + self.label=tk.Label(window,image=kuang,text=self.text,compound="center",font=("黑体",20),fg="white",width=190,height=45) + self.label.place(x=800,y=random.randint(10,550)) + + def run(self): + x=800 + while x>-200: + x-=2 + self.label.place(x=x) + time.sleep(0.02) + self.label.destroy() + + +def send(): + text=e1.get() + m1=MovingLabel(window,text) + m1.start() + + +window=tk.Tk() +window.geometry("1000x670") +window.resizable(0,0) +kuang=ImageTk.PhotoImage(file="kuang.png") +bg_image=Image.open("tv.png") +bg_image=ImageTk.PhotoImage(bg_image) +bg_label=tk.Label(window,image=bg_image) +bg_label.pack() +e1=tk.Entry(window,font=("黑体",20)) +e1.place(x=280,y=620) +b1=tk.Button(window,text="发送弹幕",font=("黑体",20),command=send) +b1.place(x=580,y=613) +window.mainloop() \ No newline at end of file