Jeremy Darrach
Jeremy Darrach

Reputation: 263

Tkinter: background image problems

I'm working on a game for a competition and it's coming along pretty nicely so far. I made an image I want to use as a background, so I loaded and placed it the same as I did with the player image:

self.bg_1=PhotoImage(file="bg_space.gif")

bg1=self.create_image(0,0,image=self.bg_1)

This is the result: bg error

It only shows a quarter of the whole image. Is the file size too big? Did I code something wrong?

I tried making four images, one for each quarter of the image, and position them in the correct spots on the canvas. This turned out even worse, and I think only showed a quarter of those as well.

I'm pretty puzzled about this, and would appreciate anyone's input on this. thanks

Upvotes: 0

Views: 581

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 385830

By default the image is centered on the coordinate you give it. To change this, set the parameter anchor to "nw" (northwest):

bg1=self.create_image(0,0,image=self.bg_1, anchor="nw")

Upvotes: 1

Related Questions