David C. Morrill | 4 Nov 16:56 2004

[Envisage-dev] Traits 2 UI Status Update

Just thought I would keep people posted on the current progress on getting the new Traits 2 UI up and running…

 

Nothing has been exhaustively tested yet, but…

 

- The ‘panel’ and ‘nonmodal’ view modes are implemented and tested (modal and wizard are not yet implemented)

- 12 of 14 trait editors have been converted to the new Traits 2 format (list and compound are not yet converted)

- 10 of the 12 converted trait editors have been tested and are working: text, boolean, enum, range, color, font, file, directory, check list, instance (button and image enum have not yet been tested)

- The ‘enabled_when’ and ‘defined_when’ clauses have been implemented and tested.

- The ‘info’ object is implemented and has been tested with a custom ‘Handler’

- The ‘Include’ facility has been mostly implemented, but has not been tested yet.

- A new, more expressive and concise, shorthand notation for defining views has been implemented and tested.

 

For anyone interested in trying it out, or who wants to see a (somewhat bizarre) example, can try out my little test case:enthought.traits.test.test_ui.py. Hint: try making the zip code field less than 5 digits or equal to 78664, or the age field less than 21. There are a lot of duplicate fields which either test the different rendering styles or the ability to synchronize all views automatically.

 

Dave M.

Prabhu Ramachandran | 5 Nov 06:24 2004
Picon

Re: [Envisage-dev] Traits 2 UI Status Update

>>>>> "DM" == David C Morrill <dmorrill@...> writes:

    DM> Just thought I would keep people posted on the current
    DM> progress on getting the new Traits 2 UI up and running.

    DM> Nothing has been exhaustively tested yet, but.

I just tried the test_ui example and got this:

$ python test_ui.py 
Traceback (most recent call last):
  File "test_ui.py", line 24, in ?
    from enthought.traits.ui.wx.color_editor import color_trait
  File "/home/prabhu/stuff/python/modules/enthought/traits/ui/wx/__init__.py", line 20, in ?
    import toolkit
  File "/home/prabhu/stuff/python/modules/enthought/traits/ui/wx/toolkit.py", line 24, in ?
    from helper                      import position_near
  File "/home/prabhu/stuff/python/modules/enthought/traits/ui/wx/helper.py", line 23, in ?
    from constants import standard_bitmap_width, screen_dx, screen_dy
  File "/home/prabhu/stuff/python/modules/enthought/traits/ui/wx/constants.py", line 40, in ?
    scrollbar_dx = wx.SystemSettings_GetSystemMetric( wx.SYS_VSCROLL_X )
AttributeError: 'module' object has no attribute 'SystemSettings_GetSystemMetric'

This is wierd since wx does indeed have the
SystemSettings_GetSystemMetric attribute!  Looks like some import
related magic?

cheers,
prabhu

David C. Morrill | 5 Nov 17:20 2004

[Envisage-dev] The road to Traits 2 (Part 2)

Latest features added to Traits 2 UI:

 

- Button and Image Enum editors have been tested/debugged. Only the Compound and List editors remain to be converted and tested.

- Trait editor dialogs can now be easily positioned and sized in a variety of ways.

- Undo/Redo/Revert/Ok/Cancel support has been added to nonmodal (i.e. live update) dialogs. Undo/Redo/Revert includes transparent support for nested objects and creation of Undo/Redo transactions for Handler-based multiple trait/object updates.

- First cut at creating modal dialogs has been completed, but the object update semantics have not yet been correctly implemented.

 

Dave M.

 

Prabhu Ramachandran | 5 Nov 19:34 2004
Picon

[Envisage-dev] tvtk update

Hi folks,

I'm almost done with the core functionality for tvtk.  I've even added
some generic documentation in tvtk/doc/README.txt (its reST and the
HTML looks pretty nice).  Unit tests are in the tests subdir.  There
is also a fully working but not-too-complex example in examples/.  It
only demonstrates that you can do the things VTK is able to do with
tvtk.  It does not demo any advanced features of tvtk.  Once traits2
is stable I'll add those demos. :)

