diff --git "a/\345\245\275\347\216\251\344\275\206\346\262\241\344\273\200\344\271\210\347\224\250\344\273\243\347\240\201/\345\274\271\350\267\263\347\252\227\345\217\243.py" "b/\345\245\275\347\216\251\344\275\206\346\262\241\344\273\200\344\271\210\347\224\250\344\273\243\347\240\201/\345\274\271\350\267\263\347\252\227\345\217\243.py" new file mode 100644 index 0000000000000000000000000000000000000000..0c853077b5d64f9e983f07c7368f8859e1a7aa7d --- /dev/null +++ "b/\345\245\275\347\216\251\344\275\206\346\262\241\344\273\200\344\271\210\347\224\250\344\273\243\347\240\201/\345\274\271\350\267\263\347\252\227\345\217\243.py" @@ -0,0 +1,39 @@ +import tkinter as tk +import random as r + +root = tk.Tk() +screen_width = root.winfo_screenwidth() +screen_height = root.winfo_screenheight() +window_width = 400 +window_height = 300 + +x = (screen_width - window_width) // 2 +y = (screen_height - window_height) // 2 +root.geometry(f'{window_width}x{window_height}+{x}+{y}') +sw, sh = window_width, window_height +max1, max2 = sw - 20, sh - 70 +dxx, dyy = x, y +dx,dy = r.randint(3,8),r.randint(3,8) #弹跳速度 +tosn = "1+1=2" #输出文字 +nts = 100 #停留回合 +tos = "".join([i*nts for i in tosn]) +tosn = len(tosn)*nts +n = -1 + +def mov(): + global dxx, dyy, dx, dy, tos, n, tosn + if n==tosn-1: n=-1 + n +=1 + dxx += dx + dyy += dy + if dxx < 0 or dxx > screen_width - window_width: + dx = -dx + if dyy < 0 or dyy > screen_height - window_height: + dy = -dy + label = tk.Label(root, text=tos[n], font=("Arial", 24)) + label.place(relx=0.5, rely=0.5, anchor=tk.CENTER) + root.geometry(f"{50}x{80}+{dxx}+{dyy}") + root.after(5, mov) + +mov() +root.mainloop()