- 论坛徽章:
- 0
|
下面这个程序就是显示一个英文"www.chinaunix.net"字符串
请问该怎样显示中文呢?
bow
- #!/usr/bin/env python
- import os, pygame
- from pygame.locals import *
- #-*- coding: UTF-8 -*-
- def main():
- #Initialize Everything
- pygame.init()
- screen = pygame.display.set_mode((300, 35))
- #Create The Backgound
- background = pygame.Surface(screen.get_size())
- background = background.convert()
- background.fill((250, 250, 250))
- #Put Text On The Background, Centered
- if pygame.font:
- font = pygame.font.Font(None, 36)
- text = font.render("www.chinaunix.net", 1, (10, 10, 10))
- textpos = text.get_rect(centerx=background.get_width()/2)
- background.blit(text, textpos)
- #Display The Background
- screen.blit(background, (0, 0))
- pygame.display.flip()
- #Main Loop
- while 1:
- for event in pygame.event.get():
- if event.type == QUIT:
- return
- #this calls the 'main' function when this script is executed
- if __name__ == '__main__': main()
复制代码 |
|