Notable additions
-----------------

 * Pickling of object 'state'.   Read the README for details.

 * Docstrings.  The class docs are ripped from the VTK docs, massaged
   and put into the tvtk class doc.  For all traits I've simply dumped
   the doc into a `docstring` attribute.  This can be changed later
   perhaps.  All the methods have docstrings along with call signature
   information in the docstring.  The class and method names are
   changed to reflect the tvtk objects.

 * User defined classes can override the defaults in the ZIP file.
   Basically, modify a class in the zip file, and save it in the
   custom/ sub-package directory.

 * Any subclass of Collection (or `vtkCollection`) will behave like a
   Python sequence (with __{get,set,del}item__, len and append) along
   with iterability. More details are in README.txt.

 * Cleanup of the code.

 * Unit tests and docs.

examples/simple.py is a translation of Cone6.py from the VTK
tutorial.

Install/build instructions are in the README.txt.

Request for Feedback
--------------------

I need to add a simple setup.py script so this stuff can be installed.
How do I build a ZIP file and add a dependency check so distutils does
not build the ZIP file each time you run setup.py?  

Is there a way to do some kind of time stamp check or something so
that only if a bunch of files are updated or the ZIP file is deleted
is the wrapper code regenerated?  

Also, do you have any recommendations as to which package's
setup_pkg.py I can use as a good example template to cut/paste from?
:)

If the setup.py is added, I think tvtk has reached a usability
milestone and can be used in serious applications!

Please check it out (the instructions in README.txt will get you
started) and let me know if you have problems.

Future
------

I still need to add some developer docs.  I'll try and finish that
tommorow.

I also need to make a few changes once the traits2 stuff is done and
add more examples.  I'll do that once traits2 is stable.

I haven't done anything to make array handling easier.  I'm saving
that for later.

I'm going to shift gears now and start writing some of the
infrastructure needed for MayaVi2.  Pipeline browser, generic
scriptable (from IPython) wxRenderWindow, lighting, picking etc.

cheers,
prabhu

Fernando Perez | 5 Nov 19:42 2004
Picon

Re: [Envisage-dev] tvtk update

Prabhu Ramachandran schrieb:
> I need to add a simple setup.py script so this stuff can be installed.
> How do I build a ZIP file and add a dependency check so distutils does
> not build the ZIP file each time you run setup.py?  
> 
> Is there a way to do some kind of time stamp check or something so
> that only if a bunch of files are updated or the ZIP file is deleted
> is the wrapper code regenerated?  

IPython.genutils has this:

In [2]: IPython.genutils.target_update?
Type:           function
Base Class:     <type 'function'>
String Form:    <function target_update at 0x9b2843c>
Namespace:      Interactive
File:           /home/fperez/code/python/IPython/genutils.py
Definition:     IPython.genutils.target_update(target, deps, cmd)
Docstring:
     Update a target with a given command given a list of dependencies.

     target_update(target,deps,cmd) -> runs cmd if target is outdated.

     This is just a wrapper around target_outdated() which calls the given
     command if target is outdated.

In [3]: IPython.genutils.target_outdated?
Type:           function
Base Class:     <type 'function'>
String Form:    <function target_outdated at 0x9b28404>
Namespace:      Interactive
File:           /home/fperez/code/python/IPython/genutils.py
Definition:     IPython.genutils.target_outdated(target, deps)
Docstring:
     Determine whether a target is out of date.

     target_outdated(target,deps) -> 1/0

     deps: list of filenames which MUST exist.
     target: single filename which may or may not exist.

     If target doesn't exist or is older than any file listed in deps, return
     true, otherwise return false.

Have a look in the setup.py for ipython for examples of its use.  It's a 
trivially simple poor man's make, in python.  I use it to auto-build ipython's 
docs based on which parts have changed (the manual includes stuff pulled in 
from ipython's sources, so the build chain has several steps).  Feel free to 
rip any of this code.  Ipython's setup.py may also be a simpler starter 
example of distutils for you than the very complex ones typical of scipy.

Cheers,

f

David C. Morrill | 6 Nov 03:02 2004

[Envisage-dev] The road to Traits 2 (part 3)

End of day summary:

 

- Modal dialogs with full Apply/Revert functionality is working.

- Wizard dialogs with the ability to block page advancement and re-route pages via a custom handler is working.

 

End of week summary:

 

At this point most of the new Traits 2 UI core functionality is working. There are two more trait editors to get working, and the “visual inheritance” capability needs a little more development, and a lot of testing. Beyond that, there is a ton of little clean-up items that I’ve accumulated this week that need to be done, but overall things look to be in pretty good shape.

 

Dave M.

 

Prabhu Ramachandran | 6 Nov 10:49 2004
Picon

Re: [Envisage-dev] The road to Traits 2 (part 3)

>>>>> "DM" == David C Morrill <dmorrill@...> writes:

[...]
    DM> End of week summary:
[...]

There are a few trivial bugs I spotted and have changed locally.
Attached at the end are the diffs.  I'd rather not check them in since
you might have uncommitted changes that I don't want to mess up.

I know you still need to test a whole bunch of things but I jumped the
gun and played with a few things.  Here are some comments.

In ui/toolkits.py::toolkit you have this defined:

     48     for toolkit_name in toolkits:   
     49         try:
     50             package  = 'enthought.traits.ui.' + toolkit_name
     51             module   = __import__( package )
     52             _toolkit = getattr( module.traits.ui, toolkit_name ).toolkit
     53             return _toolkit
     54         except:
     55             pass
     56     else:
     57         raise TraitError, ("Could not find any UI toolkit called: %s" % 
     58                            ', '.join( toolkits ))

The catch-all except befuddles error handling and its hard to figure
out why the import failed.  I think it is a better idea to use an
'except ImportError' there.

Earlier, read-only properties would be ignored when one called
edit_traits.  This is not the case anymore.  For example::

In [8]: class A(HasTraits):
   ...:     a = Trait('a', {'a':1, 'b':2})
   ...:     def _get_b(self):
   ...:         return 'b'
   ...:     b = Property(_get_b)
   ...:     

In [9]: a = A()

In [10]: a.edit_traits()

[snipped looong traceback ending with ]

/home/prabhu/stuff/python/modules/enthought/traits/ui/wx/ui_panel.py in add_items(self, content)
    312                 
    313             # Create the requested type of editor from the editor factory: 
--> 314             factory_method = getattr( editor_factory, item.style + '_editor' )
    315             editor         = factory_method( ui, object, name, desc, panel )
    316                 

AttributeError: 'NoneType' object has no attribute 'simple_editor'

Of course, if __editable_traits__ is set to ['a'], we are golden.  But
this used to work earlier.

So with these small changes, the GUI editors seem to work (atleast
they popup cleanly!).

I assume that the new UI stuff is documented in the
traits2_ui_proposal.  I haven't had a chance to read that yet, but
will do so soon.  Is there any other documentation that you'd
recommend I read to use the new traits2 UI design effectively?

Thanks!

cheers,
prabhu

# --------------- DIFFS ------------------------------------------------

$ svn diff ui/toolkit.py ui/wx/constants.py
Index: ui/toolkit.py
===================================================================
--- ui/toolkit.py       (revision 1757)
+++ ui/toolkit.py       (working copy)
 <at>  <at>  -17,7 +17,7  <at>  <at> 
 #  Imports:
 #-------------------------------------------------------------------------------

-from enthought.traits import HasTraits, HasPrivateTraits
+from enthought.traits import HasTraits, HasPrivateTraits, TraitError
 from ui_traits        import SequenceTypes

 #-------------------------------------------------------------------------------
Index: ui/wx/constants.py
===================================================================
--- ui/wx/constants.py  (revision 1757)
+++ ui/wx/constants.py  (working copy)
 <at>  <at>  -37,7 +37,10  <at>  <at> 
 standard_bitmap_width = 120

 # Width of a scrollbar:
-scrollbar_dx = wx.SystemSettings_GetSystemMetric( wx.SYS_VSCROLL_X )
+try:
+    scrollbar_dx = wx.SystemSettings_GetSystemMetric( wx.SYS_VSCROLL_X )
+except AttributeError:
+    scrollbar_dx = wx.SystemSettings_GetMetric( wx.SYS_VSCROLL_X )    

 # Screen size:
 screen_dx = wx.SystemSettings_GetMetric( wx.SYS_SCREEN_X )

Prabhu Ramachandran | 6 Nov 11:26 2004
Picon

Re: [Envisage-dev] tvtk update

Hey Fernando,

Did not realize you were on this list! :)

