tkinter picture importation problema - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: tkinter picture importation problema (/thread-10189.html) |
tkinter picture importation problema - SheeppOSU - May-16-2018 (ITS LINE 16)So I typed this code exactly how it was in the book but it still didn't work. btw I typed the name of the picture plus its file type. from tkinter import * import random import time class Game: def __init__(self): self.tk = Tk() self.tk.title("Mr.Stickman Races for the Exit") self.tk.resizable(0, 0) self.tk.wm_attributes("-topmost", 1) self.canvas = Canvas(self.tk, width=500, height=500, highlightthicknes=0) self.canvas.pack() self.tk.update() self.canvas_height = 500 self.canvas_width = 500 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 def mainloop(self): while 1: if self.running == True: for sprite in self.sprites: sprite.move() self.tk.update_idletasks() self.tk.update() time.sleepp(0.01) g = Game() g.mainloop
RE: tkinter picture importation problema - micseydel - May-16-2018 Try providing the absolute path of the file. |