aui.Manager: How to update a wx.TreeCtrl pane

Hello,

I have a aui.Manager pane that contains a wx.TreeCtrl:

self.network_element = self.NetworkExplorer()

self._mgr.AddPane(self.network_element, wx.aui.AuiPaneInfo().

Name(“NE”).Caption(“Network Explorer”).

Right().Layer(1).Position(1).CloseButton(True).MaximizeButton(True))

def NetworkExplorer(self, tree_data=’’):

tree = wx.TreeCtrl(self, -1, wx.Point(0, 0), wx.Size(400, 200),wx.TR_DEFAULT_STYLE | wx.NO_BORDER)

root = tree.AddRoot(“Nodes”)

items = []

j = 0

imglist = wx.ImageList(16, 16, True, 2)

imglist.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, wx.Size(16,16)))

imglist.Add(wx.ArtProvider_GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, wx.Size(16,16)))

tree.AssignImageList(imglist)

if tree_data == ‘’:

items.append(tree.AppendItem(root, “”, 0))

tree.AppendItem(items[0], “”, 1)

else:

for c in tree_data.keys():

items.append(tree.AppendItem(root, c, 0))

for n in tree_data[c]:

tree.AppendItem(items[j], n, 1)

j = j+1

tree.Expand(root)

tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged)

self.tree = tree

tree.SetMinSize((1800,-1))

return tree

Now, I am trying to trying to change the content of the TreeCtrl in the aui.Manager pane with the following code:

Query for all network elements and update the network explorer pane

for i in self.table.find({‘mo’:‘ManagedElement’}):

l = []

key = str(i[‘node_name’])

for r in self.table.find({‘mo’:‘IubLink’,‘node_name’:key}):

l.append(str(r[‘IubLinkId’]))

ne[key] = l

self.network_element = self.NetworkExplorer(ne)

self._mgr.Update()

But the tree control in the pane is not being updated.

How do I update the TreeCtrl in the aui.Manager pane (i.e self._mgr.GetPane(“NE”))?

Austin

It would be easier to help if you posted a working demo/sample.

Scanning through the code you posted, it looks like you’re creating new NetworkExplorer objects, rather than updating the previous one… and on top of that, the new objects aren’t being added to the Manager. Here’s where it /seems/ (due to lack of complete code demo) you’re creating the initial TreeCtrl and letting the Manager know about it:

self.network_element = self.NetworkExplorer()

self._mgr.AddPane(self.network_element, wx.aui.AuiPaneInfo()

then later here, you seem to create a completely new TreeCtrl, but don’t tell the Manager about it:

self.network_element = self.NetworkExplorer(ne)

self._mgr.Update()

I suggest moving your AppendItem code from init to some other method, say UpdateTree(self, tree_data) or something like that… in which you call:
yourTreeObject.DeleteAllItems()

then the code you already had

then:
yourTreeObject.Refresh()
then maybe try calling Update on the Manager

···

On Wednesday, August 20, 2014 2:32:48 AM UTC-7, austin aigbe wrote:

Hello,

I have a aui.Manager pane that contains a wx.TreeCtrl:

self.network_element = self.NetworkExplorer()

self._mgr.AddPane(self.network_element, wx.aui.AuiPaneInfo().

Name(“NE”).Caption(“Network Explorer”).

Right().Layer(1).Position(1).CloseButton(True).MaximizeButton(True))

def NetworkExplorer(self, tree_data=‘’):

tree = wx.TreeCtrl(self, -1, wx.Point(0, 0), wx.Size(400, 200),wx.TR_DEFAULT_STYLE | wx.NO_BORDER)

root = tree.AddRoot(“Nodes”)

items =

j = 0

imglist = wx.ImageList(16, 16, True, 2)

imglist.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, wx.Size(16,16)))

imglist.Add(wx.ArtProvider_GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, wx.Size(16,16)))

tree.AssignImageList(imglist)

if tree_data == ‘’:

items.append(tree.AppendItem(root, “”, 0))

tree.AppendItem(items[0], “”, 1)

else:

for c in tree_data.keys():

items.append(tree.AppendItem(root, c, 0))

for n in tree_data[c]:

tree.AppendItem(items[j], n, 1)

j = j+1

tree.Expand(root)

tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged)

self.tree = tree

tree.SetMinSize((1800,-1))

return tree

Now, I am trying to trying to change the content of the TreeCtrl in the aui.Manager pane with the following code:

Query for all network elements and update the network explorer pane

for i in self.table.find({‘mo’:‘ManagedElement’}):

l =

key = str(i[‘node_name’])

