第一部分
path路径
event事件
button按钮
import pygame
from sys import exit
import os
def canvasInit():
#pygame初始化
pygame.init()
global canvas
canvas = pygame.display.set_mode((1050, 660), 0, 32)
pygame.display.set_caption('寻找嫌疑人')
#主界面(一级界面)
while True:
canvasInit()
#请在下方书写你的代码
path="images/bg.jpg"
bg=pygame.image.load(path)
canvas.blit(bg,(0,0))
pygame.display.update()
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
#请在下方书写你的代码
if event.type==pygame.MOUSEBUTTONDOWN:
if event.button==1:
print('左键按下')
pos=pygame.mouse.get_pos()
mouseX=pos[0]
mouseY=pos[1]
if 860<=mouseX<=1035 and 480<=mouseY<=650:
pygame.quit()
exit()
#请在下方书写你的代码
pygame.display.update()
第二部分
resizable调整大小
window窗口
Label标签
pack打包
from PIL import ImageTk
import tkinter as tk
letter = 'The beauty has been sleep\nOne moon lies in the sky\nNonody konws where i am\nI really want to fly\nGo to the secret garden\nHide in zhe bush\nTo lie on the lawn\n\nAll stars hug the nature\nMy heart will be peace\nOne for all\n ——My lord'
#请在下方书写你的代码
window=tk.Tk()
window.resizable(0,0)
window.title('嫌疑人信件')
bg=ImageTk.PhotoImage(file="images/bg.png")
letterLab=tk.Label(window,image=bg,
text=letter,
font=('Arial',29),
foreground='white',
compound='center'
)
letterLab.pack()
window.mainloop()
发表回复