Occasionally I want a slider to control 2 values, such as defining a date range or clipping parameters. In the past, I would just create 2 sliders using the RangeEditor. It worked fine, but took up 20 or so pixels and didn’t really visually show the relationship between the 2 variables.
BoundsEditor screen shot
Qt and PyQt made it ridiculously easy to create the control I wanted. I started off transcoding the Qt QSlider C++ code into python, then added the second slider. In all, its about 180 lines of Python, less than 50 of it specific to the seconds slider.
I also wrapped this into a Traits editor, which can be found at enthought.traits.ui.qt.extra.bounds_editor.BoundsEditor
ETS contains a lot of nice features which don’t get any press, many of which aren’t event well known in the Enthought office. Today I thought I’d show off the ProgressDialog class I wrote more than a year ago.
The ProgressDialog class is intended to have an API similar to QT and Java’s progress dialogs has many of the same features:
- Optionally show estimated time remaining
- Supports indeterminate progress where the total number of steps is not known
- Cancel and skip buttons
- Automatically closes for determinate instances
This is all the code needed to do a dialog while doing a simple loop (the entire example can be found here):
progress = ProgressDialog(title="progress", message="counting to %d"%t,
max=t, show_time=True, can_cancel=True)
for i in range(0,t+1):
(cont, skip) = progress.update(i)
if not cont or skip:
Here’s what the progress dialog looks like using the WX backend (yes, there is a QT4 backend too)