Reputation: 11
I've been trying out a python application that displays text on the full screen. Couldnt convert it into an exe file to run on windows so tried it online.
The latest is AttributeError: 'NoneType' object has no attribute 'fill'.
There seems no end to attribute errors. It began off with a small compact code but what with attribute error after another whenever I added the suggestions from StackOverflow it's a bit bloated now. Would appreciate some way ahead.
I'm running it on the Colaboratory site (https://colab.research.google.com/#)
It's always come up with numerous blocks that after all the amendments it looks like this.
!apt-get -qq install -y libarchive-dev && pip install -U libarchive
import libarchive
!pip install pygame
import pygame
pygame.init()
pygame.init()
def borders(cells):
width=get_screen_width()
height=get_screen_height()
pygame.display.fullscreen = True
pygame.display
pygame.init()
import time
pygame.font.init()
import platform
if platform.system() == "Windows":
def play_game():
display = pygame.display.set_mode((800,600))
bg_color = (230,230,230)
!pip install pgzero
import pgzero
from pgzero.game import screen
screen: pgzero.screen.Screen
screen.fill(bg_color)
myfont = pygame.font.Font(None, 90)
f = open("/Users/bgr/Desktop/Advice.txt","r")
for line in f:
for word in line.split():
text = myfont.render(word,1,(0,255,0))
screen.blit(text, (300,300))
pygame.display.update()
time.sleep(0.2)
screen.fill((background))
pygame.display.update()
pygame.display.quit() ````
Thanks
Upvotes: 1
Views: 78
Reputation: 78
Your question is a little too broad, so I'm just going to answer a couple
I've been trying out a python application that displays text on the full screen.
pgzero aim to be super simple and hiding a lot of details, it has hooks that pgzero will call if you provides them in the script, to display something on the screen you need to provide draw()
hooks (function).
import pgzrun
import pygame
WIDTH = 800
HEIGHT = 600
green = (0, 128, 0)
white = (255, 255, 255)
def draw():
screen.surface = pygame.display.set_mode((WIDTH, HEIGHT), pygame.FULLSCREEN)
screen.fill(green)
screen.draw.text("Hello world", (100, 100), color=white)
pgzrun.go()
I'm running it on the Colaboratory site (https://colab.research.google.com/#)
I think you should your local pc instead, see this
Upvotes: 1