Python Forum
how to render TAB in pygame
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to render TAB in pygame
#1
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
Reply


Messages In This Thread
how to render TAB in pygame - by lightframe109 - Sep-03-2020, 01:52 PM
RE: how to render TAB in pygame - by metulburr - Sep-03-2020, 09:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [pyGame] Render Text from Variable, examples needed ! JamieVanCadsand 1 5,971 Oct-03-2017, 09:54 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020