O'Reilly logo

WxPython Application Development Cookbook by Cody Precord

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Displaying hierarchical data with TreeCtrl

TreeCtrl provides a way to create and display data in a hierarchy. The control contains a series of nodes that can have child nodes, which in turn can have their own child nodes. This nested data display allows users to expand and collapse the nodes to see more or less as need be. In this recipe, we will use TreeCtrl to create an outline view of an XML file.

How to do it…

Perform the following steps:

  1. For this recipe, in addition to the wx module, we will use the ElementTree module from the Python standard library. Take a look at the following script:
    import xml.etree.ElementTree as ET
    import wx
  2. Next, let's start on a custom subclass of wx.TreeCtrl to specialize it to display XML data using the following code: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required