twVolc / PyCamPermanent

Permanent PiCam (SO2) installation project software
GNU General Public License v3.0
1 stars 2 forks source link

Add option to set config loaded on startup #96

Closed ubdbra001 closed 7 months ago

ubdbra001 commented 7 months ago

Allows users to define a yml file that will be loaded when PyCam starts. GUI elements may need a bit of modification so they look okay.

twVolc commented 7 months ago

Reverting to the original default doesn't work. I think because the settings of the new default file seem to overwrite the ./pycam/conf/processing_settings_defaults.yml file so when you revert back to this file the settings have all changed in it so it doesn't revert back to Villarrica data.

twVolc commented 7 months ago

The issue might be that I clicked "Save changes" after selecting the new config file, perhaps I wasn't supposed to? Maybe this then overwrites the current settings into the default settings. Maybe we need to create a processing_settings_defaults_safe.yml file that doesn't ever get edited and the Revert back button changes the file name to this one? THat way we always have an untouched default we can change to even if we've edited the other default file?

ubdbra001 commented 7 months ago

Ah yeah, I see what's happened. Okay, I'll have a quick think about how best to do that.

ubdbra001 commented 7 months ago

Just a thought: Do you think having the 'save as default' buttons is useful anymore?

twVolc commented 7 months ago

Just a thought: Do you think having the 'save as default' buttons is useful anymore?

Arguably not... There could be the odd situation where it would be nice to just update one thing, but I'm not sure how that would all interact with the fact we can now change the location of the config file, so they might be redundant and just a bit confusing now? I think it's probably not worth the effort of changing things right now, but I'll add an issue to think about those buttons.

ubdbra001 commented 7 months ago

The revert button now overwrites the processing_setting_defaults.yml with the contents of a backup, and then changes the path stored in self.default_conf_location.

twVolc commented 7 months ago

That revert button works. But the Save changes button now throws an error

Traceback (most recent call last):
  File "C:\Users\gg1tcw\.conda\envs\pycam\lib\tkinter\__init__.py", line 1892, in __call__
    return self.func(*args)
  File "C:\Users\gg1tcw\Documents\PythonProjects\PyCamTests\PyCamPermanent\pycam\gui\menu.py", line 551, in <lambda>
    update_butt = ttk.Button(self.load_frame, text='Save changes', command=lambda: self.set_defaults(self.frame))
  File "C:\Users\gg1tcw\Documents\PythonProjects\PyCamTests\PyCamPermanent\pycam\gui\misc.py", line 313, in set_defaults
    self.pyplis_worker.save_config(filename, subset=self.vars.keys())
  File "C:\Users\gg1tcw\Documents\PythonProjects\PyCamTests\PyCamPermanent\pycam\so2_camera_processor.py", line 442, in save_config
    with open(full_path, "w") as file:
FileNotFoundError: [Errno 2] No such file or directory: './pycam/conf/processing_setting_defaults.yml\\process_config.yml'

I'm kind of wondering whether we should actually remove the Save changes button and all of the rest of that start-up stuff, and just have start-up defined by the config file that is selected?

ubdbra001 commented 7 months ago

I just spotted that too, and then spotted another underlying issue: The gather_vars() function for LoadFrame doesn't actually do anything. So, the options in that config startup GUI window don't actually get saved by pressing the 'Save changes' button. Either fixing it or removing the buttons is going to require a little time to do so I suppose it will depend on which you think is a better use of my time?

twVolc commented 7 months ago

I think just remove all of that code, it's obsolete now that we can save and load config files. For speed it should be as simple as just deleting the all of the GUI stuff in generate_frame() other than the initial frame and the bits you have added. For now I don't think it's worth taking time to work out which other bits of code become redundant (e.g. properties and functions within that class), just removing all of the widgets is probably fine

ubdbra001 commented 7 months ago

Okay, all removed.

twVolc commented 7 months ago

This looks good to me. Shall I merge?

ubdbra001 commented 7 months ago

Sure!