microscope-cockpit / cockpit

Cockpit is a microscope graphical user interface. It is a flexible and easy to extend platform aimed at life scientists using bespoke microscopes.
https://microscope-cockpit.org
GNU General Public License v3.0
35 stars 26 forks source link

help in debugging configuration #892

Open carandraug opened 1 month ago

carandraug commented 1 month ago

A few weeks ago I spent a lot of time debugging an issue with the parsing of configuration files. I'm thinking it would be nice to have a window displaying the current configuration (which is the merge of multiple files). I have a proof of concept: it adds two entries on the menu bar for "View Cockpit Configuration" and "View Depot Configuration".

carandraug commented 1 month ago

checkout my configparser-frame branch (new menu entries under "File").

iandobbie commented 1 month ago

Seems to work well. Just a couple of thoughts.

1) The text window that appears on macos is tiny. I suggest we edit to have the following

text_ctrl = wx.TextCtrl(
    panel,
    value=config_str.getvalue(),
    style=(wx.TE_MULTILINE|wx.TE_DONTWRAP|wx.TE_READONLY),size=(500,500)
)

The added arbitary size gives a reasonable sized window that can be resized to be bigger if needed.

2) Can we add the current channels config to the list?

carandraug commented 1 month ago

The added arbitary size gives a reasonable sized window that can be resized to be bigger if needed.

Good point. But instead of an arbitrary size, I added the logic to resize the window to at least the size of the text or 80x24 characters.

  1. Can we add the current channels config to the list?

Possibly. I wrote the code to display a configparser and I plan to add extra bits that show the list of files that were parsed and the list of files that were attempted. So it doesn't really work for channels configuration which is always a single file and in json format. It would require some extra work.

The goal was to help in figuring out what is the final configuration and where it is coming from. Is that an issue with channels too? (location of channels file is displayed on this new cockpit config window, and we have menu entries to import and save channels to specific locations).

iandobbie commented 4 weeks ago

The added arbitary size gives a reasonable sized window that can be resized to be bigger if needed.

Good point. But instead of an arbitrary size, I added the logic to resize the window to at least the size of the text or 80x24 characters.

Much more elegant. Thanks for fixing my hack.

  1. Can we add the current channels config to the list?

Possibly. I wrote the code to display a configparser and I plan to add extra bits that show the list of files that were parsed and the list of files that were attempted. So it doesn't really work for channels configuration which is always a single file and in json format. It would require some extra work.

The goal was to help in figuring out what is the final configuration and where it is coming from. Is that an issue with channels too? (location of channels file is displayed on this new cockpit config window, and we have menu entries to import and save channels to specific locations).

No my main thought about this was to make sure we could find what was stored in the channel config. As far as I can tell the only way to do so at the moment is to export the channel and then go look at the text file. As this is already effectively displaying text files I thought it might be a simple way to add that functionality. Also I don't think it is a json file but a python dictionary.

carandraug commented 4 weeks ago

[...] Also I don't think it is a json file but a python dictionary.

It's json https://github.com/microscope-cockpit/cockpit/blob/master/cockpit/interfaces/channels.py#L151 (but they are very similar)