2

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?

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

1 Comment

It gives an error: expected argument 2 of type 'size_t'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.