Graph plotting using wxPython

Dear Sir,

I am trying to build a custom block to plot graphs. For starting this
block is similar to the block of “WX GUI Scope Sink”.
I started with wxPython, the code is below.
The problem is, this block causes the whole flow graph to “freeze”.
So the question is, how to program this block correctly?
(I am new to wxPython)

Thanks & regards,

Python code of the block:

        #!/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, 
                    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
       = []

         = wx.App(False)
                self.frame = wx.Frame( None, title=title, 
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.SetPen(wx.Pen( "BLUE", 1 ))

                for i in range(len(
                    newx = self.x + 1
                    newy = self.height/2.0 -[i] * 30.0 /

                    dc.DrawLine( self.x, self.y,  newx, newy )
                    self.x = newx
                    self.y = newy

                    if self.x >= self.width:
                        self.x = 0

            def work(self, input_items, output_items):
       = input_items[0][:]
                #self.frame.Refresh()   # this cause the flow graph to
freeze even more seriously
         # remove this to avoid blocking

                return 0

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs