py3k+phoenix patches for lib.masked and lib.mixins.listctrl

I've submitted the patches to trac (see the forwarded message for more info):

py3k support for wx.lib.masked (phoenix)

http://trac.wxwidgets.org/ticket/15163

py3k support for wx.lib.mixins.listctrl.ColumnSorterMixin (phoenix)

http://trac.wxwidgets.org/ticket/15164

Also, let me know if you think convenient to update the phoenix wiki
pages to reflect the recomendations in the thread (for example, adding
the code snippets about six that sent Robin)

Best regards,

Mariano Reingart
http://www.sistemasagiles.com.ar

···

---------- Forwarded message ----------
From: Mariano Reingart <reingart@gmail.com>
Date: Wed, Apr 24, 2013 at 2:25 PM
Subject: Re: [wxPython-users] porting gui2py (pythoncard fork) to
py3k+phoenix: it works! but some issues found
To: wxpython-users@googlegroups.com

On Tue, Apr 23, 2013 at 10:53 PM, Robin Dunn <robin@alldunn.com> wrote:

Mariano Reingart wrote:

Dear:

Thank you for your excellent work in py3k + phoenix, just using 2to3
and minor fixes I almost could get my code working from wx2.8 to
wx2.9.5.81 (py2.5 to py3.2) in an initial attempt.

I found the following issues:

wx.gizmos.TreeListCtrl seems not to be there too, what should be used
instead?

There is a wx.adv.TreeListCtrl that is similar. It is derived from the
DataViewCtrl and so it has many of the same capabilities. If you need
something more flexible, with a pluggable data model, renderers, etc. then
you can also use DataViewCtrl directly and get hierarchical and/or tabular
data views.

No module named wx.propgrid, will it be supported?

Eventually.

maskededit seems to be unported (uses types module, old string
manipulation and some py2 constructs), are you planing to maintain it
in phoenix?

Yep. With lots of help from the community. <hint!> See
ProjectPhoenix/LibraryMigration - wxPyWiki

I could fix some minor issues in maskedit.py and numctrl.py (attached
diff) but I'm not sure about several needed changes, for example:

in numctrl.py I get the following exception about Validator_IsSilent,
how should it be fixed?

   File "/home/reingart/gui2py/3/wx/lib/masked/numctrl.py", line 971,
in _disallowValue
     if not wx.Validator_IsSilent():
AttributeError: 'module' object has no attribute 'Validator_IsSilent'

See the section in the Migration Guide about static methods.
wxPython Project Phoenix Migration Guide — wxPython Phoenix 4.2.3a1 documentation

In listctrl (and in maskededit too), its checks with type to look for
a string / unicode, how this check should be made in py3k + phoenix?

   File "/home/reingart/gui2py/3/wx/lib/mixins/listctrl.py", line 157,
in __ColumnSorter
     if type(item1) == unicode and type(item2) == unicode:

We're using a copy of the six module to help make code be both Py2.7 and Py3
compatible. For example, for just testing if something is a string type
then you could do:

        import wx.lib.six as six
        if isinstance(item1, six.string_types):
                ...

But in this specific case I think I would just add another layer of
conditionals to the statement checking for the Python version, something
like:

        if not six.PY3:
                current code
        else:
                new code

Thanks very much!

I was able to fix all the blocking issues (masked, numctrl, listctrl
mixin), so gui2py now runs without issues on phoenix (still with some
minor deprecation warning, but working fine)

I'll move the discussion to wxpython-dev with the proposed patch, and,
if accepted, clarification of the wiki with the recommendations in
this thread.

Best regards

Mariano Reingart
http://www.sistemasagiles.com.ar

Mariano Reingart wrote:

I've submitted the patches to trac (see the forwarded message for more info):

py3k support for wx.lib.masked (phoenix)

wxTrac has been migrated to GitHub Issues - wxWidgets

py3k support for wx.lib.mixins.listctrl.ColumnSorterMixin (phoenix)

wxTrac has been migrated to GitHub Issues - wxWidgets

Thanks. Next time please make the patch from the root of the wxPython source tree. That makes them easier to apply.

Also, let me know if you think convenient to update the phoenix wiki
pages to reflect the recomendations in the thread (for example, adding
the code snippets about six that sent Robin)

Yep. Anything that would be helpful to people working on migrating library modules would be fine.

···

--
Robin Dunn
Software Craftsman

Thanks you,

Here is a new patch also for listctrl mixin, fixing missing cmp, apply
and some static methods:

http://trac.wxwidgets.org/ticket/15177

Sorry about the relative path, hope it is correctly made.

Best regards,

Mariano Reingart
http://www.sistemasagiles.com.ar

···

On Thu, Apr 25, 2013 at 9:17 PM, Robin Dunn <robin@alldunn.com> wrote:

Mariano Reingart wrote:

I've submitted the patches to trac (see the forwarded message for more
info):

py3k support for wx.lib.masked (phoenix)

wxTrac has been migrated to GitHub Issues - wxWidgets

py3k support for wx.lib.mixins.listctrl.ColumnSorterMixin (phoenix)

wxTrac has been migrated to GitHub Issues - wxWidgets

Thanks. Next time please make the patch from the root of the wxPython
source tree. That makes them easier to apply.