Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question About Files
#1
I am making a game from the python and i had some problems so I asked someone and they told me to provide the absolute file path for my picture how do that. Just in case: it is a xcf file i named "backround.gif" and here's the code i'm using to create the picture.
self.bg = PhotoImage(file='Background.gif.xcf')
        w = self.bg.width()
        h = self.gb.height()
        for x in range(0, 5):
            for y in range(0, 5):
                self.canvas.create_image_(x * w, y * h, image=self.bg, anchor='nw')
        self.sprites = []
        self.running = True
Reply
#2
import os

# change line 1 to:
self.bg = PhotoImage(file=os.path.abspath('Background.gif.xcf'))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Newbie question about switching between files - Python/Pycharm Busby222 3 629 Oct-15-2023, 03:16 PM
Last Post: deanhystad
  Making a question answering chatbot based on the files I upload into python. Joejones 1 1,249 May-19-2023, 03:09 PM
Last Post: deanhystad
  files creation question, any help plz ? Qubayel 10 7,287 Apr-12-2017, 02:34 PM
Last Post: wavic

Forum Jump:

User Panel Messages

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