[code]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy
from gnuradio import gr
import wx
class plotter1(gr.sync_block):
def __init__(self, title, samp_rate, V_scale, T_scale, adjust):
gr.sync_block.__init__(self,
name="plotter1",
in_sig=[ numpy.float32 ],
out_sig=None )
self.V_scale = V_scale
self.T_scale = T_scale
self.x = 0
self.y = 0
self.width = 1000
self.height = 500
self.data = "">
self.app = wx.App(False)
self.frame = wx.Frame( None, title=title, size=(self.width, self.height) )
self.panel = wx.Panel(self.frame)
self.panel.Bind(wx.EVT_PAINT, self.myPaint)
def myPaint(self, event):
dc =wx.PaintDC(event.GetEventObject())
dc.Clear()
dc.SetPen(wx.Pen( "BLUE", 1 ))
for i in range(len(self.data)):
newx = self.x + 1
newy = self.height/2.0 - self.data[i] * 30.0 / self.V_scale
dc.DrawLine( self.x, self.y, newx, newy )
self.x = newx
self.y = newy
if self.x >= self.width:
self.x = 0
break
def work(self, input_items, output_items):
self.data = "">
#self.frame.Refresh() # this cause the flow graph to freeze even more seriously
self.frame.Show(True)
#self.app.MainLoop() # remove this to avoid blocking
return 0
[/code]