>>>>> "FP" == Fernando Perez <Fernando.Perez@...> writes:

    FP> Prabhu Ramachandran schrieb:
    >> Is there a way to do some kind of time stamp check or something
    >> so that only if a bunch of files are updated or the ZIP file is
    >> deleted is the wrapper code regenerated?

    FP> IPython.genutils has this:

    FP> In [2]: IPython.genutils.target_update?  

    FP> In [3]: IPython.genutils.target_outdated?

Thanks!  The only problem is that if I use these I will add IPython to
the dependency list.  I guess for now that is OK.  If someone objects
to this later, I'll steal liberally from your code. :)

It would be cool if these were part of scipy_distutils.  Perhaps we
can convince Pearu to take a look?

    FP> Have a look in the setup.py for ipython for examples of its
    FP> use.  It's a trivially simple poor man's make, in python.  I
    FP> use it to auto-build ipython's docs based on which parts have
    FP> changed (the manual includes stuff pulled in from ipython's
    FP> sources, so the build chain has several steps).  Feel free to
    FP> rip any of this code.  

OK, thanks for the example.

    FP> Ipython's setup.py may also be a simpler starter example of
    FP> distutils for you than the very complex ones typical of scipy.

Oh, writing the setup is not the real problem (sometimes it can be but
in my case the setup should be fairly simple).  I wanted to know if
there were any 'enthought' specific things I needed to worry about.

For now I'll just go ahead and use the IPython functions to build the
ZIP file.

Thanks again!

cheers,
prabhu

Fernando Perez | 6 Nov 18:29 2004
Picon

Re: [Envisage-dev] tvtk update

Prabhu Ramachandran wrote:
> Hey Fernando,
> 
> Did not realize you were on this list! :)

I'm stalking you :)

> Thanks!  The only problem is that if I use these I will add IPython to
> the dependency list.  I guess for now that is OK.  If someone objects
> to this later, I'll steal liberally from your code. :)

It's just two tiny standalone functions, why don't you just copy them over? 
No point in making ipython a dependency for so little code, I think.  If you 
improve them, just send the changes my way.

> It would be cool if these were part of scipy_distutils.  Perhaps we
> can convince Pearu to take a look?

Sure.  Remember that ipython is now BSD licensed (officially so in CVS 
already, I'll try to release 0.6.4 on Monday), so code sharing/copying is not 
an issue anymore.

Best,

f

eric jones | 6 Nov 21:24 2004

[Envisage-dev] trying tvtk on windows

Hey Prabhu,

I tried building the tvtk stuff today and got this error:

C:\wrk\converge\src\lib\enthought\tvtk>python code_gen.py -s
Traceback (most recent call last):
  File "code_gen.py", line 215, in ?
    main()
  File "code_gen.py", line 203, in main
    gen.generate_code()
  File "code_gen.py", line 84, in generate_code
    self._write_wrapper_class(node, tvtk_name)
  File "code_gen.py", line 167, in _write_wrapper_class
    self.wrap_gen.generate_code(node, out)
  File "C:\wrk\converge\src\lib\enthought\tvtk\wrapper_gen.py", line 66, 
in generate_code
    self._gen_methods(node, out)
  File "C:\wrk\converge\src\lib\enthought\tvtk\wrapper_gen.py", line 
132, in _gen_methods
    ut.update(self._gen_toggle_methods(klass, out))
  File "C:\wrk\converge\src\lib\enthought\tvtk\wrapper_gen.py", line 
159, in _gen_toggle_m
ethods
    vtk_set_meth = getattr(klass, 'Set' + m)
AttributeError: SetEnabled

I am using the latest Enthon which has vtk 4.2.2.  Do I need a more 
recent version?

thanks,
eric


Gmane