You can use most image editing programs to produce icon images in one of the supported formats. After you have created the image file, you construct the icon by calling the appropriate method, as shown in the following example: icon = afxCreatePNGIcon('myIcon.png') FXLabel(self, 'A label with an icon', icon) In some cases you may need to call the icon's create method before using it in a widget. In the previous example, it is not necessary to call the icon's create method because the label widget creates the icon when the label is created. However, if you construct an icon after you call the widget's create method, you must call the icon's create method before you use the icon in the widget. For more information, see The create method. The format of an XPM icon is simple; and you can use any pixmap editor, or even a text editor, to create the icon data. More details about the XPM format are available at https://www.x.org/docs/XPM/xpm.pdf. The following image editing programs support the XPM format:
As an alternative to using the afxCreateXPMIcon method, you can define the XPM image data as a Python list of strings and create an icon using the FXXPMIcon method, as shown in the following example. Note: For a list of valid color names and their corresponding RGB values, see Colors and RGB values. To define a transparent color, you must define it as “c None s None”, not just “c None”. blueIconData = [ "12 12 2 1", ". c None s None", " c blue", " ", " ", " ", " ", " .... ", " .... ", " .... ", " .... ", " ", " ", " ", " " ] blueIcon = FXXPMIcon(getAFXApp(),blueIconData) Figure 1 shows the blue square icon created by this example. Figure 1. The blue square icon.
|