discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do you write to a widget from a Python file in an OOT?


From: Jeff Long
Subject: Re: How do you write to a widget from a Python file in an OOT?
Date: Sun, 24 Oct 2021 11:26:49 -0400

If you have an Entry called "gain", then a set_gain() function is automatically generated in the top block. Calling this function will set the variable and update the Entry. However, this set_gain(), and other functions in the top level Python code, should not really be called from a work() function. You would need to create a Python thread that is in charge of updating this (and maybe other?) variables, and an event queue.

Another possibility is to use the Function Probe block. This method would be polling-based. You block would set an internal variable when it does whatever it does with the file. Your block would have a get_gain() function, too. The Function Probe block can be set up to call get_gain() at some interval, and the result will be kept in the variable named after the Function Probe. So, if you call the function probe "gain_from_file", then you can put "gain_from_file" as the value in the Entry. This should work, but I haven't tried it.

On Sun, Oct 24, 2021 at 11:08 AM Elmore Family <wa4ywm@comcast.net> wrote:
Jeff,
 
Thanks for the reply.
 
I see that I can set the value in the GUI Entry to the value selected by the Chooser.
 
However, what I want to do is set the GUI Entry value to any arbitrary value from the Chooser callback in test.py. My ultimate goal is to read a value from a file and set the GUI Entry using a callback from a “Get File” button. Or perhaps there is some other means that I may not be aware of.
 
Thanks,
Jim
 
From: Jeff Long
Sent: Saturday, October 23, 2021 9:27 PM
Subject: Re: How do you write to a widget from a Python file in an OOT?
 
Don't try to set the GUI display from within a block, if that's what you are trying to do. If you have an entry called "I_Gain", then there should already be a set_I_GAIN() function in the top block.
 
How to call set_I_Gain() depends on what you are trying to do. If you want to set it over the network or from another process, follow Paul's recommendation and use XMLRPC.
 
But, from the image attached, it looks like you just want to set the gain via a chooser and display it in the entry? In that case, just put "Change_I_Gain" (the name of the chooser) in the value field for I_Gain and it should be set whenever you choose a new value.
 
On Sat, Oct 23, 2021 at 9:03 PM Elmore's <wa4ywm@comcast.net> wrote:
I had asked this question earlier in a different form but did not receive a response so I am trying a different approach using a greatly simplified flowgraph to illustrate my point.
 
I have attached the three pertinent files.
 
Test is an OOT module. I want to be able to trigger a callback set_IGain (which works) and write a value to the I_Gain GUI Entry (which doesn’t work). I have tried various imports, setting of variables and any other scheme that I could think of. I have not included any specific piece of code in the callback.
 
This seems like such a simple thing to do but nothing works. I get various errors or nothing is written when I eliminate the errors. I must be missing a basic point.
 
Please help me get over this hump.
 
Jim

Virus-free. www.avg.com

reply via email to

[Prev in Thread] Current Thread [Next in Thread]