[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Update QT GUI Label from Embedded Python Block
From: |
Phil Wiggum |
Subject: |
Re: Update QT GUI Label from Embedded Python Block |
Date: |
Thu, 8 Jul 2021 14:44:56 +0200 |
Hi Marcus,
I solved my Label issue with a 'Python Snippet' as follows:
Properties of Python Snippet:
- Section of Flowgraph: Main - After Init
- Code Snipet: self.epy_block_0.set_parent(self)
And in my 'Python Block' added set_parent function.
'Python Block' code:
class blk(gr.sync_block):
def __init__(self ):
gr.sync_block.__init__( self, name='Embedded Python Block',
in_sig=[np.float32], out_sig=None )
def set_parent(self,parent):
self.parent=parent
self.parent._label_label.setText("10MHz") #label updated here
def work(self, inp, out):
return 0
Now about my blocks and the my real problem I'm try solve in Gnuradio!
I would like to detect a peak frequency in a FFT plot and show that frequency
value in my QT GUI Label.
So far I done following:
SDR -> Frequency Xlating FIR Filter (Decimation:1,
Taps:firdes.low_pass(2,smprate,bw,bw/5,6), Center:100K, Sample Rate:5M) ->
Rational Resampler (Interpol:100k, Decimat: 5M, Taps: Fract BW: 0) *-> QT GUI
Frequency Sink.
That works nice and I get visible peak frequency.
And now my attempt to get the value of that peak frequency into my GUI Label.
*-> Log ower FFT -> Max -> Python Block
I don't get particular far. The python code seems to produce overruns and can't
keep up with the amount of data.
Is it right to say that all 'work' functions in all blocks are called
synchronously even if no data has changed.
Do you have any suggestion of blocks that I should use for detecting the FFT
peak frequency?
/Thanks
Phil
> Hi Phil,
>
> can't do that! The label can only be changed by calling setters in Python that
> are not in
> the namespace you (directly) have access to in your block (you can hack
> together things
> where you just hard-code the top_block's name, but uhggggh ugliness).
>
> Also, sounds like the right job, but the wrong tool. Your block seems to be
> something like
> a decimator, i.e. it takes in N samples and produces 1 value. Is that right?
>
> Best regards,
> Marcsu
>