I am currently trying to make a pyautogui/pygame code that tracks the mouse location and prints the cords on a pygame window. Here is what I have so far:
import pygame
import pygame.freetype
import pyautogui
import time
pygame.init()
POS = pyautogui.position()
screen = pygame.display.set_mode((800, 600))
GAME_FONT = pygame.freetype.Font("/Users/user/Desktop/Calibri.ttf", 24)
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
screen.fill((255, 255, 255))
while True:
time.sleep(0.4)
GAME_FONT.render_to(screen, (40, 350), POS, (0, 0, 0))
pass
pygame.display.flip()
pygame.quit()
When I run this code I get the error:
TypeError: Expected a Unicode or LATIN1 (bytes) string for text: got type Point
As you can see, the variable POS contains the command; I would like the command output printed on my pygame screen. Is there an alternative or am I just looking at this wrong? I have scoured the internet and asking a question here is usually my last resort so: Any help/criticism is appreciated.