Fred | 1 Dec 11:11 2010
Picon

[chaco] DataLabel: setting label position...

Hi all,

In the attached CME (from data_labels.py example), I would like to set 
progammatically the position of the labels, ie not using the mouse.

I know DataLabel traits in concern are x, y, x2 and y2.

First of all, if I print these traits (line 68), they are all equal to 0.

Maybe because the window is not created yet?

So, how could I do what I want to do?

TIA

Cheers,

--

-- 
Fred
Attachment (cme0.py): text/x-python, 4767 bytes
_______________________________________________
Enthought-Dev mailing list
Enthought-Dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
ruoyu zhang | 1 Dec 14:14 2010
Picon

TableEditor crash

the attached program will crash by following step:

1. click any cell of the table to enter edit mode.
2. click the button on the top.
3. if not crashed, repeat 1&2.

the table is in a ListTable object, and the ListTable object is edited
by an InstanceEditor. click the button will create a new ListTable
object, so the
entire table will be recreated.

when no cell is in edit mode,  it is ok to recreate the table, but when any
cell is in edit mode, recreate the table will crash the program.

 I did some debug, and it seems that it is related with the dispose
method in TableEditor:

C:\Python26\Lib\site-packages\TraitsBackendWX-3.5.0-py2.6.egg\enthought\traits\ui\wx\table_editor.py

I am using windows 7, Traits-3.5.0-py2.6-win32.egg
--------------------------------------------------------
from enthought.traits.api import HasTraits, List, Button, Str, Instance
from enthought.traits.ui.api import View, Item, TableEditor

class ListItem(HasTraits):
    name = Str
    address = Str
    phone = Str

class ListTable(HasTraits):
(Continue reading)

Fred | 1 Dec 15:40 2010
Picon

[chaco][BUG?] contour_plot issue...

Hi all,

I struggle against an issue, using basic contour_plot.py.

Let's say I want to draw line contours (second plot.contour_plot()) in 
pink color:

     plot.contour_plot("imagedata",
                       type="line",
                       xbounds=(xs[0], xs[-1]),
                       ybounds=(ys[0], ys[-1]),
                       colormap=pink)

Line contours are still black.

So I tried:

     plot.contour_plot("imagedata",
                       type="line",
                       xbounds=(xs[0], xs[-1]),
                       ybounds=(ys[0], ys[-1]),
                       colors=pink)

In this case, I get a traceback:

enthought.traits.trait_errors.TraitError: The 'colors' trait of a 
ContourLinePlot instance must be a string or a ColorMapper or None or a 
list of items which are any value or a tuple, but a value of 
<enthought.chaco.color_mapper.ColorMapper object at 0x36fc290> <class 
'enthought.chaco.color_mapper.ColorMapper'> was specified.
(Continue reading)

John Wiggins | 1 Dec 17:55 2010

Re: [chaco][BUG?] contour_plot issue...

Fred,

Removing the quotes around ColorMapper on lines 27 and 30 is a good solution. I'll make that change to the code soon. Note that "colormap" is not a trait of contour plots or a kwarg for the contour_plot() method, so passing it in will have no effect. I'll fix the example code to reflect that as well.

Unfortunately, that doesn't answer why this was broken to begin with. I'm not the best person to answer that since my knowledge of Traits isn't very deep. Here's what I did find:
1) Not creating a poly contour plot in the basic/contour_plot.py example will cause the TraitError to go away.
2) Changing the Trait declaration from
    colors = Trait(None, Str, Instance("ColorMapper"), List, Tuple)
    to
    colors = Instance("ColorMapper")
    also causes the TraitError to go away.
3) I think the above has something to do with the trait declaration on line 30:
    color_mapper = Property(Instance("ColorMapper"))
    which gets used when you create a contour poly plot (and the "colors" trait is not used)

If somebody with deeper Traits knowledge sees the problem here, it'd be good to know what it is.

- John

On Wed, Dec 1, 2010 at 8:40 AM, Fred <fredmfp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Hi all,

I struggle against an issue, using basic contour_plot.py.

