ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
why isn't this code moving each text down 10 pixels, i feel like it should be printing text on different lines.
I want each type of text to print 10 pixels lower then that last but its not working!
Code:
#!/usr/bin/python3
import pygame
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((600,600))
print(pygame.font.get_fonts())
pygame.display.set_caption("Let's do some text!");
font = []
text = []
textrect = []
i=0
for fonts in pygame.font.get_fonts():
font.insert(i, pygame.font.SysFont(fonts,50,italic=True,bold=True))
text.insert(i, font[i].render("Hello Everyone",True,(255,255,255)))
textrect.insert(i, text[i].get_rect())
#textrect[i].center=((600/2, 600/2))
i+=1
i=0
pos = [0,0]
for fonts in pygame.font.get_fonts():
textrect[i].move(pos)
pos[1] = pos[1]+10
i+=1
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_q:
pygame.quit()
quit()
screen.fill((131,97,97))
i=0
for fonts in pygame.font.get_fonts():
screen.blit(text[i], textrect[i])
i+=1
pygame.display.update()
Special note this code below i think is what should be moving the text pixels before they are each printed but it doesnt seem to be moving the text at all i cant figure out why.
Code:
for fonts in pygame.font.get_fonts():
textrect[i].move(pos)
pos[1] = pos[1]+10
i+=1
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.