5
我已經盡力在pygame中繪製矩形,但是我需要能夠在該矩形中獲得像「Hello」這樣的文本。我怎樣才能做到這一點? (如果你能解釋它,以及那將是非常讚賞感謝信)如何將文本添加到pygame矩形中
這裏是我的代碼:
import pygame
import sys
from pygame.locals import *
white = (255,255,255)
black = (0,0,0)
class Pane(object):
def __init__(self):
pygame.init()
pygame.display.set_caption('Box Test')
self.screen = pygame.display.set_mode((600,400), 0, 32)
self.screen.fill((white))
pygame.display.update()
def addRect(self):
self.rect = pygame.draw.rect(self.screen, (black), (175, 75, 200, 100), 2)
pygame.display.update()
def addText(self):
#This is where I want to get the text from
if __name__ == '__main__':
Pan3 = Pane()
Pan3.addRect()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit(); sys.exit();
謝謝您的時間。
非常感謝。你是我的救星。 – PythonNovice
你怎樣才能在文本框中包裝?如果你有一個完整的句子,例如.. –
@ChrisNielsen試試這個http://pygame.org/wiki/TextWrap – sloth