wx.ArtProvider

Inheritance diagram for wx.ArtProvider:



Description

wx.ArtProvider class is used to customize the look of wxPython application. When wxPython needs to display an icon or a bitmap (e.g. in the standard file dialog), it does not use a hard-coded resource but asks wx.ArtProvider for it instead. This way users can plug in their own wx.ArtProvider class and easily replace standard art with their own version. All that is needed is to derive a class from wx.ArtProvider, override its CreateBitmap method and register the provider with Push.

There’s another way of taking advantage of this class: you can use it in your code and use platform native icons as provided by GetBitmap or GetIcon

Identifying Art Resources

Every bitmap is known to wx.ArtProvider under an unique ID that is used by when requesting a resource from it. The ID is represented by wx.ArtID type and can have one of these predefined values:

  • wx.ART_ADD_BOOKMARK
  • wx.ART_DEL_BOOKMARK
  • wx.ART_HELP_SIDE_PANEL
  • wx.ART_HELP_SETTINGS
  • wx.ART_HELP_BOOK
  • wx.ART_HELP_FOLDER
  • wx.ART_HELP_PAGE
  • wx.ART_GO_BACK
  • wx.ART_GO_FORWARD
  • wx.ART_GO_UP
  • wx.ART_GO_DOWN
  • wx.ART_GO_TO_PARENT
  • wx.ART_GO_HOME
  • wx.ART_FILE_OPEN
  • wx.ART_PRINT
  • wx.ART_HELP
  • wx.ART_TIP
  • wx.ART_REPORT_VIEW
  • wx.ART_LIST_VIEW
  • wx.ART_NEW_DIR
  • wx.ART_FOLDER
  • wx.ART_GO_DIR_UP
  • wx.ART_EXECUTABLE_FILE
  • wx.ART_NORMAL_FILE
  • wx.ART_TICK_MARK
  • wx.ART_CROSS_MARK
  • wx.ART_ERROR
  • wx.ART_QUESTION
  • wx.ART_WARNING
  • wx.ART_INFORMATION
  • wx.ART_MISSING_IMAGE

Additionally, any string recognized by custom art providers registered using Push may be used.

Derived From

Class API

Methods

__init__()

wx.ArtProvider class is used to customize the look of wxPython application. When wxPython needs to display an icon or a bitmap (e.g. in the standard file dialog), it does not use a hard-coded resource but asks wx.ArtProvider for it instead. This way users can plug in their own wx.ArtProvider class and easily replace standard art with their own version. All that is needed is to derive a class from wx.ArtProvider, override its CreateBitmap method and register the provider with Push

class MyArtProvider(wx.ArtProvider):

    def __init__(self):
        wx.ArtProvider.__init__(self)

    def CreateBitmap(self, artid, client, size):

        # Create your bitmap here...
        return bmp

Returns:

wx.ArtProvider


Delete(provider)

Delete the given provider.

Parameters:


Returns:

bool


GetBitmap(id, client=wx.ART_OTHER, size=wx.DefaultSize)

Query registered providers for bitmap with given ID.

Parameters:

  • id (int): wx.ArtID unique identifier of the bitmap.
  • client (int): wx.ArtClient identifier of the client (i.e. who is asking for the bitmap).
  • size (wx.Size): Size of the returned bitmap or wx.DefaultSize if size doesn’t matter.

Returns:

wx.Bitmap


GetIcon(id, client=wx.ART_OTHER, size=wx.DefaultSize)

Query the providers for icon with given id and return it. Return wx.NullIcon if no provider provides it.

Parameters:

  • id (int)
  • client (int)
  • size (wx.Size)

Returns:

wx.Icon


GetSizeHint(client, platform_dependent=False)

Get the size hint of an icon from a specific Art Client, queries the topmost provider if platform_dependent is False

Parameters:

  • client (string)
  • platform_dependent (bool)

Returns:

wx.Size


Insert(provider)

Register new art provider and add it to the bottom of providers stack (i.e. it will be queried as the last one).

Parameters:


See also

Push


InsertProvider(provider)

Add new provider to the bottom of providers stack.

Parameters:


Pop()

Remove latest added provider and delete it.


Returns:

bool


PopProvider()

Remove latest added provider and delete it.


Returns:

bool


Push(provider)

Register new art provider and add it to the top of providers stack (i.e. it will be queried as the first provider).

Parameters:

See also

Insert


PushProvider(provider)

Add new provider to the top of providers stack.

Parameters:


RemoveProvider(provider)

Remove provider. The provider must have been added previously! The provider is not deleted.

Parameters:


Returns:

bool