[traits] RangeEditor bounds format...

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[traits] RangeEditor bounds format...

fred-2
Hi all,

In the following CME

from scipy import sqrt

from enthought.traits.api import *
from enthought.traits.ui.api import *
from enthought.traits.ui.wx.extra.bounds_editor import BoundsEditor

class MyClass(HasTraits):

     x = Float(sqrt(2))

     y = Float
     min_range = Float(sqrt(2))
     max_range = Float(sqrt(3))

     view = View(Item('x'),
                 Item('x',
                      editor=TextEditor(format_str='%g',
                                        evaluate=float,
                                        auto_set=False, enter_set=True)),
                 Item('y',
                      springy=True,
                      editor=RangeEditor(low_name='min_range',
                                         high_name='max_range',
                                         mode='slider')))

if __name__ == '__main__':
     my_class = MyClass()
     my_class.configure_traits()

I would like to set something like format_str for range bounds and
value, in order to display shorter floats ("1.4142" rather than the too
long "1.41421356237")

How could I do this?


TIA

Cheers,

--
Fred
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: [traits] RangeEditor bounds format...

bryce hendrix-2
Did you mean to use the BoundsEditor, or the RangeEditor?

On Fri, Dec 3, 2010 at 12:37 PM, Fred <[hidden email]> wrote:
Hi all,

In the following CME

from scipy import sqrt

from enthought.traits.api import *
from enthought.traits.ui.api import *
from enthought.traits.ui.wx.extra.bounds_editor import BoundsEditor

class MyClass(HasTraits):

    x = Float(sqrt(2))

    y = Float
    min_range = Float(sqrt(2))
    max_range = Float(sqrt(3))

    view = View(Item('x'),
                Item('x',
                     editor=TextEditor(format_str='%g',
                                       evaluate=float,
                                       auto_set=False, enter_set=True)),
                Item('y',
                     springy=True,
                     editor=RangeEditor(low_name='min_range',
                                        high_name='max_range',
                                        mode='slider')))

if __name__ == '__main__':
    my_class = MyClass()
    my_class.configure_traits()

I would like to set something like format_str for range bounds and
value, in order to display shorter floats ("1.4142" rather than the too
long "1.41421356237")

How could I do this?


TIA

Cheers,

--
Fred
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: [traits] RangeEditor bounds format...

Warren Weckesser
In reply to this post by fred-2


On Fri, Dec 3, 2010 at 11:37 AM, Fred <[hidden email]> wrote:
Hi all,

In the following CME

from scipy import sqrt

from enthought.traits.api import *
from enthought.traits.ui.api import *
from enthought.traits.ui.wx.extra.bounds_editor import BoundsEditor

class MyClass(HasTraits):

    x = Float(sqrt(2))

    y = Float
    min_range = Float(sqrt(2))
    max_range = Float(sqrt(3))

    view = View(Item('x'),
                Item('x',
                     editor=TextEditor(format_str='%g',
                                       evaluate=float,
                                       auto_set=False, enter_set=True)),
                Item('y',
                     springy=True,
                     editor=RangeEditor(low_name='min_range',
                                        high_name='max_range',
                                        mode='slider')))

if __name__ == '__main__':
    my_class = MyClass()
    my_class.configure_traits()

I would like to set something like format_str for range bounds and
value, in order to display shorter floats ("1.4142" rather than the too
long "1.41421356237")

How could I do this?


The RangeEditor has a 'format' keyword that does this:

                     editor=RangeEditor(low_name='min_range',
                                        high_name='max_range',
                                        format="%6.4f",
                                        mode='slider')))
 

Warren


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: [traits] RangeEditor bounds format...

fred-2
Le 03/12/2010 18:48, Warren Weckesser a écrit :

> The RangeEditor has a 'format' keyword that does this:
Arg, my bad, once again :-(

Thanks!!


Cheers,

--
Fred
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev