]> git.saurik.com Git - wxWidgets.git/blob - wxPython/tests/test_stepColours.py
don't remove the tools we hadn't added to the toolbar (replaces patch 1660201)
[wxWidgets.git] / wxPython / tests / test_stepColours.py
1 import wx
2 import wx.lib.colourselect as cs
3 import wx.lib.imageutils as iu
4
5 class 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
51 app = wx.App()
52 frm = wx.Frame(None, title="Stepping Colours")
53 pnl = TestPanel(frm)
54 frm.Show()
55 app.MainLoop()
56