Closed ajeddeloh closed 3 years ago
Reworked dockpanels too. Hopefully its clear what's going on in the new code. As a bonus by using the QDoubleValidator
we don't even need to worry about data entered not being numeric.
I added some more comments, hopefully it's more clear now.
setitem is needed instead of setattr for when the parent of the part of the model being set is a list (and thus the "field" being set is a list index). This is used when setting things in the wavelengths
list.
Use
float()
instead ofeval()
to parse user input. This prevents a lot of crashes and generally insures the data entered is numeric.It does prevent the user from doing calculations in the text box however.
Originally I thought
eval()
was being used to allow referencing variables defined elsewhere, but then I learned thateval()
does not include any variables in the environment by default.Also switched from the
7.4f
format to.7g
which is probably what users expect.Fixes https://github.com/mjhoptics/ray-optics/issues/13
PR marked as draft until I hunt down all the text boxes that act the same way.