元气_hi 2022-12-17 14:55 采纳率: 80%
浏览 19
已结题

Pygame绘制字体

##PYTHON 3.10.8
我想要用pygame写个字,今天发现写不出来,有人知道吗
问题在第一个循环里,我运行无法看到字..

import pygame as pg
from pygame.locals import *
import sys
import server.getInfo as gi
# 初始化设置
pg.init()
screen = pg.display.set_mode((600, 800)) # 窗口句柄
pg.display.set_caption("APP")
colors = {"white":(255,255,255), "black":(0,0,0)}
done = False
colorH,cadd, xadd = 170, 0.0625, 0.125
X = 201
cfont = pg.font.SysFont("microsoftjhenghei", True, 30)
efont = pg.font.SysFont("consolas", True, 30)
while not done:
    for event in pg.event.get():
        if event.type == QUIT:  # 退出事件
            sys.exit()
    
    screen.fill(colors["white"])
    pg.draw.circle(screen, (colorH, colorH, 255), (X, 250), 10.0)
    screen.blit(cfont.render("请稍等.........", True, colors["black"]), (300, 290))
    
    if colorH == 70 or colorH == 170:
        cadd = -cadd
    if X == 400 or X == 200:
        xadd = -xadd
    colorH += cadd
    X += xadd

    pg.display.update()

# 主循环
while True:
    for event in pg.event.get():
        if event.type == QUIT:  # 退出事件
            sys.exit()
    
    # 初始化
    screen.fill(colors["white"])

    # 绘制背景
    pg.draw.rect(screen, (220, 220, 220), (0, 750, 600, 50), 0)

    # gi.search()
    pg.display.update()


  • 写回答

2条回答 默认 最新

  • 元气_hi 2022-12-17 15:21
    关注

    问题已解决,我也是没看到SysFont多了个True

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 12月25日
  • 已采纳回答 12月17日
  • 创建了问题 12月17日

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度