wx_icons_suru

Suru icon theme for wxPython 🐍

This package provides a wxPython wxArtProvider class with icons from the Suru Icon Theme.

Docs

Documentation Status Docs Check Status

Tests

Travis Build Status Windows Tests Status macOS Tests Status CodeFactor Grade

PyPI

PyPI - Package Version PyPI - Supported Python Versions PyPI - Supported Implementations PyPI - Wheel

Activity

GitHub last commit GitHub commits since tagged version Maintenance

Other

License GitHub top language Requirements Status pre-commit

Installation

python3 -m pip install wx_icons_suru --user

Usage

To use wx_icons_suru in your application:

from wx_icons_suru import wxSuruIconTheme

class MyApp(wx.App):
    def OnInit(self):
        wx.ArtProvider.Push(wxSuruIconTheme())
        self.frame = TestFrame(None, wx.ID_ANY)
        self.SetTopWindow(self.frame)
        self.frame.Show()
        return True

And then the icons can be accessed through wx.ArtProvider:

wx.ArtProvider.GetBitmap('document-new', wx.ART_OTHER, wx.Size(48, 48))

Any FreeDesktop Icon Theme Specification name can be used.

Currently the Client ID is not used, so just pass wx.ART_OTHER.

API Reference

class wx_icons_humanity.HumanityDarkIconTheme(name, comment, directories, inherits=None, scaled_directories=None, hidden=False, example='')[source]
classmethod create()[source]

Create an instance of the Humanity Dark Icon Theme

find_icon(icon_name, size, scale, prefer_this_theme=True)[source]
Parameters
  • icon_name

  • size

  • scale

  • prefer_this_theme – Return an icon from this theme even if it has to be resized, rather than a correctly sized icon from the parent theme. Default True.

Returns

Return type

classmethod from_configparser(theme_index_path)

Constructs a IconTheme from config file.

Parameters

theme_index_path (Union[str, PathLike]) –

Return type

IconTheme

inherits: List[str]
scaled_directories: List[wx_icons_hicolor.directory.Directory]
class wx_icons_humanity.HumanityIconTheme(name, comment, directories, inherits=None, scaled_directories=None, hidden=False, example='')[source]
classmethod create()[source]

Create an instance of the Humanity Icon Theme

find_icon(icon_name, size, scale, prefer_this_theme=True)[source]
Parameters
  • icon_name (str) –

  • size (int) –

  • scale (Any) –

  • prefer_this_theme (bool) – Return an icon from this theme even if it has to be resized, rather than a correctly sized icon from the parent theme. Default True.

Returns

Return type

classmethod from_configparser(theme_index_path)

Constructs a IconTheme from config file.

Parameters

theme_index_path (Union[str, PathLike]) –

Return type

IconTheme

inherits: List[str]
scaled_directories: List[wx_icons_hicolor.directory.Directory]
wx_icons_humanity.version()[source]
class wx_icons_humanity.wxHumanityDarkIconTheme[source]
CreateBitmap(id, client, size)[source]

Returns the requested resource.

Parameters
  • id – Unique identifier of the bitmap.

  • client – Identifier of the client (i.e. who is asking for the bitmap). This only serves as a hint.

  • size – Preferred size of the bitmap. The function may return a bitmap of different dimensions; it will be automatically rescaled to meet client’s request.

static HasNativeProvider()
Return type

bool

static icon2bitmap(icon, size)

Converts an Icon to a wx.Bitmap.

Parameters
  • icon (Icon) –

  • size (int) – The desired size of the icon. If the icon isn’t scalable the icon is returned in its original size.

Return type

Bitmap

class wx_icons_humanity.wxHumanityIconTheme[source]
CreateBitmap(id, client, size)[source]

Returns the requested resource.

Parameters
  • id (Any) – Unique identifier of the bitmap.

  • client (Any) – Identifier of the client (i.e. who is asking for the bitmap). This only serves as a hint.

  • size (Union[Tuple[int], Size]) – Preferred size of the bitmap. The function may return a bitmap of different dimensions; it will be automatically rescaled to meet client’s request.

Return type

Bitmap

static HasNativeProvider()
Return type

bool

static icon2bitmap(icon, size)

Converts an Icon to a wx.Bitmap.

Parameters
  • icon (Icon) –

  • size (int) – The desired size of the icon. If the icon isn’t scalable the icon is returned in its original size.

Return type

Bitmap

Contributing

wx_icons_suru uses tox to automate testing and packaging, and pre-commit to maintain code quality.

Install pre-commit with pip and install the git hook:

python -m pip install pre-commit
pre-commit install

Coding style

Yapf is used for code formatting, and isort is used to sort imports.

yapf and isort can be run manually via pre-commit:

pre-commit run yapf -a
pre-commit run isort -a

The complete autoformatting suite can be run with pre-commit:

pre-commit run -a

Automated tests

Tests are run with tox and pytest. To run tests for a specific Python version, such as Python 3.6, run:

tox -e py36

To run tests for all Python versions, simply run:

tox

Type Annotations

Type annotations are checked using mypy. Run mypy using tox:

tox -e mypy

Build documentation locally

The documentation is powered by Sphinx. A local copy of the documentation can be built with tox:

tox -e docs

Downloading source code

The wx_icons_suru source code is available on GitHub, and can be accessed from the following URL: https://github.com/domdfcoding/custom_wx_icons_suru

If you have git installed, you can clone the repository with the following command:

$ git clone https://github.com/domdfcoding/custom_wx_icons_suru"
> Cloning into 'custom_wx_icons_suru'...
> remote: Enumerating objects: 47, done.
> remote: Counting objects: 100% (47/47), done.
> remote: Compressing objects: 100% (41/41), done.
> remote: Total 173 (delta 16), reused 17 (delta 6), pack-reused 126
> Receiving objects: 100% (173/173), 126.56 KiB | 678.00 KiB/s, done.
> Resolving deltas: 100% (66/66), done.
Alternatively, the code can be downloaded in a ‘zip’ file by clicking:
Clone or download –> Download Zip
Downloading a 'zip' file of the source code.

Downloading a ‘zip’ file of the source code

Building from source

The recommended way to build wx_icons_suru is to use tox:

tox -e build

The source and wheel distributions will be in the directory dist.

If you wish, you may also use pep517.build or another PEP 517-compatible build tool.

View the Function Index or browse the Source Code.

Browse the GitHub Repository