wxPython – AppendItem() method in wx.TreeCtrl
Last Updated :
08 Jul, 2020
In this article we will learn about AppendItem() method in wx.TreeCtrl class of wxPython. AppendItem() method is used to append an item to the end of the branch identified by parent, return a new item id.
Append() method takes parent(wx.TreeItemId) as parameter.
Syntax: wx.TreeCtrl.AppendItem()
Parameters
Parameter |
Input Type |
Description |
parent |
wx.TreeItemId |
parent root for Item. |
text |
string |
text on node |
image |
int |
image parameter is an index within the normal image list specifying the image to unselected items, respectively. |
selImage |
int |
selImage parameter is an index within the normal image list specifying the image to selected items, respectively. |
data |
TreeItemData |
data for root item. |
Return Type: wx.TreeItemId
Code Example:
import wx
class MainFrame(wx.Frame):
def __init__( self ):
wx.Frame.__init__( self , parent = None , title = 'TreeCtrl Demo' )
self .tree = wx.TreeCtrl( self , wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize)
self .root = self .tree.AddRoot( 'Root ' )
self .tree.AppendItem( self .root, "Item" )
self .tree.Expand( self .root)
self .Show()
if __name__ = = '__main__' :
app = wx.App(redirect = False )
frame = MainFrame()
app.MainLoop()
|
Output Window:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...