Open In App
Related Articles

wxPython – ExpandAll() method in wx.TreeCtrl

Improve Article
Save Article
Like Article

In this article we are going to learn about ExpandAll() method associated with wx.TreeCtrl class of wxPython. ExpandAll() method is similar to Expand() but the only difference is that this method is used to expand all the items present in the Tree Control. All child nodes  along with their parent nodes are visible using this method.

No parameters are required by this method.

Syntax: wx.TreeCtrl.ExpandAll(self)


No parameters are required by this method.

Code Example:


import wx
class MyTree(wx.TreeCtrl):
    def __init__(self, parent, id, pos, size, style):
        wx.TreeCtrl.__init__(self, parent, id, pos, size, style)
class TreePanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        # create tree control in window
        self.tree = MyTree(self, wx.ID_ANY, wx.DefaultPosition,
                           wx.DefaultSize, wx.TR_HAS_BUTTONS)
        self.root = self.tree.AddRoot('root')
        self.tree.SetPyData(self.root, ('key', 'value'))
        # add item to root
        item = self.tree.AppendItem(self.root, "Item")
        item2 = self.tree.AppendItem(self.root, "Item")
        item3 = self.tree.AppendItem(item, "SubItem")
        # expand all nodes of the tree
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.tree, 0, wx.EXPAND)
class MainFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, parent = None, title ='TreeCtrl Demo')
        panel = TreePanel(self)
if __name__ == '__main__':
    app = wx.App(redirect = False)
    frame = MainFrame()


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 28 Feb, 2023
Like Article
Save Article
Similar Reads
Related Tutorials