wxPython中的img2py的使用方法简介

王朝other·作者佚名  2008-05-18
窄屏简体版  字體: |||超大  

在查看wxpython自带的demo的源代码的时候总是有一点特别奇怪,它那里有一个文件是images.py,它里有一句是对一个解释是这样的:

This file was generated by C:\PROJECTS\wx\wxPython\demo\encode_bitmaps.py

打开这个encode_bitmaps.py文件一看,发现居然是对wxpython.tools里一个叫img2py的例程的调用。

原来这个img2py是将图像转为以py文件存储的程序哦。终于明白了。

于是退出python的环境,到命令行下运行img2py看看。

果然有一大堆的参数。

下面是帮助的东东哦。

[myphp]

img2py.py -- Convert an image to PNG format and embed it in a Python

module with appropriate code so it can be loaded into

a program at runtime. The benefit is that since it is

Python source code it can be delivered as a .pyc or

'compiled' into the program using freeze, py2exe, etc.

Usage:

img2py.py [options] image_file python_file

Options:

-m <#rrggbb> If the original image has a mask or transparency defined

it will be used by default. You can use this option to

override the default or provide a new mask by specifying

a colour in the image to mark as transparent.

-n <name> Normally generic names (getBitmap, etc.) are used for the

image access functions. If you use this option you can

specify a name that should be used to customize the access

fucntions, (getNameBitmap, etc.)

-c Maintain a catalog of names that can be used to reference

images. Catalog can be accessed via catalog and index attributes

of the module. If the -n <name> option is specified then <name>

is used for the catalog key and index value, otherwise

the filename without any path or extension is used as the key.

-a This flag specifies that the python_file should be appended

to instead of overwritten. This in combination with -n will

allow you to put multiple images in one Python source file.

-u Don't use compression. Leaves the data uncompressed.

-i Also output a function to return the image as a wxIcon.

[/myphp]

呵呵,明白了。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航