When a device is selected from the list, its configuration is loaded
into the tmpcfg buffer. When this failed due to there being no
configuration in the device, the ensuing exception prevented the device
from being configured by the GUI.
Now we explicitly silence the KeyError when loading configuration. The
tmpcfg is still valid, so it can be read and manipulated just as always.
Since I was clever enough to implement equality testing for SinkConfig,
the Save button's visibility can now be checked with a single comparison
of two SinkConfig objects. Wonderful!
Now instead of editing configuration on the device, we keep a SinkConfig
locally and manipulate it there. Much less error-prone, and things can
still get even better than they are now.
There was a bug where a device could end up being programmed with 0
current if the device was disconnected and reconnected while editing its
configuration. I thought of several solutions for this, but concluded
that the right one would really be to go ahead with my original plan to
kick the user out of the configuration screen when the device was
unplugged. As usual, the implementation could be better, but it works.
Previously, we updated the Save button before sending the commands.
This meant that if the command failed, the save button was still updated
before the error dialog appeared, which was a bit odd. Now that's
fixed.
Before now, if an error occurred when sending a command, it passed
silently. This is a Bad Thing™, so it's been fixed. Now if there's an
error, an error dialog appears with some information about what
happened. If the error occurred on the Sink page, the program goes back
to the device list after the error dialog is closed.
Before now, the Save button appeared when the voltage and current
widgets changed their value. If they were then changed back to the
original values, the Save button was still visible, allowing unnecessary
wear on the flash. (the sarcastic horror!)
Now, the Save button is only shown when the voltage and current are not
both at their saved values. A minor tweak, but we're closer to the
original design now.
Previously, the SelectListStore directly modified the GUI in its
update_items method, which was really just poor form.
This has been corrected by creating a new SelectList to encapsulate all
the GUI elements from the select-stack downward. This handles showing
the select-none or select-frame elements as appropriate, as well as
adding the list item separators. It's much nicer than the old way, if I
do say so myself.
Previously, we refreshed the list by completely erasing it and building
a new one. While simple, it caused some obnoxious visual glitches, and
I could imagine some more serious problems it might have caused as well.
Now we remove only the devices that don't exist any more, and add only
those that we don't already know about. Much better for the user
interface, but O(n^2). Oh well, I doubt anyone will have enough PD
Buddies connected at once for that to matter much.
Previously, the device list only loaded once on startup. This was poor
behaviour, as devices can be attached and detached at any time.
Now the attached devices are polled once per second, and the list is
updated accordingly. The code behind it is a bit messy because the
list model interacts directly with parts of the GUI, but it works
pretty well nevertheless. There's no mechanism to kick us out of the
configuration screen if the device we're configuring is detached, but
this can be addressed later. For now, I'm reasonably happy with this
new feature.
It had been stretched vertically due to the two text labels stretching
the whole grid. Now the button is square, because it's set to align
center rather than fill.
It's by no means wonderful internally, but to a large extent it works.
The list functionality is still untested, since I won't be able to have
two PDB Sinks connected to my computer at once until tomorrow. But for
now, a neat little GUI.