Day15作业

2018-11-23  本文已影响0人  312d026ea2dd
from color import Color
import pygame


pygame.init()
window = pygame.display.set_mode((400,400))

# 将窗口颜色改成指定颜色
window.fill((Color.yellow))
# 自定义字体
font = pygame.font.Font('files/aa.ttf', 40)
text = font.render('学生管理系统', True,Color.black)
# 将文字渲染到窗口上

# 设置矩形显示位置,矩形里面显示文字
pygame.draw.rect(window,Color.red, (100,180,180,30), 2)
font = pygame.font.Font('files/aa.ttf', 20)
text1 = font.render('账号:', True,  Color.black)
pygame.draw.rect(window,Color.red, (100,240,180,30), 2)
font = pygame.font.Font('files/aa.ttf', 20)
text2 = font.render('密码:', True,  Color.black)
pygame.draw.rect(window,Color.red, (100,300,180,30), 0)
font = pygame.font.Font('files/aa.ttf', 20)
text3 = font.render('登录', True, Color.black)


window.blit(text, (50, 50))
window.blit(text1, (100, 180))
window.blit(text2, (100, 240))
window.blit(text3, (100, 300))
pygame.display.flip()

# window.fill(Color.white)
# font5 = pygame.font.Font('aa.ttf', 50)
# text5 = font.render('学生管理页面', True, Color.red)
# window.blit(text5, (100, 300))
# pygame.display.flip()

while True:


    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            exit()
        elif event.type ==pygame.MOUSEBUTTONDOWN:
            print("鼠标按下",event.pos)
            x, y = event.pos
            if 200 <= x <= 400 and 100 <= y <= 480:
                window.fill(Color.white)
                font = pygame.font.Font('files/aa.ttf', 20)
                text4 = font.render('学生管理页面欢迎您!', True, Color.red)
                window.blit(text4, (100, 100))
                pygame.display.flip()

上一篇下一篇

猜你喜欢

热点阅读