Specifying the Path of Bitmaps

You need to specify a bitmap in some widgets. This can be done in several ways:

Bitmap Path

Specify the path to the bitmap file.

Usually you can type an absolute path in a text box or browse for a bitmap with a file dialog.

Example 6.1. wxBitmap object with the typed string as bitmap path



produces in C++:

wxBitmap("/usr/share/icons/application.png", wxBITMAP_TYPE_ANY)

statement var:

Syntax: var:<variable name>

You can enter a variable name using the var: tag in the text box. In Perl code generation a $ sign is added if you omit it.

Example 6.2. wxBitmap object with the variable name as bitmap path



produces in C++:

wxBitmap(my_bitmap_path, wxBITMAP_TYPE_ANY)

statement empty:

Syntax: empty:<width>,<height>

Creates an empty bitmap of the specified size. It's recommended to use a minimal size of 1, 1.

Example 6.3. Create an empty wxBitmap with width of 32 and height of 32



produces in Python:

wx.EmptyBitmap(32, 32)

produces in C++:

wxBitmap(32, 32)

statement art:

Syntax: art:<ArtID>,<ArtClient> or art:<ArtID>,<ArtClient>,<width>,<height>

Create a bitmap using wxArtProvider.

Example 6.4. Create a bitmap using wxArtProvider



produces in Perl:

Wx::ArtProvider::GetBitmap(wxART_GO_UP, wxART_OTHER, Wx::Size->new(32, 32))

statement code:

Syntax: code:<code chunk to return a wxBitmap>

You can enter a code chunk returning a wxBitmap, by using the code: tag. This inserts verbatim the code you enter in brackets and nothing more.

Example 6.5. wxSomeWidget needs a wxBitmap as an argument


code:if (x == 0) get_bitmap1() else get_bitmap2();

produces in C++:

wxSomeWidget((if (x == 0) get_bitmap1() else get_bitmap2();), option1, option2)

If you use the code: tags like shown above the preview window shows a fixed size empty bitmap instead.


Refer to the section called “Code Properties” for a description of declaration and assignment of additional functions and variables.