error using FileEditor

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

error using FileEditor

Timmie
Administrator
Hello,
I get the following error when using a file editor:

PyAssertionError                          Traceback (most recent call last)

C:\Python26\lib\site-packages\traitsbackendwx-3.3.0-py2.6.egg\enthought\traits\ui\wx\file_editor.pyc
in show_file_dialog(self, event)
    176         """
    177         if self.history is not None:
--> 178             self.popup = self._create_file_popup()
    179         else:
    180             dlg       = self._create_file_dialog()

C:\Python26\lib\site-packages\traitsbackendwx-3.3.0-py2.6.egg\enthought\traits\ui\wx\file_editor.pyc
in _create_file_popup(self)
    268                           file_name = self.str_value,
    269                           filter    = self.factory.filter,
--> 270                           height    = 300 )
    271
    272     def _update ( self, file_name ):

C:\Python26\lib\site-packages\traitsbackendwx-3.3.0-py2.6.egg\enthought\traits\ui\wx\helper.pyc
in __init__(self, **traits)
    593         self.popup = popup = wx.Frame( None, -1, '', style = style )
    594         wx.EVT_ACTIVATE( popup, self._on_close_popup )
--> 595         self.create_control( popup )
    596         self._position_control()
    597         popup.Show()

C:\Python26\lib\site-packages\traitsbackendwx-3.3.0-py2.6.egg\enthought\traits\ui\wx\file_editor.pyc
in create_control(self, parent)
    443
    444         self._files = files = wx.GenericDirCtrl( parent, style = style,
--> 445                                           filter = '|'.join( self.filter ) )
    446         files.SetPath( self.file_name )
    447         self._tree  = tree = files.GetTreeCtrl()

C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_controls.pyc in
__init__(self, *args, **kwargs)
   5685             int defaultFilter=0, String name=TreeCtrlNameStr) ->
GenericDirCtrl
   5686         """
-> 5687        
_controls_.GenericDirCtrl_swiginit(self,_controls_.new_GenericDirCtrl(*args,
**kwargs))
   5688         self._setOORInfo(self)
   5689

PyAssertionError: C++ assertion "wxAssertFailure" failed at
..\..\src\common\filefn.cpp(1746) in wxParseCommonDialogsFilter(): missing '|'
in the wildcard string!
---------------------------------------------------------------------------
PyAssertionError                          Traceback (most recent call last)

C:\Python26\lib\site-packages\traitsbackendwx-3.3.0-py2.6.egg\enthought\traits\ui\wx\file_editor.pyc
in show_file_dialog(self, event)
    176         """
    177         if self.history is not None:
--> 178             self.popup = self._create_file_popup()
    179         else:
    180             dlg       = self._create_file_dialog()

C:\Python26\lib\site-packages\traitsbackendwx-3.3.0-py2.6.egg\enthought\traits\ui\wx\file_editor.pyc
in _create_file_popup(self)
    268                           file_name = self.str_value,
    269                           filter    = self.factory.filter,
--> 270                           height    = 300 )
    271
    272     def _update ( self, file_name ):

C:\Python26\lib\site-packages\traitsbackendwx-3.3.0-py2.6.egg\enthought\traits\ui\wx\helper.pyc
in __init__(self, **traits)
    593         self.popup = popup = wx.Frame( None, -1, '', style = style )
    594         wx.EVT_ACTIVATE( popup, self._on_close_popup )
--> 595         self.create_control( popup )
    596         self._position_control()
    597         popup.Show()

C:\Python26\lib\site-packages\traitsbackendwx-3.3.0-py2.6.egg\enthought\traits\ui\wx\file_editor.pyc
in create_control(self, parent)
    443
    444         self._files = files = wx.GenericDirCtrl( parent, style = style,
--> 445                                           filter = '|'.join( self.filter ) )
    446         files.SetPath( self.file_name )
    447         self._tree  = tree = files.GetTreeCtrl()

C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_controls.pyc in
__init__(self, *args, **kwargs)
   5685             int defaultFilter=0, String name=TreeCtrlNameStr) ->
GenericDirCtrl
   5686         """
-> 5687        
_controls_.GenericDirCtrl_swiginit(self,_controls_.new_GenericDirCtrl(*args,
**kwargs))
   5688         self._setOORInfo(self)
   5689

PyAssertionError: C++ assertion "wxAssertFailure" failed at
..\..\src\common\filefn.cpp(1746) in wxParseCommonDialogsFilter(): missing '|'
in the wildcard string!


Could anyone please give me a hint where this comes from?
I am using ETS 3.4 on PythonXY.

Kind regards,
Timmie
Reply | Threaded
Open this post in threaded view
|

Re: error using FileEditor

Didrik Pinte-2
------- Original message -------

> From: Timmie <[hidden email]>
> To: [hidden email]
> Sent: 3.4.'10,  10:44
>
> PyAssertionError: C++ assertion "wxAssertFailure" failed at
> ..\..\src\common\filefn.cpp(1746) in wxParseCommonDialogsFilter():
> missing
> '|'
> in the wildcard string!
>

How did you call the FileEditor ? Could you copy the original code ? It
seems the wilcard you use is not vald.

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

Re: error using FileEditor

Timmie
Administrator
Hello,
thanks for your reply.

Here is the code I used for the FileEditor:

class FileChoser(HasTraits):
    "a file selector with filter for ASCII files"
    id        = 'dataloader.filechose',  
   
     

    filepath = File(editor = FileEditor(filter=['*.csv', '*.dat', '*.txt']))
    traits_ui_view = View(Item('filepath', label='Input CSV')
                                    )


I would appreciate a helping hint here.
It was working before and stopped after something got updated.

Thanks and regards,
Timmie
Reply | Threaded
Open this post in threaded view
|

Re: error using FileEditor

Warren Weckesser
Timmie wrote:

> Hello,
> thanks for your reply.
>
> Here is the code I used for the FileEditor:
>
> class FileChoser(HasTraits):
>     "a file selector with filter for ASCII files"
>     id        = 'dataloader.filechose',  
>    
>      
>
>     filepath = File(editor = FileEditor(filter=['*.csv', '*.dat', '*.txt']))
>     traits_ui_view = View(Item('filepath', label='Input CSV')
>                                     )
>
> I would appreciate a helping hint here.
> It was working before and stopped after something got updated.
>
>  

The filter syntax is quirky and not well documented.  If you want only
one filter choice, and that filter allows multiple extensions, put a
single string in the list, and use a semicolon to separate the patterns
within that string. For example:

    filter=['*.csv;*.txt;*.dat']

Note that there is just one string in the list.  When there is more than
one string in the list, the strings are *alternating descriptions and
patterns*.  So if you wanted the same pattern, but with your own
description of that pattern, you could use:

    filter=['All data types (*.csv, *.txt, *.dat)', '*.csv;*.txt;*.dat']

If you want the user to be able to choose different filters, each with
its own pattern,  alternate the descriptions and patterns in the list.  
For example,

        filter=['All data types (*.csv, *.txt, *.dat)', '*.csv;*.txt;*.dat',
                'Only CSV files (*.csv)', '*.csv',
                'Only text files (*.txt)', '*.txt',
                'Only data files (*.dat)', '*.dat']))

On my computer (Mac OSX with the wx backend), I get a pull-down menu at
the bottom of the file tree that lets me choose one of the four
different filters to apply.


Warren


> Thanks and regards,
> Timmie
>
>  

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