Warning: count(): Parameter must be an array or an object that implements Countable in /www/wwwroot/blog.hsmao.cn/usr/plugins/AMP/Action.php on line 388
笔记

hmao的日记

笔记

第一部分

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









当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »

因本文不是用Markdown格式的编辑器书写的,转换的页面可能不符合AMP标准。