def onSelChange(self, event):
        """Select a new tree node, loading it if needed"""
        item = event.GetItem()
        data = self.db_layout_tree.GetPyData(item)
        if isinstance(data, (dict, UserDict.UserDict, OOBTree)):
            self.txtData.Clear()
            self.txtType.SetLabel(str(type(data)))
            if hasattr(data, 'wx_str'):
                self.txtData.AppendText(data.wx_str())
            if not self.db_layout_tree.ItemHasChildren(item):
                keys = data.keys()
                try:
                    keys.sort()
                except AttributeError:
                    pass
                for key in keys:
                    child = self.db_layout_tree.AppendItem(item, str(key))
                    self.db_layout_tree.SetPyData(child, data[key])
                    self._set_child_icons(child, data[key])
        elif isinstance(data, (list, UserList.UserList)):
            self.txtData.Clear()
            self.txtType.SetLabel(str(type(data)))
            for d in data:
                self.txtData.AppendText(str(type(d)) + ' --\n')
                if hasattr(d, 'wx_str'):
                    self.txtData.AppendText(d.wx_str())
                else:
                    self.txtData.AppendText(str(d))
                self.txtData.AppendText('\n')
        else:
            self.txtType.SetLabel(str(type(data)))
            fmt = '%s\n-----\n%s'
            if hasattr(data, 'wx_str'):
                self.txtData.SetValue(data.wx_str())
            else:
                self.txtData.SetValue(str(data))
Select a new tree node, loading it if needed
recipes/Python/409012_A_Simple_ZODB_viewer_in_wxPython/recipe-409012.py