Aug-06-2017, 02:37 AM
How can I add code in onStop of LeftPanel to stop the timer created in RightPanel?
Is it possible to stop it from in Frame class? Thanks.
Is it possible to stop it from in Frame class? Thanks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
import wx import wx.html2 as webview class LeftPanel(wx.Panel): def __init__( self , parent): wx.Panel.__init__( self , parent = parent) stopBtn = wx.Button( self , label = "Stop Timer" ) stopBtn.Bind(wx.EVT_BUTTON, self .onStop) def onStop( self ,event): print ( 'Stop Timer' ) class RightPanel(wx.Panel): def __init__( self , parent): wx.Panel.__init__( self , parent = parent) self .frame = self .GetTopLevelParent() self .titleBase = self .frame.GetTitle() sizer = wx.BoxSizer(wx.VERTICAL) self .wv = webview.WebView.New( self ) sizer.Add( self .wv, 1 , wx.EXPAND) self .SetSizer(sizer) self .wv.LoadURL( self .current) self .timer = wx.PyTimer( self .Timer1) self .timer.Start( 3000 ) def Timer1( self ): print ( '3-second timer' ) class Frame(wx.Frame): def __init__( self ): wx.Frame.__init__( self , None , title = "Stop Timer" , size = ( 500 , 300 ), pos = ( 500 , 300 )) splitter = wx.SplitterWindow( self ) leftP = LeftPanel(splitter) rightP = RightPanel(splitter) splitter.SplitVertically(leftP, rightP) splitter.SetMinimumPaneSize( 200 ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(splitter, 1 , wx.EXPAND) self .SetSizer(sizer) if __name__ = = "__main__" : app = wx.App() win = Frame() win.CreateStatusBar() win.Show() app.MainLoop() |