[Top][All Lists]

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

Re: Variable Config Read and Write Questions

From: Jeff Long
Subject: Re: Variable Config Read and Write Questions
Date: Mon, 29 Nov 2021 19:31:12 -0500

The Variable Config is definitely a strange one, when used as you are using it (read and write to runtime-selectable sections). Here's the code it generates for handling a change in section (e.g., toggling between 40 and 80 in your example). I've created two config variables, freq and lna.

    def set_section(self, section):
        self.section = section
        self._freq_config_config = configparser.ConfigParser()
        if not self._freq_config_config.has_section(self.section):
        self._freq_config_config.set(self.section, 'freq', str(self.freq))
        self._freq_config_config.write(open('/tmp/testconfig.ini', 'w'))
        self._lna_config_config = configparser.ConfigParser()
        if not self._lna_config_config.has_section(self.section):
        self._lna_config_config.set(self.section, 'lna', str(self.lna))
        self._lna_config_config.write(open('/tmp/testconfig.ini', 'w'))

which says it will do exactly what you're seeing. This is the first time I've heard of the block, actually, so I'm sure it's not getting much attention!

I'll put in an Issue on this. You should probably find another way to do what you are thinking of, since I don't think this will be addressed right away. Thanks for the report.

On Mon, Nov 29, 2021 at 6:22 PM Elmore's <wa4ywm@comcast.net> wrote:
Variable Config
ID: I_image_config
Section: image_sections[image_chooser]
Option: I_image_correct
Write Back: I_Gain
GUI Range
ID: I_Gain
Default: I_image_config
I found a question similar to this one on the forum but no one answered it so I hope I can get a response to this one.
I have shown above my configuration for two blocks in my flowgraph.
I wish to write to and read from an INI file with 5 sections.
I can successfully write the value of I_Gain to I_image_correct in a single section when I make an adjustment to the I_Gain Range control. I want to use a Chooser with the ID: image_chooser to select another section to write a value of I_Gain to that section. However, the Chooser callback writes the current value of I_Gain immediately to the file without my making a change to I_Gain. This is a major problem if I wish to select a Section that I had already stored a value in. Whatever the current value of I_Gain happens to be is written to the Section. For example: I change I_Gain to 1.1 for Section 40. I then select Section 80 which immediately upon selection has 1.1 written to it. I then select I_Gain = 1.5 which stores that value in Section 80. I then select Section 40 in hopes of using I_Gain = 1.1 but find that in the process of selection the value of I_Gain has changed to 1.5. This makes no sense since it defeats the purpose of saving a configuration in a file.
How do I save parameters to different sections without the sections being overwritten?
The other main issue is how do I read from the file so that I can set I_Gain when the Section is selected? I don’t see how to do this. The only time I have seen the file read is on initialization. I presume this is due to the fact that I set the default value of I_Gain to I_image_config. I need to to be able to read a value on demand.
By the way, I have 3 parameters to save and recall in each of 5 Sections.
Any help will be greatly appreciated. I have been wrestling with this issue for quite some time.

Virus-free. www.avg.com

reply via email to

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