user interface - Pythonic way of applying changes on closing a dialog window -


I could not find any useful resources for this topic. I hope I can get some guidance here.

I have created a dialogue window using Glade, GTK (3.10) and Python 3. In this, about 30 options can be changed. I set the full dialog window in the init function and set the options to the current value. I also define a bool-variable that stores if any widget has changed:

  self.settings_changed = False  

so For each widget, I set up a function that catches the "change-signal" and does the following:

  def on_checkbutton_line_width_changed (auto, widget): set to #setting_changed true so that something in the dialog Replace self.settings_changed = True # store the variable value in the temporary variable ST.temp_checkbutton_value = widget.get_active ()  

Now when I A. I click "Cancel" on the dialogue, I do not apply any temporary values. But when I click on "Apply" I want all the variables to be applied. But this is my problem: Only variables with only a few variables are present and all others will access many attribute errors, because the temporary variable does not exist.

I tried to avoid errors by leaving several tasks and avoiding errors:

  Try: excluding self.dataclass.set_checkbutton (self.temp_checkbutton_value): pass < / Code> 

Is there a simple (and short) way to resolve this? I think that after clicking on "Apply", there should be a way to queue the changes executed after each other, but my potato-like dragon skills are not able to help me solve it till now.

Here's an example that can help:

  class MyWidget: def __init __ (self): self (self, new_name): self.changes.append (('change_name', new_name) def change_color (auto, new_color): self Changes.append (('change_color', new_color) DEF def_changes (self): for changes in self.changes: print ("{} - {}". Format (change [0], change [1])  

Alternatively you can do something like this:

  self.changes.append (lambda: self.dataclass.set_checkoutbutton (value))  

and then the changes will apply:

  for changes in self. Change: change ()  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -