Python wx 模块,EVT_NOTEBOOK_PAGE_CHANGED 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用wx.EVT_NOTEBOOK_PAGE_CHANGED

项目:PandasDataFrameGUI    作者:bluenote10    | 项目源码 | 文件源码
def __init__(self, df):
        wx.Frame.__init__(self, None, -1, "Pandas DataFrame GUI")

        # Here we create a panel and a notebook on the panel
        p = wx.Panel(self)
        nb = wx.Notebook(p)
        self.nb = nb

        columns = df.columns[:]

        self.CreateStatusBar(2, style=0)
        self.SetStatusWidths([200, -1])

        # create the page windows as children of the notebook
        self.page1 = DataframePanel(nb, df, self.status_bar_callback)
        self.page2 = ColumnSelectionPanel(nb, columns, self.page1.df_list_ctrl)
        self.page3 = FilterPanel(nb, columns, self.page1.df_list_ctrl, self.selection_change_callback)
        self.page4 = HistogramPlot(nb, columns, self.page1.df_list_ctrl)
        self.page5 = ScatterPlot(nb, columns, self.page1.df_list_ctrl)

        # add the pages to the notebook with the label to show on the tab
        nb.AddPage(self.page1, "Data Frame")
        nb.AddPage(self.page2, "Columns")
        nb.AddPage(self.page3, "Filters")
        nb.AddPage(self.page4, "Histogram")
        nb.AddPage(self.page5, "Scatter Plot")

        nb.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.on_tab_change)

        # finally, put the notebook in a sizer for the panel to manage
        # the layout
        sizer = wx.BoxSizer()
        sizer.Add(nb, 1, wx.EXPAND)
        p.SetSizer(sizer)

        self.SetSize((800, 600))
        self.Center()
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def AddPanelAndStoreID(self, panel, text, **kwargs):
        new_page_image_id = len(self.ztv_frame.control_panels)
        setattr(panel, 'ztv_page_id', new_page_image_id)
        setattr(panel, 'ztv_display_name', text)
        setattr(panel, 'ztv_ref_name', text.lower() + '_panel')
        setattr(panel, 'highlight_panel', lambda : self._highlight_page(panel))
        setattr(panel, 'select_panel', lambda : self.SetSelection(panel.ztv_page_id))
        setattr(self.ztv_frame, text.lower() + '_panel', panel)
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.notebook_page_changed)
        self.AddPage(panel, text)
        self.ztv_frame.control_panels.append(panel)
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def notebook_page_changed(self, evt):
        oldnew = (evt.GetOldSelection(), evt.GetSelection())
        # EVT_NOTEBOOK_PAGE_CHANGED seems to be called 4-5 or more times per actual change, with identical
        #     OldSelection,Selection; so, need to filter those additional calls out after first one
        if oldnew != self._prior_notebook_page_change:
            if hasattr(self.ztv_frame.control_panels[oldnew[1]], 'on_activate'):
                self.ztv_frame.control_panels[oldnew[1]].on_activate()
            self._prior_notebook_page_change = oldnew
        evt.Skip()
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def AddPanelAndStoreID(self, panel, text, **kwargs):
        new_page_image_id = len(self.ztv_frame.control_panels)
        setattr(panel, 'ztv_page_id', new_page_image_id)
        setattr(panel, 'ztv_display_name', text)
        setattr(panel, 'ztv_ref_name', text.lower() + '_panel')
        setattr(panel, 'highlight_panel', lambda : self._highlight_page(panel))
        setattr(panel, 'select_panel', lambda : self.SetSelection(panel.ztv_page_id))
        setattr(self.ztv_frame, text.lower() + '_panel', panel)
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.notebook_page_changed)
        self.AddPage(panel, text)
        self.ztv_frame.control_panels.append(panel)
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def notebook_page_changed(self, evt):
        oldnew = (evt.GetOldSelection(), evt.GetSelection())
        # EVT_NOTEBOOK_PAGE_CHANGED seems to be called 4-5 or more times per actual change, with identical
        #     OldSelection,Selection; so, need to filter those additional calls out after first one
        if oldnew != self._prior_notebook_page_change:
            if hasattr(self.ztv_frame.control_panels[oldnew[1]], 'on_activate'):
                self.ztv_frame.control_panels[oldnew[1]].on_activate()
            self._prior_notebook_page_change = oldnew
        evt.Skip()
