Python Forum
Python is unable to read file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python is unable to read file
#4
As the code stands now, it will not run.
Images will need to use win.blit to get the background image to show.
I do not see where you called the main function either.

Here is a basic example
import pygame
import os 

# Set a path to current directory of executing script
path = os.path.realpath(os.path.dirname(__file__))

# Pulling image from current directory
# This could be some other path
bg_image = pygame.image.load(f'{path}/my_img.png')

# Set the screen
screen = pygame.display.set_mode((800,600))

running = True

while running:
    # Blit the image to the screen surface
    screen.blit(bg_image, (0,0))

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    # Update the display
    pygame.display.update()
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
Download my project scripts


Reply


Messages In This Thread
Python is unable to read file - by Genericgamemaker - Jul-18-2024, 08:06 PM
RE: Python is unable to read file - by deanhystad - Jul-18-2024, 08:41 PM
RE: Python is unable to read file - by menator01 - Jul-19-2024, 04:28 AM
RE: Python is unable to read file - by deanhystad - Jul-19-2024, 02:16 PM
RE: Python is unable to read file - by snippsat - Jul-19-2024, 04:01 PM
RE: Python is unable to read file - by snippsat - Jul-19-2024, 05:20 PM
RE: Python is unable to read file - by deanhystad - Jul-19-2024, 05:20 PM
RE: Python is unable to read file - by deanhystad - Jul-19-2024, 05:35 PM
RE: Python is unable to read file - by snippsat - Jul-19-2024, 06:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to read a file as binary or hex "string" so that I can do regex search? tatahuft 3 1,003 Dec-19-2024, 11:57 AM
Last Post: snippsat
  Read TXT file in Pandas and save to Parquet zinho 2 1,206 Sep-15-2024, 06:14 PM
Last Post: zinho
  Pycharm can't read file Genericgamemaker 5 1,542 Jul-24-2024, 08:10 PM
Last Post: deanhystad
  Connecting to Remote Server to read contents of a file ChaitanyaSharma 1 3,215 May-03-2024, 07:23 AM
Last Post: Pedroski55
  Recommended way to read/create PDF file? Winfried 3 4,607 Nov-26-2023, 07:51 AM
Last Post: Pedroski55
  python Read each xlsx file and write it into csv with pipe delimiter mg24 4 3,749 Nov-09-2023, 10:56 AM
Last Post: mg24
  read file txt on my pc to telegram bot api Tupa 0 2,545 Jul-06-2023, 01:52 AM
Last Post: Tupa
  parse/read from file seperated by dots giovanne 5 2,231 Jun-26-2023, 12:26 PM
Last Post: DeaD_EyE
  Formatting a date time string read from a csv file DosAtPython 5 4,881 Jun-19-2023, 02:12 PM
Last Post: DosAtPython
  How do I read and write a binary file in Python? blackears 6 24,371 Jun-06-2023, 06:37 PM
Last Post: rajeshgk

Forum Jump:

User Panel Messages

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