Python 显示带有字体的文本 &颜色? [英] Python display text with font & color?
本文介绍了Python 显示带有字体的文本 &颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法使用 python 在 pygame 窗口上显示文本?
Is there a way I can display text on a pygame window using python?
我需要显示一堆实时更新的信息,而不是为我需要的每个角色制作图像.
I need to display a bunch of live information that updates and would rather not make an image for each character I need.
我可以将文本 blit 到屏幕上吗?
Can I blit text to the screen?
推荐答案
是的.可以在pygame中绘制文本:
Yes. It is possible to draw text in pygame:
# initialize font; must be called after 'pygame.init()' to avoid 'Font not Initialized' error
myfont = pygame.font.SysFont("monospace", 15)
# render text
label = myfont.render("Some text!", 1, (255,255,0))
screen.blit(label, (100, 100))
这篇关于Python 显示带有字体的文本 &颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文