Let's say I want to draw line contours (second plot.contour_plot()) in pink color:

   plot.contour_plot("imagedata",
                     type="line",
                     xbounds=(xs[0], xs[-1]),
                     ybounds=(ys[0], ys[-1]),
                     colormap=pink)

Line contours are still black.

So I tried:


   plot.contour_plot("imagedata",
                     type="line",
                     xbounds=(xs[0], xs[-1]),
                     ybounds=(ys[0], ys[-1]),
                     colors=pink)

In this case, I get a traceback:

enthought.traits.trait_errors.TraitError: The 'colors' trait of a ContourLinePlot instance must be a string or a ColorMapper or None or a list of items which are any value or a tuple, but a value of <enthought.chaco.color_mapper.ColorMapper object at 0x36fc290> <class 'enthought.chaco.color_mapper.ColorMapper'> was specified.

So I looked at base_contour_plot.py, line 27:

   # The color(s) of the lines.
   colors = Trait(None, Str, Instance("ColorMapper"), List, Tuple)

In previous versions, it was

   colors = Trait(None, Str, Instance(ColorMapper), List, Tuple)

If I remove " around ColorMapper, it works fine with 'colors=pink' (but line contours are still black with 'colormap=pink).


Any clue?


TIA


Cheers,

PS : I use svn sources #26042

--
Fred

_______________________________________________
Enthought-Dev mailing list
Enthought-Dev-oRDGkvazHdbtRgLqZ5aouw@public.gmane.orgought.com
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-Dev mailing list
Enthought-Dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
John Wiggins | 1 Dec 18:12 2010

Re: [chaco] DataLabel: setting label position...

Fred,
The label_position kwarg can also be a tuple. If given as a tuple, it is the x,y offset from the data point.

- John

On Wed, Dec 1, 2010 at 4:11 AM, Fred <fredmfp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Hi all,

In the attached CME (from data_labels.py example), I would like to set progammatically the position of the labels, ie not using the mouse.

I know DataLabel traits in concern are x, y, x2 and y2.

First of all, if I print these traits (line 68), they are all equal to 0.

Maybe because the window is not created yet?

So, how could I do what I want to do?


TIA


Cheers,

--
Fred

_______________________________________________
Enthought-Dev mailing list
Enthought-Dev-oRDGkvazHdbtRgLqZ5aouw@public.gmane.orgought.com
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-Dev mailing list
Enthought-Dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
Pearu Peterson | 1 Dec 20:33 2010
Picon

font_manager crashes with IOError

Hi,

After svn update of ETS, my application crashes with the following traceback:

Traceback (most recent call last):
  File "tiff_viewer.py", line 7, in <module>
    from iocbio.chaco.image_stack_viewer import ImageStackViewer
  File "/usr/local/lib/python2.6/dist-packages/iocbio/chaco/image_stack_viewer.py",
line 9, in <module>
    from enthought.enable.api import Component, ComponentEditor
  File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/enable/api.py",
line 8, in <module>
    from base import IDroppedOnHandler, TOP, VCENTER, BOTTOM, LEFT,
HCENTER, RIGHT, \
  File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/enable/base.py",
line 36, in <module>
    from enthought.kiva import font_metrics_provider
  File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/kiva/__init__.py",
line 26, in <module>
    from fonttools import Font   # relative import; not the fonttools project!
  File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/kiva/fonttools/__init__.py",
line 1, in <module>
    from font import Font, str_to_font
  File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/kiva/fonttools/font.py",
line 9, in <module>
    from font_manager import FontProperties, fontManager
  File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/kiva/fonttools/font_manager.py",
line 1388, in <module>
    _rebuild()
  File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/kiva/fonttools/font_manager.py",
line 1338, in _rebuild
    fontManager = FontManager()
  File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/kiva/fonttools/font_manager.py",
line 1056, in __init__
    self.ttflist = createFontList(self.ttffiles)
  File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/kiva/fonttools/font_manager.py",
line 676, in createFontList
    font = TTFont(str(fpath))
  File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/kiva/fonttools/fontTools/ttLib/__init__.py",
