radiology-research / ispy2_mri

GUI to enter info on incoming MRI's for ISPY2 into database
GNU General Public License v3.0
0 stars 0 forks source link

Handling of ComboBox mismatches #11

Open RossBoylan opened 11 months ago

RossBoylan commented 11 months ago

The Problem

When reading data from a text file the program inserts the text into various widgets, some of which are a BComboBox or BSiteComboBox. Those widgets, and often (?) the underlying db, permit only a limited set of choices. Sometimes the text does not match any of them. This seems to produce erratic behavior, sometimes leaving the widget blank and sometimes with a random value (esp the first Site on the list, Georgetown).

There is no explicit warning to the user that anything has gone wrong.

At one point, maybe when the fields were editable, there was also a problem that they could show text that didn't correspond to any allowed choice. Saving this might appear to work, but probably left NULL in the database.

This is in v0.0.7

Ideal Behavior

  1. Provide a single popup at end listing all problems fields, including the text attempted to insert.
  2. In the hover over the widget, show the text from the file.
  3. Don't silently fail to write an apparent selection to the database.

Or, rather than 2, show the text from the file in the widget in a way that graphically indicates there is a problem, e.g., in red, or with a big colored border on the box.

RossBoylan commented 11 months ago

As of v0.1.0 prerelease [7be74c2 2023-10-31] only Visit and Site have changed; they were the main problem areas, but there are other ComboBox widgets, and they could throw exceptions.

For all Combo Widgets

  1. Added tooltip if nothing is selected, saying to make a selection.
  2. If a value inserted via fromtext() does not match any existing choices a) If it is empty, set currentIndex to -1 and add tip saying to make a selection. b) Otherwise
    • set background to yellow, text to red
    • display a ? and the attempted value in the box as placeholderText
    • put a notice of recognition failure in the tooltip.
    • Raise UnexpectedInputError c) A valid selection undoes all the special handling in b).
  3. This applies to BComboBox and BSiteComboBox.

Limitations

  1. Only Site and Visit setting trap the exceptions. They ignore them.
  2. So errors in other widgets will crash the program.
  3. Needs more testing, esp what happens if I leave one of the yellow fields in place.
  4. Current code in BreastForm.readFile() often does not use fromtext() to update the values, and so will bypass all above (except that restoring regular values will undo weird coloring and tooltips, since it's tied to signals.
  5. Most of the original "Ideal Behavior" remains unimplemented, and much is reconsidered. See next section.

Original Ideal Behaviors: Current Status

  1. Provide a single popup at end listing all problems fields, including the text attempted to insert. Not done, and not clear it needs to be done. The colorizing and tooltips seem to make it pretty obvious.
  2. In the hover over the widget, show the text from the file. Not done, because better alternatives were done. Put the text from the file in placeHolderText, which provides a more obvious alternative since it is always visible. Tooltips are now provided to offer additional information in most states. Mostly I implemented the alternate scheme (mentioned at the end of the original section) using coloring to highlight the problems and solutions.
  3. Don't silently fail to write an apparent selection to the database. What I have done probably mostly meets this since the invalid text is now in placeHolderText. The old problem arose because the editText might not match any of the items on the list, but it looked like any other selection. More testing required.

To Do

  1. Regularize handling of setting of all ComboBoxes from the file in BreastForm.readFile(). Use fromtext() uniformly and trap errors uniformly.
  2. Test.
  3. Consider more graphical tweaks to highlight mismatchesL thicker box boundaries, different fonts ...
  4. Consider a popup listing all problems if any of the values don't match (original Ideal Behavior 1).
RossBoylan commented 11 months ago

The placeholder text is not being cleared out.

@Teffany agrees: no point in popup with all the errors. No other graphical tweaks needed.

RossBoylan commented 10 months ago

Where we stand on the previous to do:

  1. Regularize handling of setting of all ComboBoxes from the file in BreastForm.readFile(). Use fromtext() uniformly and trap errors uniformly. Done
  2. Test. Needs more; some done. Esp if try to save with error selection.
  3. Consider more graphical tweaks to highlight mismatches: thicker box boundaries, different fonts Unnecessary.
  4. Consider a popup listing all problems if any of the values don't match (original Ideal Behavior 1). Unnecessary.

Leaving open for now because of 2.