from wxPython.wx import *
import Numeric
import time

points = 2000
width = 5

class myframe(wxFrame):
	def __init__(self):        
		wxFrame.__init__(self, NULL, -1, 'test', wxDefaultPosition, (500,500))
	
		array1 = Numeric.fromfunction(lambda X: 250*Numeric.cos(X)+250, (points,))
		array2 = Numeric.fromfunction(lambda X: 250*Numeric.sin(0.78*X)+250, (points,))
		self.array = Numeric.transpose(Numeric.array([array1,array2]))
		self.SetBackgroundColour(wxNamedColor('white'))
		self.bmp = wxEmptyBitmap(500,500,-1)
		EVT_LEFT_DOWN(self, self.OnDraw)
		EVT_CLOSE(self, self.OnQuit)
		
	def OnDraw(self, event):
		dc = wxMemoryDC()
		dc.BeginDrawing()
		dc.SelectObject(self.bmp)
		dc.Clear()
		dc.SetPen(wxPen(wxNamedColor('red'),width))
		start = time.clock()
		dc.DrawLines(self.array)
		end = time.clock()
		print end-start
		dc.EndDrawing()
		scr = wxClientDC(self)
		scr.BeginDrawing()
		scr.Blit(0,0,500,500,dc,0,0,wxCOPY,0)
		scr.EndDrawing()
		
	def OnQuit(self, event):
		self.Destroy()
	
class MyApp(wxApp):
	def OnInit(self):
		frame = myframe()
		frame.Show(true)
		return true
app = MyApp(0)
app.MainLoop()
