]>
Commit | Line | Data |
---|---|---|
cbfc9df6 RD |
1 | import wx |
2 | ||
3 | class Canvas(wx.Panel): | |
4 | def __init__(self, parent): | |
5 | wx.Panel.__init__(self, parent) | |
6 | self.Bind (wx.EVT_PAINT, self.OnPaint) | |
7 | self.bkg_brush = wx.Brush((190,190,255)) | |
8 | self.v_pos = 100 | |
9 | ||
10 | def OnPaint(self, evt): | |
11 | dc = wx.PaintDC(self) | |
12 | dc = wx.GCDC(dc) | |
13 | dc.SetBackground(self.bkg_brush) | |
14 | dc.Clear() | |
15 | dc.DrawEllipticArc(100, 200, 200, 200-self.v_pos, 90,270) | |
16 | dc.DrawLine(100, 100, 100, 300) | |
17 | ||
18 | ||
19 | class MyFrame(wx.Frame): | |
20 | def __init__(self): | |
21 | wx.Frame.__init__(self, None, title="DrawEllipticArc") | |
22 | self.SetSize((640,480)) | |
23 | self.canvas = Canvas(self) | |
24 | self.slider = wx.Slider(self, minValue=0, maxValue=100) | |
25 | box = wx.BoxSizer(wx.VERTICAL) | |
26 | box.Add(self.canvas, 1, wx.EXPAND) | |
27 | box.Add(self.slider, 0, wx.EXPAND) | |
28 | self.SetSizer(box) | |
29 | self.Show() | |
30 | self.CenterOnScreen() | |
31 | self.slider.Bind (wx.EVT_SLIDER, self.OnSlide) | |
32 | ||
33 | def OnSlide(self, evt): | |
34 | self.canvas.v_pos = 100+self.slider.GetValue() | |
35 | self.canvas.Refresh(False) | |
36 | ||
37 | ||
38 | if __name__ == "__main__": | |
39 | app = wx.App(0) | |
40 | frame = MyFrame() | |
41 | app.MainLoop() |