line 124, in __init__
    file = open(file, "rb")
IOError: [Errno 21] Is a directory:
'/usr/share/fonts/truetype/ttf-symbol-replacement/symbol-replacement.ttf'

I am using ubuntu maverick. The directory
/usr/share/fonts/truetype/ttf-symbol-replacement/symbol-replacement.ttf
contains a file symbol.ttf.
The following patch fixed the IOError:

--- enthought/kiva/fonttools/font_manager.py    (revision 26059)
+++ enthought/kiva/fonttools/font_manager.py    (working copy)
 <at>  <at>  -430,7 +430,7  <at>  <at> 
         for fname in files:
             fontfiles[os.path.abspath(fname)] = 1

-    return [fname for fname in fontfiles.keys() if os.path.exists(fname)]
+    return [fname for fname in fontfiles.keys() if os.path.isfile(fname)]

However, I am not sure that this is a proper fix because the
symbol.ttf file might be missed in the list.

Best regards,
Pearu
bryce hendrix | 1 Dec 20:35 2010

Re: font_manager crashes with IOError

On Wed, Dec 1, 2010 at 1:33 PM, Pearu Peterson <pearu.peterson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

I am using ubuntu maverick. The directory
/usr/share/fonts/truetype/ttf-symbol-replacement/symbol-replacement.ttf
contains a file symbol.ttf.
The following patch fixed the IOError:

--- enthought/kiva/fonttools/font_manager.py    (revision 26059)
+++ enthought/kiva/fonttools/font_manager.py    (working copy)
<at> <at> -430,7 +430,7 <at> <at>
        for fname in files:
            fontfiles[os.path.abspath(fname)] = 1

-    return [fname for fname in fontfiles.keys() if os.path.exists(fname)]
+    return [fname for fname in fontfiles.keys() if os.path.isfile(fname)]

However, I am not sure that this is a proper fix because the
symbol.ttf file might be missed in the list.


Does Gnome or KDE find that font? If not, then I think your patch is good enough.

Bryce
_______________________________________________
Enthought-Dev mailing list
Enthought-Dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
Pearu Peterson | 1 Dec 20:54 2010
Picon

Re: font_manager crashes with IOError

On Wed, Dec 1, 2010 at 9:35 PM, bryce hendrix <bhendrix@...> wrote:
> On Wed, Dec 1, 2010 at 1:33 PM, Pearu Peterson <pearu.peterson@...>
> wrote:
>>
>> I am using ubuntu maverick. The directory
>> /usr/share/fonts/truetype/ttf-symbol-replacement/symbol-replacement.ttf
>> contains a file symbol.ttf.
>> The following patch fixed the IOError:
>>
>> --- enthought/kiva/fonttools/font_manager.py    (revision 26059)
>> +++ enthought/kiva/fonttools/font_manager.py    (working copy)
>>  <at>  <at>  -430,7 +430,7  <at>  <at> 
>>         for fname in files:
>>             fontfiles[os.path.abspath(fname)] = 1
>>
>> -    return [fname for fname in fontfiles.keys() if os.path.exists(fname)]
>> +    return [fname for fname in fontfiles.keys() if os.path.isfile(fname)]
>>
>> However, I am not sure that this is a proper fix because the
>> symbol.ttf file might be missed in the list.
>>
>
> Does Gnome or KDE find that font? If not, then I think your patch is good
> enough.

I am not sure. The Gnome Font Installer shows the availability of Symbol font
and my system contains only one file symbol.ttf but I don't know if
they are connected.
Do you know how to check whether the Gnome finds the font or no?

Pearu
bryce hendrix | 1 Dec 20:56 2010

Re: font_manager crashes with IOError



