I’ve got a Python script nearly identical to that on the wxPy Wiki, and I’d like to run a function in (no indentation) every time the tab is changed. I’ve tried just putting theFunction() after the wx.Frame.__init__... line in the def __init__ in each of hte three classes used by the Notebook. When I do this, the window closes immediately after closing, with no error in the terminal. What am I doing wrong? Here’s what I have for each class used by the notebook:
class Textures(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
self.textureslist = wx.ListBox(choices = ['One', 'Two', 'Three'], id = -1, name = 'textureslist', parent = self, pos = (6, 0), size = (382, 150))
getDivVars()
EDIT: The reason it was quitting was related to accidentally using App, not PySimpleApp. However, the list still doesn’t update (which getDivVars() does) each time the tab is changed. I still need to do this.
To have a function called whenever the notebook page changes, bind the
EVT_NOTEBOOK_PAGE_CHANGEDevent to a function or method. Taking the ‘Simple wx.Notebook Example` as a starting point, you’d add a lineor, if you want to call a function outside of a class instead of a method,
some_functionwould need to take a single parameter, andsome_methodwould need to take a single parameter in addition toself.