项目:bp5000    作者:isaiahr    | 项目源码 | 文件源码
def setup(self):
        menubar = wx.MenuBar()
        filem = wx.Menu()
        helpm = wx.Menu()
        setm = wx.Menu()
        new = filem.Append(wx.ID_NEW, '&New Tournament')
        open_ = filem.Append(wx.ID_OPEN, '&Open Tournament')
        filem.AppendSeparator()
        self.Bind(wx.EVT_MENU, self.new_event, new)
        qmi = wx.MenuItem(filem, wx.ID_EXIT, '&Quit\tCtrl+W')
        filem.AppendItem(qmi)
        about = helpm.Append(wx.ID_ANY, '&About BP5000')
        options = setm.Append(wx.ID_ANY, '&Options')
        self.Bind(wx.EVT_MENU, self.quit_event, qmi)
        self.Bind(wx.EVT_MENU, self.load_event, open_)
        self.Bind(wx.EVT_MENU, self.about_event, about)
        self.Bind(wx.EVT_MENU, self.options_event, options)
        self.options = Options()
        menubar.Append(filem, '&File')
        menubar.Append(setm, '&Settings')
        menubar.Append(helpm, '&Help')
        self.SetMenuBar(menubar)
        p = wx.Panel(self)
        self.nb = fnb.FlatNotebook(p, agwStyle=fnb.FNB_X_ON_TAB)

        def pagechanged(event):
            col = wx.Colour(hash(self.nb.GetPage(event.GetSelection()).sname))
            self.nb.SetActiveTabColour(col)
            if isinstance(self.nb.GetPage(event.GetSelection()), BracketPage):
                self.nb.GetPage(event.GetSelection()).updatebracketimg()

        self.nb.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, pagechanged)
        sz = wx.BoxSizer()
        sz.Add(self.nb, 1, wx.EXPAND)
        p.SetSizer(sz)
        self.Bind(wx.EVT_CLOSE, self.quit_event)
        self.SetSize((950, 650))
        self.SetTitle('BP5000')
        self.Centre()
        self.Show(True)
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def __init__(self, logplot, track_id=ID_ALL_TRACKS, logplotformat=None, ok_callback=None):

        self.logplot = logplot
        self.track_id = track_id

        self.welluid = self.logplot.get_well_uid()
        self._OM = ObjectManager(self)
        #well = self._OM.get(self.welluid)

        if logplotformat is None:
            logplotformat = LogPlotFormat()
        self.original_logplotformat = logplotformat
        self.edited_logplotformat = copy.deepcopy(self.original_logplotformat)


        wx.Frame.__init__(self, self.logplot, -1,
                                          title="Log Plot Format - TESTE",
                                          size=(850, 600),
                                          style=wx.DEFAULT_FRAME_STYLE & 
                                          (~wx.RESIZE_BORDER) &(~wx.MAXIMIZE_BOX))

        self.callback = ok_callback             
        sizer = wx.BoxSizer(wx.VERTICAL)                                  
        self.base = wx.Panel(self)
        note = wx.Notebook(self.base)
        bsizer = wx.BoxSizer(wx.HORIZONTAL)
        bsizer.Add(note, 1, wx.ALL|wx.EXPAND, border=5)        
        self.base.SetSizer(bsizer)

        self.tracks_model = None
        self.curves_model = CurvesModel(self.edited_logplotformat, self.track_id)

        if self.track_id == self.ID_ALL_TRACKS:
            self.tracks_model = TracksModel(self.edited_logplotformat)
            tn = TracksNotifier(self.edited_logplotformat, self.curves_model)
            self.tracks_model.AddNotifier(tn)
            tn.SetOwner(self.tracks_model)
            self.grid_panel = BasePanel(note, 'grid', self.welluid, self.track_id, self.tracks_model)                  
            note.AddPage(self.grid_panel, "Grid", True)
        else:
            self.grid_panel = None
        if self.tracks_model is not None:    
            cn = CurvesNotifier(self.edited_logplotformat, self.tracks_model)
            self.curves_model.AddNotifier(cn)
            cn.SetOwner(self.curves_model) 
        self.curves_panel = BasePanel(note, 'curves', self.welluid, self.track_id, self.curves_model)
        note.AddPage(self.curves_panel, "Curves", False)


        note.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self._OnNotePageChanging)
        sizer.Add(self.base, 1, wx.EXPAND)
        sizer.Add(self.getPanelBottomButtons(), 0, wx.EXPAND|wx.BOTTOM|wx.TOP)
        self.SetSizer(sizer)