Enable check box to work with drop down list

What I’m trying to do:
I have a drop down list with several countries and a check box with time lapse command.

When I change the drop down list to some country and check the checkbox to operate the time lapse every thing is working great.

However while the check box is still checked I am changing to a different country in the drop down list, now I need to recheck the checkbox, otherwise the GUI doesn’t know about it.
How can I make a general statement that no matter what happens as long as the check box is checked the GUI need to enable that option?

I’m guessing that you have an event-handler attached to the checkbox, and are doing work as a result of the box becoming checked. As opposed to testing the state of the box at some other place and time.

But that’s just a guess. Seeing your actual code here, if you can share it, would go a long way towards clarifying the current state of affairs, including any implicit (unstated) requirements that your code is trying to meet.

You are correct but how can I avoid of checking in each element in the GUI the state of the checkbox?

There’s a good chance that you can automate that checking, via Data Binding. But without seeing your GUI, and its code, it’s hard to get any more concrete than that.

Here is a code snippet, let me know if that is sufficient or you want more parts of it:

def check_box_2_change(self, **event_args):
    """This method is called when this checkbox is checked or unchecked"""
    if self.check_box_2.checked == True:
      if (self.drop_down_1.selected_value == 'X'):
        html_name = "time_lapse_X"
        self.html_mechanic_for_gui(html_name)
        self.data_grid_1.visible = False

Thanks. Part of this looks like a good candidate for Data Binding.

For example, in the IDE, you could bind
self.data_grid_1.visible
to the expression
not (self.check_box_2.checked and self.drop_down_1.selected_value).

To re-evaluate this binding (and re-set the value of self.data_grid_1.visible), you can just call self.refresh_data_bindings(). When to call it? Whenever check_box_2 or drop_down_1 changes state. You already have an on-change handler for check_box_2, so a similar handler for drop_down_1 should be pretty self-explanatory.

If your Data Binding expression needs to be really complex, you can put that code in a function, and have the Data Binding expression call it.

My mistake on the code it should be like that:

def check_box_2_change(self, **event_args):
    """This method is called when this checkbox is checked or unchecked"""
    if self.check_box_2.checked == True:
      if (self.drop_down_1.selected_value == 'X'):
        html_name = "time_lapse_X"
        self.html_mechanic_for_gui(html_name)

I would like the self.html_mechanic_for_gui(html_name)
To work any time the check_box_2 is enabled and operate according to what drop down list 1 value is.

How many times per second should html_mechanic_for_gui be called? Or is there some specific trigger event?

Only when the name of the country in the drop down list 1 change.
Currently I need to choose country in drop down list 1 and recheck the box in order it to trigger.

Have you tried using the drop-down’s on-change event?

Hint: you can use both. And you can use the same handler function for both events.

Yes and they work, but it has to work with conjunction to the checkbox. So if I change the drop down list to some other country it ignores the state of the checkbox, and represent something else. Only when I recheck the checkbox the GUI “notice” the checkbox state.

It sounds like you have different code in your drop-down’s on-change event handler, OR you don’t have any event handler connected to your drop-down component.

You are right.
If the checkbox is not checked then changing countries in the drop down present one thing.
If the checkbox checked then a different map should appear.
So for example let’s say I want to see a colorful map of Australia, USA.
Changing the drop down will show either Australia or USA color map.
However checking the check box should show the same place but in black and white.
The problem is that when changing the countries the colorful map triggered and the checkbox is ignored.