]> git.saurik.com Git - wxWidgets.git/blame - wxPython/tests/test_stepColours.py
No animate contrib anymore
[wxWidgets.git] / wxPython / tests / test_stepColours.py
CommitLineData
fd363e1a
RD
1import wx
2import wx.lib.colourselect as cs
3import wx.lib.imageutils as iu
4
5class TestPanel(wx.Panel):
6 def __init__(self, *args, **kw):
7 wx.Panel.__init__(self, *args, **kw)
8
9 self.colour = wx.NamedColour("purple")
10
11 self.cpnl = wx.Panel(self, size=(100,100), style=wx.SIMPLE_BORDER)
12 self.slider = wx.Slider(self,
13 minValue=0,
14 value=100,
15 maxValue=200,
16 size=(300, -1),
17 style=wx.SL_HORIZONTAL | wx.SL_LABELS)
18 csel = cs.ColourSelect(self, colour=self.colour)
19
20 sizer = wx.BoxSizer(wx.VERTICAL)
21 sizer.Add(self.cpnl, 0, wx.ALL, 20)
22 sizer.Add(self.slider, 0, wx.LEFT, 20)
23 sizer.Add(csel, 0, wx.ALL, 20)
24 self.SetSizer(sizer)
25
26 self.slider.Bind(wx.EVT_SCROLL, self.OnSliderChanged)
27 self.Bind(cs.EVT_COLOURSELECT, self.OnColourSelect)
28
29 self.UpdatePanel()
30
31
32 def UpdatePanel(self):
33 val = self.slider.GetValue()
34
35 colour = iu.stepColour(self.colour, val)
36
37 self.cpnl.SetBackgroundColour(colour)
38 self.cpnl.Refresh()
39
40
41 def OnSliderChanged(self, evt):
42 self.UpdatePanel()
43
44
45 def OnColourSelect(self, evt):
46 self.colour = evt.GetValue()
47 self.UpdatePanel()
48
49
50
51app = wx.App()
52frm = wx.Frame(None, title="Stepping Colours")
53pnl = TestPanel(frm)
54frm.Show()
55app.MainLoop()
56