Problem with python 3.6.3 and wxPython Phoenix 4.0.0b2.

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

Problem with python 3.6.3 and wxPython Phoenix 4.0.0b2.

Zig Zag
Hi all,
how can i to fix this sample code ? See attachment.
I use python 3.6.3 and wxPython Phoenix 4.0.0b2.

Small precision, I do not master python 3.x.

ERROR :
File "C:\wx.ListCtrl virtual.py", line 80, in <module>
  app.MainLoop()
File "C:\Users\toto\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\wx\core.py", line 2085, in MainLoop
  rv = wx.PyApp.MainLoop(self)
File "C:\wx.ListCtrl virtual.py", line 60, in Sort
  self.items.sort(lambda x,y: cmp(x[idx],y[idx]))
  builtins.TypeError: must use keyword argument for key function


Thank by advance.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

wx.ListCtrl.py (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem with python 3.6.3 and wxPython Phoenix 4.0.0b2.

Tim Roberts
On Oct 29, 2017, at 7:53 AM, [hidden email] wrote:

how can i to fix this sample code ? See attachment.
I use python 3.6.3 and wxPython Phoenix 4.0.0b2.

Small precision, I do not master python 3.x.

ERROR :
File "C:\wx.ListCtrl virtual.py", line 80, in <module>
  app.MainLoop()
File "C:\Users\toto\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\wx\core.py", line 2085, in MainLoop
  rv = wx.PyApp.MainLoop(self)
File "C:\wx.ListCtrl virtual.py", line 60, in Sort
  self.items.sort(lambda x,y: cmp(x[idx],y[idx]))
  builtins.TypeError: must use keyword argument for key function


The sort method Python 3 no longer uses a cap function.  Instead, you specify the "key" function that returns the thing to be sorted:

    self.items.sort( key=lambda x: x[idx] )
— 
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with python 3.6.3 and wxPython Phoenix 4.0.0b2.

Zig Zag
It's perfect.

        if self.flg_sort == "sm_up":
            # self.items.sort(lambda x,y: cmp(x[idx],y[idx]))
            self.items.sort( key=lambda x: x[idx] )
                
        else:
            # self.items.sort(lambda y,x: cmp(x[idx],y[idx]))            
            self.items.reverse()
            self.flg_sort = "sm_down"

Tim, thank you very much.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.