0

The part of my code is

frames = [PhotoImage(file='E:\\omoha\\Documents\\assistant.gif',format = 'gif -index %i' %(i)) for i in range(100)]
window.title('Saako')

Sorry for messy question. This is my first time ask question! I want to send this project to my other pc but it wont work because the image is specifically to my directory. How to fix this... Also, it will be nice if there is something like gif url instead of file directory.

  • There are a lot of ways to do this which depend on how you package your program, but for example using `pyinstaller` you can add these types of files as [`datas`](https://pyinstaller.readthedocs.io/en/stable/spec-files.html) that get packaged with your executable. – Cory Kramer Apr 04 '22 at 15:04
  • Why not transfer the image as well? Also, take a look at [this](https://stackoverflow.com/questions/918154/relative-paths-in-python) – Dion Apr 04 '22 at 15:05

2 Answers2

0

You can either use a relative path like assistant.gif (will search in current working directory) and distribute your program with this gif or download it via internet using requests library for example.

CrafterKolyan
  • 1,042
  • 5
  • 13
0

It isn't working because the directory name changes. You need to have a 'dynamic' directory, and also try sending your project files as a zip.

I modified your code so it can work between computers

import os
global file_path
file_path = os.path.dirname(__file__)
frames = [PhotoImage(file=file_path+'\assistant.gif',format = 'gif -index %i' %(i)) for i in range(100)]
window.title('Saako')

you don't need to install anything with pip because os is an included module.

thedankboi
  • 53
  • 1
  • 8