avi
avi

Reputation: 1886

Working with wxpython NoteBook event

I have a NoteBook in wxpython as follows:

self.a = wx.Notebook(self, -1, style=0)

self.x= firstpanel(self.a,None)
self.y= secondpanel(self.a,None)

self.a.AddPage(self.x,_("firstPage"))
self.a.AddPage(self.y,_("secondPage"))

self.a.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,self.ChangedTab)

In ChangedTab I want to change a Button named bttn in the screen. if secondPage tab was clicked then button will be clickable (bttn.Enabled() ) if any other tab was clicked button will be unclickable (bttn.Disable()).

What I have so far is:

def ChangedTab(self, event):
     index = event.GetIndex()

My problem is how do I know which tab was clicked?

I know the tabs by their names firstPage and secondPage etc.. how do I get them from the event? The GetIndex() doesn't seem to help me in this case. or there is another way to do what?

Upvotes: 2

Views: 841

Answers (1)

falsetru
falsetru

Reputation: 369444

You can use GetPage to get the selected page object, then you can compare it with the second page object (self.y) to check if the second tab is selected:

def ChangedTab(self, event):
    index = self.a.GetSelection()
    if self.a.GetPage(index) is self.y: # second page
        # Enable button
    else:                               # other pages
        # Disable button

Upvotes: 2

Related Questions