Pyinstaller Packaging program with pictures

Source: Internet
Author: User

First of all, this packaging method can only be used on this computer to operate normal

Preparation:. py File: Your program

GIF file: The picture you want to use

The first step:

Open cmd in the directory where the file is located

 输入  pyi-makespec FP.py  Will generate a Fp.spec  He's a guide to the Pyinstaller package.

FP is my own name, you have to follow your. py file name.

Step Two:

The above variable is actually the path of your image.

Use Picture:

Photo = Tk. Photoimage (file= './socket_one.gif ') This is the way I use pictures when I normally write code without packaging

When I'm going to use this method,

Photo = Tk. Photoimage (File=p_pic) that's the picture.

Step three: Start changing the spec file

Open the file to add code in the red box, save

datas+=[(' _pic.png ', ' d:\\xiutudog\\_pic.png ', ' DATA ')],

datas+=(' _pic.png ', ' d:\\xiutudog\\_pic.png ', ' DATA ')

The above two formats can be tested separately, there is a not error should be.

The red box is the three picture I need, the format is (' Name 1 ', ' 1 ' full path ', ' type '), (' Name 2 ', ' 2 ' full path ', ' type ')

Next, as I described in my previous article, it's okay to pack.

This method is the program specific to the image file path, so no matter where you put the program, you can find the picture where, and normal use.

But no other computer can be found, that is, cannot run

Pyinstaller Packager with pictures

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.