Skip to content

Code: Proposal for YML editor (implemented and obsolete)

lneuhaus edited this page Jul 5, 2017 · 1 revision

To edit the yml config file sections while the program is running, I see 2 possibilities:

  1. Make a YmlAttribute and a YmlWidget that complies with the general attribute<->attribut_widget logic. Moreover, if we want to edit different states of a module, a possible mechanism would be to implement 2 attributes:
  • _yml_content # YmlAttribute, the actual content to modify
  • _yml_current_state_edit # which state is affected when _yml_content is touched
  1. Another possibility is to just use set/get functions:
  • module.set_yml(new_yml, state=None) # changes the yml code for state "state". If state is None, changes the current yml section and reloads it with _load_setup_attribute()
  • module.get_yml(state=None) # get the yml code for state state (current section if state is None) Then, the BaseModuleWidget would just create the dialog to display and save yml code when the user requests it.

I must say that I really prefer the second option because option 1 would be very hard to understand.

Moreover, we need to define if the YmlWidget is blocking for the rest of the program (I think it is called "modal"). That would avoid some naughty bugs, such as opening a yml editor for a stage while another editor is already open for the whole sequence. ---> since the stage is a sub-section of the sequence, one would have to find complicated mechanisms to keep both "in-sync".

so options are:

  1. the blocking scenario: the whole gui is frozen while editing. There would simply be a button "save and close" at the bottom of the YmlEditor...

  2. Keep the yml editors non-blocking and add a button "refresh" that reloads the current file content next to the button "save" that saves the content to the file-->I think that would be at the same time simple, clear and functional.

  3. Make a big mess with timers and/or hooks in the memory trees to make sure the file content is always reloaded in the YML editor (needless to say it is not my favorite).