for r in self.table.find({‘mo’:‘IubLink’,‘node_name’:key}):

l.append(str(r[‘IubLinkId’]))

ne[key] = l

self.network_element = self.NetworkExplorer(ne)

self._mgr.Update()

But the tree control in the pane is not being updated.

How do I update the TreeCtrl in the aui.Manager pane (i.e self._mgr.GetPane(“NE”))?

Austin

Thanks Nathan for the hint.

I missed out the fact self.network_element was not hooked to the aui.AuiManager.

Now it works fine.

I am using the following piece code to update the TreeCtrl:

def UpdateTree(self, tree_ctrl, tree_data):

items =

j = 0

if tree_data != ‘’:

tree_ctrl.DeleteAllItems()

root = tree_ctrl.AddRoot(“Nodes”)

for c in tree_data.keys():

items.append(tree_ctrl.AppendItem(root, c, 0)) # RNCs

for n in tree_data[c]:

tree_ctrl.AppendItem(items[j], n, 1)

j = j+1

tree_ctrl.Refresh()

And using the following to update the view from the aui manager:

Query for all network elements and update the network explorer pane

for i in self.table.find({‘mo’:‘ManagedElement’}):

l =

key = str(i[‘node_name’]) # For RNC’s

for r in self.table.find({‘mo’:‘IubLink’,‘node_name’:key}):

l.append(str(r[‘IubLinkId’])) # For RBS’s

ne[key] = l

self.p.UpdateTree(self.p.network_element,ne)

self.p._mgr.Update()

···

On Wednesday, August 20, 2014 5:44:06 PM UTC+1, Nathan McCorkle wrote:

It would be easier to help if you posted a working demo/sample.

Scanning through the code you posted, it looks like you’re creating new NetworkExplorer objects, rather than updating the previous one… and on top of that, the new objects aren’t being added to the Manager. Here’s where it /seems/ (due to lack of complete code demo) you’re creating the initial TreeCtrl and letting the Manager know about it:

self.network_element = self.NetworkExplorer()

self._mgr.AddPane(self.network_element, wx.aui.AuiPaneInfo()

then later here, you seem to create a completely new TreeCtrl, but don’t tell the Manager about it:

self.network_element = self.NetworkExplorer(ne)

self._mgr.Update()

I suggest moving your AppendItem code from init to some other method, say UpdateTree(self, tree_data) or something like that… in which you call:
yourTreeObject.DeleteAllItems()

then the code you already had

then:
yourTreeObject.Refresh()
then maybe try calling Update on the Manager

On Wednesday, August 20, 2014 2:32:48 AM UTC-7, austin aigbe wrote:

Hello,

I have a aui.Manager pane that contains a wx.TreeCtrl:

self.network_element = self.NetworkExplorer()

self._mgr.AddPane(self.network_element, wx.aui.AuiPaneInfo().

Name(“NE”).Caption(“Network Explorer”).

Right().Layer(1).Position(1).CloseButton(True).MaximizeButton(True))

def NetworkExplorer(self, tree_data=‘’):

tree = wx.TreeCtrl(self, -1, wx.Point(0, 0), wx.Size(400, 200),wx.TR_DEFAULT_STYLE | wx.NO_BORDER)

root = tree.AddRoot(“Nodes”)

items =

j = 0

imglist = wx.ImageList(16, 16, True, 2)

imglist.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, wx.Size(16,16)))

imglist.Add(wx.ArtProvider_GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, wx.Size(16,16)))

tree.AssignImageList(imglist)

if tree_data == ‘’:

items.append(tree.AppendItem(root, “”, 0))

tree.AppendItem(items[0], “”, 1)

else:

for c in tree_data.keys():

items.append(tree.AppendItem(root, c, 0))

for n in tree_data[c]:

tree.AppendItem(items[j], n, 1)

j = j+1

tree.Expand(root)

tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged)

self.tree = tree

tree.SetMinSize((1800,-1))

return tree

Now, I am trying to trying to change the content of the TreeCtrl in the aui.Manager pane with the following code:

Query for all network elements and update the network explorer pane

for i in self.table.find({‘mo’:‘ManagedElement’}):

l =

key = str(i[‘node_name’])

for r in self.table.find({‘mo’:‘IubLink’,‘node_name’:key}):

l.append(str(r[‘IubLinkId’]))

ne[key] = l

self.network_element = self.NetworkExplorer(ne)

self._mgr.Update()

But the tree control in the pane is not being updated.

How do I update the TreeCtrl in the aui.Manager pane (i.e self._mgr.GetPane(“NE”))?

Austin