how to render TAB in pygame - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Game Development (https://python-forum.io/forum-11.html) +--- Thread: how to render TAB in pygame (/thread-29459.html) |
how to render TAB in pygame - lightframe109 - Sep-03-2020 Hi, I'm using pygame to build a screen, which has some system information on it. The text I am printing on screen contains a TAB (\t). When I run my code the screen is rendered and the text is shown, but the TAB is renderen as a question mark. I don't know what to do to render this TAB (\t) correctly in pygame. See my code below. import os import pygame import platform import sys import distro from netifaces import interfaces, ifaddresses, AF_INET def bootsplash(): for ifaceName in interfaces(): if(ifaceName != "lo"): addresses = [i['addr'] for i in ifaddresses(ifaceName).setdefault(AF_INET, [{'addr':'No IP addr'}] )] stripaddress = addresses kernel = platform.uname().release python = sys.version.split('\n')[0] system = platform.system() os = distro.linux_distribution()[0] osstrings = f"Python versie:\t {python} \r\nKernel versie:\t {kernel} \r\nSystem:\t\t {system} \r\nOperating System: {os} \r\nIP address:\t {stripaddress}" print("Python versie:\t",python,"\r\nKernel versie:\t",kernel,"\r\nSystem:\t\t",system,"\r\nOperating System:",os,"\r\nIP address:\t",stripaddress) return osstrings RUNNING = True while RUNNING: try: splashtext = bootsplash().split('\r\n') #print (os) pygame.init() pygame.mouse.set_visible(False) font = pygame.font.SysFont("monospace", 32) displayinfo = pygame.display.Info() screen = pygame.display.set_mode((displayinfo.current_w, displayinfo.current_h)) pygame.display.set_caption('Bootsplash') regeltext1 = font.render(splashtext[0],True,(0,0,0)) regeltext2 = font.render(splashtext[1],True,(0,0,0)) regeltext3 = font.render(splashtext[2],True,(0,0,0)) regeltext4 = font.render(splashtext[3],True,(0,0,0)) regeltext5 = font.render(splashtext[4],True,(0,0,0)) screen.fill((255,255,255)) screen.blit(regeltext1,(100, 100)) screen.blit(regeltext2,(100, 125)) screen.blit(regeltext3,(100, 150)) screen.blit(regeltext4,(100, 175)) screen.blit(regeltext5,(100, 200)) pygame.display.update() # for event in pygame.event.get(): # if event.type == pygame.QUIT(): # RUNNING = False except KeyboardInterrupt: pygame.QUIT() sys.exit() pygame.QUIT() sys.exit()I hope somebody can help me figuring this out. Kind regards, Lightframe109 RE: how to render TAB in pygame - metulburr - Sep-03-2020 In GUI you cant just put a /t and expect it to print out a tab like it does in the console/terminal. You have to literally push it over some number of pixels to the right.... in the same manner that you pushed each line down on the X axis in increments of 25 pixels to simulate newlines. |