hmao的日记

hmao的日记



笔记

hmao · 2022年08月06日 03:14 pm · 0浏览 · 长文


第一部分

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()












thumb_up赞赏文章


comment 评论区

添加新评论





  • ©2025 bilibili.com

textsms
内容不能为空
account_circle
昵称不能为空
email
邮件地址格式错误
web
beach_access
验证码不能为空
keyboard发表评论


star_outline 咱快来抢个沙发吧!