Archive for the 'Pyface' category

New double slider editor

Aug 26 2009 Published by Bryce Hendrix under Pyface, Qt, Traits

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

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

12 responses so far

Little known ETS features: Progress Dialog

Dec 01 2008 Published by Bryce Hendrix under Enthought Tool Suite, Pyface

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):

def task_func(t):
    progress = ProgressDialog(title="progress", message="counting to %d"%t,
                              max=t, show_time=True, can_cancel=True)
    progress.open()

    for i in range(0,t+1):
        time.sleep(1)
        print i
        (cont, skip) = progress.update(i)
        if not cont or skip:
            break

    progress.update(t)

Here’s what the progress dialog looks like using the WX backend (yes, there is a QT4 backend too)

ProgressDialog Screenshot

4 responses so far

Older posts »

Featuring Advanced Search Functions plugin by YD