1
- #!/usr/bin/env python2.4
1
+ #!/usr/bin/env python
2
2
3
3
import wx
4
4
import numarray
5
5
from numarray import random_array
6
- import RandomArray # the Numeric version
6
+ import RandomArray # the Numeric version.
7
7
import time
8
8
9
9
12
12
13
13
## Make some random data to draw things with.
14
14
MaxX = 500
15
- LinesPoints = random_array .randint (1 , MaxX , (NumLinePoints ,2 ) )
16
- #PointsPoints = random_array.randint(1, MaxX, (NumPointPoints,2) )
17
- PointsPoints = RandomArray .randint (1 , MaxX , (NumPointPoints ,2 ) ) # Numeric
18
-
15
+ LinesPoints = random_array .randint (1 , MaxX , (NumLinePoints , 2 ))
16
+ #PointsPoints = random_array.randint(1, MaxX, (NumPointPoints, 2))
17
+ PointsPoints = RandomArray .randint (1 , MaxX , (NumPointPoints , 2 )) # Numeric.
19
18
20
19
21
20
class TestFrame (wx .Frame ):
22
21
def __init__ (self ):
23
22
wx .Frame .__init__ (self , None , - 1 , "DrawLines Test" ,
24
- wx .DefaultPosition ,
25
- size = (500 ,500 ),
26
- style = wx .DEFAULT_FRAME_STYLE | wx .NO_FULL_REPAINT_ON_RESIZE )
23
+ wx .DefaultPosition ,
24
+ size = (500 ,500 ),
25
+ style = wx .DEFAULT_FRAME_STYLE | wx .NO_FULL_REPAINT_ON_RESIZE )
27
26
28
- ## Set up the MenuBar
27
+ # Set up the MenuBar.
29
28
MenuBar = wx .MenuBar ()
30
-
29
+
31
30
file_menu = wx .Menu ()
32
31
ID_EXIT_MENU = wx .NewId ()
33
- file_menu .Append (ID_EXIT_MENU , "E&xit" ,"Terminate the program" )
32
+ file_menu .Append (ID_EXIT_MENU , "E&xit" , "Terminate the program" )
34
33
wx .EVT_MENU (self , ID_EXIT_MENU , self .OnQuit )
35
34
MenuBar .Append (file_menu , "&File" )
36
-
35
+
37
36
draw_menu = wx .Menu ()
38
37
ID_DRAW_MENU = wx .NewId ()
39
- draw_menu .Append (ID_DRAW_MENU , "&ReDraw" ,"DrawAgain" )
38
+ draw_menu .Append (ID_DRAW_MENU , "&ReDraw" , "DrawAgain" )
40
39
wx .EVT_MENU (self , ID_DRAW_MENU ,self .ReDraw )
41
40
MenuBar .Append (draw_menu , "&Draw" )
42
41
@@ -46,14 +45,14 @@ def __init__(self):
46
45
47
46
def OnPaint (self ,event ):
48
47
dc = wx .PaintDC (self )
49
- dc .SetBackground ( wx .Brush ("White" ) )
48
+ dc .SetBackground (wx .Brush ("White" ))
50
49
dc .Clear ()
51
50
self .DrawLines (dc )
52
51
self .DrawPoints (dc )
53
52
54
53
def ReDraw (self , event = None ):
55
54
dc = wx .ClientDC (self )
56
- dc .SetBackground ( wx .Brush ("White" ) )
55
+ dc .SetBackground (wx .Brush ("White" ))
57
56
dc .Clear ()
58
57
self .DrawLines (dc )
59
58
self .DrawPoints (dc )
@@ -64,15 +63,15 @@ def DrawLines(self, dc):
64
63
start = time .clock ()
65
64
#dc.DrawLines(LinesPoints.tolist())
66
65
dc .DrawLines (LinesPoints )
67
- print "DrawLines Call took %f seconds" % (time .clock () - start )
66
+ print ( "DrawLines Call took %f seconds" % (time .clock () - start ) )
68
67
dc .EndDrawing ()
69
68
70
69
def DrawPoints (self , dc ):
71
70
dc .BeginDrawing ()
72
71
dc .SetPen (wx .Pen ('Red' , 2 ))
73
72
start = time .clock ()
74
73
dc .DrawPointList (PointsPoints )
75
- print "DrawPointList Call took %f seconds" % (time .clock () - start )
74
+ print ( "DrawPointList Call took %f seconds" % (time .clock () - start ) )
76
75
dc .EndDrawing ()
77
76
78
77
def OnQuit (self ,event ):
@@ -89,22 +88,3 @@ def OnInit(self):
89
88
if __name__ == "__main__" :
90
89
app = DemoApp (0 )
91
90
app .MainLoop ()
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
0 commit comments