On Wed, Dec 1, 2010 at 1:54 PM, Pearu Peterson <pearu.peterson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
On Wed, Dec 1, 2010 at 9:35 PM, bryce hendrix <bhendrix-SCgzsaguwNrby3iVrkZq2A@public.gmane.org> wrote:
> On Wed, Dec 1, 2010 at 1:33 PM, Pearu Peterson <pearu.peterson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> wrote:
>>
>> I am using ubuntu maverick. The directory
>> /usr/share/fonts/truetype/ttf-symbol-replacement/symbol-replacement.ttf
>> contains a file symbol.ttf.
>> The following patch fixed the IOError:
>>
>> --- enthought/kiva/fonttools/font_manager.py    (revision 26059)
>> +++ enthought/kiva/fonttools/font_manager.py    (working copy)
>> <at> <at> -430,7 +430,7 <at> <at>
>>         for fname in files:
>>             fontfiles[os.path.abspath(fname)] = 1
>>
>> -    return [fname for fname in fontfiles.keys() if os.path.exists(fname)]
>> +    return [fname for fname in fontfiles.keys() if os.path.isfile(fname)]
>>
>> However, I am not sure that this is a proper fix because the
>> symbol.ttf file might be missed in the list.
>>
>
> Does Gnome or KDE find that font? If not, then I think your patch is good
> enough.

I am not sure. The Gnome Font Installer shows the availability of Symbol font
and my system contains only one file symbol.ttf but I don't know if
they are connected.
Do you know how to check whether the Gnome finds the font or no?


Not beyond trying to change to that font. I'll fix it correctly...

Bryce
_______________________________________________
Enthought-Dev mailing list
Enthought-Dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev
Pearu Peterson | 1 Dec 21:10 2010
Picon

[chaco] Exception in ArrayViewEditor when changing Array trait value

Hi,

I get the following exception when trying to set Array trait to another vaiue:

Exception occurred in traits notification handler.
Please check the log file for details.
Exception occurred in traits notification handler for object:
<iocbio.chaco.scale_space_task.ScaleSpaceTask object at 0x5214830>,
trait: results, old value: [[1 2 3 4]], new value: [[32  1  1  0]
 [33  1  1  0]
 [34  1  1  0]
 ...,
 [39 41  7  0]
 [40 41  7  0]
 [41 41  7  0]]
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/Traits-3.5.1.dev_r26038-py2.6-linux-x86_64.egg/enthought/traits/trait_notifiers.py",
line 536, in rebind_call_4
    object, trait_name, old, new )
  File "/usr/local/lib/python2.6/dist-packages/Traits-3.5.1.dev_r26038-py2.6-linux-x86_64.egg/enthought/traits/trait_notifiers.py",
line 622, in dispatch
    handler( *args )
  File "/usr/local/lib/python2.6/dist-packages/TraitsBackendWX-3.5.1.dev_r25960-py2.6.egg/enthought/traits/ui/wx/tabular_editor.py",
line 445, in _update_editor
    if old_value[top:bottom] != new_value[top:bottom]:
ValueError: The truth value of an array with more than one element is
ambiguous. Use a.any() or a.all()

and here is a patch that fixes this bug:

--- enthought/traits/ui/wx/tabular_editor.py    (revision 26059)
+++ enthought/traits/ui/wx/tabular_editor.py    (working copy)
 <at>  <at>  -26,6 +26,8  <at>  <at> 
 import wx
 import wx.lib.mixins.listctrl as listmix

+import numpy
+
 from enthought.traits.api \
     import HasStrictTraits, Int, \
            List, Bool, Instance, Any, Event, \
 <at>  <at>  -435,9 +437,13  <at>  <at> 
         top     = control.GetTopItem()
         pn      = control.GetCountPerPage()
         bottom = min(top + pn - 1, n, len(old_value))
-
-        if old_value[top:bottom] != new_value[top:bottom]:
-            self._update_visible = True
+
+        if isinstance (old_value, numpy.ndarray):
+            if (old_value[top:bottom] != new_value[top:bottom]).any():
+                self._update_visible = True
+        else:
+            if old_value[top:bottom] != new_value[top:bottom]:
+                self._update_visible = True

         super(TabularEditor, self)._update_editor(object, name,
                                                   old_value, new_value)

I was not able to check similar issue with qt4 backend as my
application crashed with a segfault in sip.so. I haven't looked into
more details though..

Pearu

Gmane