Chapter 7. Installing and Designing own Widget Plugins
Prev |  | Next

# Chapter 7. Installing and Designing own Widget Plugins

wxGlade supports a simple plugin system for widgets to load all widgets at the application startup dynamically. The plugin system loads all

built-in widgets like “Static Text” widget or the “Gauge” widget. It also loads widgets installed by users.

## Widgets packages

The wxGlade plugin system supports two different types of widget packages:

1. “directory package” - a single directory with all necessary files inside

2. “ZIP package” - a zipped version of a "directory" package

Example 7.1. Directory package

    static_text          <- Directory named after the widget name
    |-- __init__.py      <- Mostly an empty file or a file with just a comment
    |-- codegen.py       <- Python and C++ code generators
    |-- wconfig.py       <- Widget configuration
    |-- lisp_codegen.py  <- Lisp code generator
    |-- perl_codegen.py  <- Perl code generator
    `-- static_text.py   <- wxGlade GUI code

Example 7.2. ZIP package

    # unzip -l static_text.zip
    Archive:  static_text.zip
      Length      Date    Time    Name
    ---------  ---------- -----   ----
            0  2013-12-09 10:02   static_text/
          329  2013-12-09 10:02   static_text/__init__.py
         3352  2013-12-09 10:02   static_text/codegen.py
          320  2013-12-09 10:02   static_text/wconfig.py
         1640  2013-12-09 10:02   static_text/lisp_codegen.py
         1841  2013-12-09 10:02   static_text/perl_codegen.py
         5917  2013-12-09 10:02   static_text/static_text.py
    ---------                     -------
        13079                     6 files

### Create ZIP package

Creating a ZIP package is quite simple. Just create a ZIP package from widgets directory with all Python and additional files. Don't include Python bytecode files because they are not platfrom-independend.

    # tree static_text/
    static_text/
    |-- __init__.py
    |-- codegen.py
    |-- wconfig.py
    |-- lisp_codegen.py
    |-- perl_codegen.py
    `-- static_text.py

    # zip -r static_text.zip static_text
      adding: static_text/ (stored 0%)
      adding: static_text/__init__.py (deflated 36%)
      adding: static_text/codegen.py (deflated 67%)
      adding: static_text/wconfig.py (deflated 64%)
      adding: static_text/lisp_codegen.py (deflated 54%)
      adding: static_text/perl_codegen.py (deflated 56%)
      adding: static_text/static_text.py (deflated 69%)

Check the integrity of the created ZIP archive:

    # zip -T static_text.zip
    test of static_text.zip OK

Prev |  | Next
For contributors | Home | Installing Widget Plugins locally