wx.Slider is a widget that has a simple handle. This handle can be pulled back and forth. This way we can choose a specific task.
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 class Example(wx.Frame): def __init__( self , * args, * * kw): super (Example, self ).__init__( * args, * * kw) self .InitUI() def InitUI( self ): pnl = wx.Panel( self ) sld = wx.Slider(pnl, value = 200 , minValue = 150 , maxValue = 500 , pos = ( 20 , 20 ), size = ( 250 , - 1 ), style = wx.SL_HORIZONTAL) sld.Bind(wx.EVT_SCROLL, self .OnSliderScroll) self .txt = wx.StaticText(pnl, label = '200' , pos = ( 20 , 90 )) self .SetSize(( 290 , 200 )) self .SetTitle( 'wx.Slider' ) self .Centre() self .Show( True ) def OnSliderScroll( self , e): obj = e.GetEventObject() val = obj.GetValue() self .txt.SetLabel( str (val)) def main(): ex = wx.App() Example( None ) ex.MainLoop() if __name__ = = '__main__' : main() |