hello everyone i am working on a project about puzzle game. I had problem with uploading image to program by using tk.filedialog but i have this error
UnboundLocalError: cannot access local variable 'image' where it is not associated with a value
here is my code:
def select_image(): file_path = tk.filedialog.askopenfilename() if file_path: # Resmi 16 parçaya böl image = image.open(file_path) image = image.resize((400, 400)) image_list = [] for i in range(0, 400, 100): for j in range(0, 400, 100): piece = image.crop((i, j, i+100, j+100)) image_list.append(piece)
image.open()makes no sense - you're only just definingimagein that line of code, you can't use it to define itself! I think that should beImage.open(), referring to a class from the PIL or Pillow library.