gr.sync_block.__init__( self, name="image_sink1",
in_sig=[ numpy.complex64 ],
out_sig=None)
pyplot.figure()
pyplot.ion()
pyplot.show()
self.axes1 = pyplot.gca()
#self.win = self.axes1.figure.canvas.manager.window
#self.win.after(100,animate)
self.completed = False
self.img2 = numpy.zeros( (150,150,4), numpy.uint8 )
self.coordinate = self.coordinate_stream()
def coordinate_stream(self):
for y in range(150):
for x in range( 0, 150, 2 ):
yield y,x
def work(self, input_items, output_items):
in0 = input_items[0]
if self.completed:
return -1
for sample1 in in0:
try:
y,x = next( self.coordinate )
if sample1.real > 0:
self.img2[y,x] = numpy.array([255,255,255,255])
else:
self.img2[y,x] = numpy.array([0,0,0,255])
if sample1.imag > 0:
self.img2[y,x+1] = numpy.array([255,255,255,255])
else:
self.img2[y,x+1] = numpy.array([0,0,0,255])
except StopIteration:
print "Receiver side completed!"
self.complete = True
self.axes1.imshow( self.img2 )
self.axes1.figure.canvas.draw() # or, pyplot.draw(), both gives error !!!
return in0.size