wxPython Phoenix Documentation

repository·master·Indexed 25 days ago

https://github.com/wxwidgets/phoenix

A high-performance, next-generation wrapper for the wxWidgets C++ toolkit enabling native GUI development in Python. Includes documentation on the wx.lib.plot plotting package, buildbot worker configuration, Docker-based wheel builds for Linux distributions, and GUI implementation guides for components like StyledTextCtrl, AUI Perspectives, and custom logging.

Tokens
42.8K
Snippets
78
Records
283
Agent score
80%

What's inside wxPython Phoenix

  1. Overview of wx.lib.plot

    master

    wx.lib.plot

    wx.lib.plot is a lightweight plotting package designed for wxPython Phoenix. It is built upon wxPlotCanvas and is optimized for small footprint and fast plotting of large datasets.

    Key Characteristics:

    • Performance: Focused on speed when handling large data sets.
    • Simplicity: Easier to integrate into wxPython applications compared to heavy-duty scientific libraries.
    • Capabilities: Supports line graphs, scatter graphs, and simple bar graphs.
    • Comparison: While not as feature-rich as SciPy's matplotlib (plt) or Chaco, it is significantly more resource-efficient for simple plotting tasks.

    Authorship:

    • Original authors: K. Hinsen, R. Srinivasan
    • wxPython Port: Harm van der Heijden
  2. Introduction to wxPython Phoenix

    master
    wxPython Phoenix is a modern implementation of wxPython designed for improved speed, maintainability, and extensibility. It serves as a Python wrapper for the wxWidgets C++ toolkit, providing access to the UI portions of the wx API. This allows developers to create Python applications with a native look and feel across Windows, macOS, and Unix systems while minimizing the need for platform-specific code.
  3. Overview of wxPython Project Phoenix

    master
    wxPython Project Phoenix is a next-generation implementation of wxPython focused on speed, maintainability, and extensibility. It wraps the wxWidgets C++ toolkit to provide native GUI access for Python applications on Windows, macOS, and Unix systems, ensuring a native look and feel with minimal platform-specific code.
  4. Overview of PyCrust

    master

    PyCrust is an interactive Python environment written in Python. It is designed to be used as a standalone tool or integrated into other development environments and Python applications. It consists of three main components:

    • PyShell: An interactive Python shell.
    • PyFilling: An interactive namespace/object tree control.
    • PyCrust: An integrated, split-window combination of PyShell and PyFilling.
  5. Implement Undo/Redo using wx.CommandProcessor

    master
    The wx.CommandProcessor class maintains a history of wx.Command instances and provides built-in undo and redo functionality. When a user interface event occurs, submit the command to a wx.CommandProcessor object to execute and store it in the history. You can derive a new class from wx.CommandProcessor if you require custom history management behavior.
  6. Understand wx.DataObject for Clipboard and Drag and Drop

    master

    In wxPython, wx.DataObject is the central class used for both clipboard operations and drag-and-drop transfers. Because both mechanisms use the same underlying logic, implementing support for one often provides support for the other.

    wx.DataObject (and its derivatives) represents the data being transferred. It is considered a "smart" object because it:

    • Knows which formats it supports (via GetFormatCount and GetAllFormats).
    • Knows how to render itself in supported formats (via GetDataHere).
    • Can receive values from external sources if it implements SetData.
  7. Choose a BookCtrl variant for page navigation

    master

    A BookCtrl is used to display multiple pages of information, showing one page at a time. wxPython provides five variants depending on the desired navigation interface:

    • wx.Choicebook: Navigation is controlled by a wx.Choice widget.
    • wx.Listbook: Navigation is controlled by a wx.ListCtrl widget.
    • wx.Notebook: Navigation uses a row of tabs.
    • wx.Treebook: Navigation is controlled by a wx.TreeCtrl widget.
    • wx.Toolbook: Navigation is controlled by a wx.ToolBar widget.
  8. Use the integrated PyPubSub library in wxPython

    master

    wxPython includes a verbatim copy of the PyPubSub project in the wx.lib.pubsub module for convenience. This allows wxPython users to use the publish-subscribe pattern without additional installations.

    If you require a more up-to-date version than the one bundled with your wxPython distribution, you can install the standalone PyPubSub package or manually overwrite the contents of the wx/lib/pubsub directory with a version from the official SourceForge repository.

  9. Model application actions with wx.Command

    master

    Use wx.Command as a base class to model application actions (e.g., menu item selections, toolbar button presses) as explicit objects. This approach centralizes functionality that would otherwise be scattered across various functions, making the application easier to maintain and allowing for features like Undo/Redo or macro recording.

    To implement an action, you can either derive a new class for every specific command or use a single parameterized class that uses an integer or string command identifier.

  10. Understand RichTextCtrl styling layers

    master

    The wx.richtext.RichTextCtrl uses a layered approach to determine the final visible style of text. The visible style is a dynamic combination of the following four notions:

    1. Basic style: The fundamental style (e.g., default font). Set via SetBasicStyle. Changing this can affect all content using relative styles.
    2. Paragraph style: Attributes applied to an entire paragraph (e.g., alignment, indentation). Set via SetStyleEx with the RICHTEXT_SETSTYLE_PARAGRAPHS_ONLY flag.
    3. Character style: Attributes applied to specific characters or runs within a paragraph (e.g., bold, color). Set via SetStyle or SetStyleEx with the RICHTEXT_SETSTYLE_CHARACTERS_ONLY flag.
    4. Default style: The style used for content that is subsequently typed or inserted. Set via SetDefaultStyle.
  11. Manage font encodings with wx.FontEnumerator and wx.FontMapper

    master

    When working with 8-bit fonts, you may need to handle incompatible encodings or missing fonts across different platforms. wxPython provides two primary classes for this:

    1. wx.FontEnumerator: Use this to enumerate all available encodings on the system and to find specific font face names that support a given encoding.
    2. wx.FontMapper: Use this to resolve mapping issues where wx.FontEnumerator might fail (e.g., finding a KOI8 font on a Windows system). wx.FontMapper stores mappings between encodings and font face names in a wx.ConfigBase object. It can optionally ask the user for the correct mapping and remember the choice for future use.
  12. Use Cairo support in wxPython on Windows

    master
    The msw-cairo package provides Cairo header files and DLLs for Windows. This enables Cairo support within wx.GraphicsContext in wxWidgets and allows for direct Cairo usage from Python via the wx.lib.wxcairo package. These DLLs are included by default in standard Windows binary builds of wxPython.