Sub-classing wx.TextCompleter

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

Sub-classing wx.TextCompleter

Xaviou
Hi.

I am trying to play with auto completion.

I have created a class derived from wx.TextCompleter witch contains the following :

import wx

from ClassList import szClasses

class ClassCompleter(wx.TextCompleter):
def __init__(self):
wx.TextCompleter.__init__(self)
self._iLastReturned = wx.NOT_FOUND
self._sPrefix = ''

def Start(self, prefix):
self._sPrefix = prefix.lower()
self._iLastReturned = wx.NOT_FOUND
for item in szClasses:
if item.lower().startswith(self._sPrefix):
return True
# Nothing found
return False

def GetNext(self):
for i in range(self._iLastReturned+1, len(szClasses)):
if szClasses[i].lower().startswith(self._sPrefix):
return szClasses[i]
# No more corresponding item
return ''


Then, in the main application, I've created a simple textbox and enabled auto complete using the following line :

self._txtEntry.AutoComplete(ClassCompleter())

But this line gives an error at execution time :
TypeError: wx._core.TextCompleter cannot be instantiated or sub-classed
OnInit returned false, exiting...

Can one tell me what I've done wrong ?
I'm using wxPython 4.0.2a1 dev3717 64bits on a Windows 10 system, installed from the "snapshots builds" wheels (https://wxpython.org/Phoenix/snapshot-builds/).

Thanks in advance.

Regards
Xav'

--
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: Sub-classing wx.TextCompleter

Xaviou
Hi again...

For people who prefer having a small test app : here it is.

The line witch causes the error has been commented : see MainFrame.py line 28

Regards
Xav'

--
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.

AutoComplete.zip (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Sub-classing wx.TextCompleter

Robin Dunn
On Tuesday, April 24, 2018 at 8:46:19 AM UTC-7, Xaviou wrote:
Hi again...

For people who prefer having a small test app : here it is.

The line witch causes the error has been commented : see MainFrame.py line 28


Thanks for the sample. I'll take a look when I can. It will probably need some extra tweaks for that class to convince sip that it's not an abstract class.

I've added an issue to track this, and so it won't be forgotten. https://github.com/wxWidgets/Phoenix/issues/827

--
Robin

--
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: Sub-classing wx.TextCompleter

Xaviou
Hi.

I think there is also a problem with wx.TextCompleterSimple : I've tried the sample code provided on the doc (https://wxpython.org/Phoenix/docs/html/wx.TextCompleterSimple.html) and I obtain an error when auto completion starts :
NotImplementedError: TextCompleterSimple.Start() is abstract and must be overridden

If I add a basic "Start" method witch returns a boolean, it also requires the "GetNext" one:
NotImplementedError: TextCompleterSimple.GetNext() is abstract and must be overridden

Regards
Xav'

On Tuesday, April 24, 2018 at 9:24:58 PM UTC+2, Robin Dunn wrote:
On Tuesday, April 24, 2018 at 8:46:19 AM UTC-7, Xaviou wrote:
Hi again...

For people who prefer having a small test app : here it is.

The line witch causes the error has been commented : see MainFrame.py line 28


Thanks for the sample. I'll take a look when I can. It will probably need some extra tweaks for that class to convince sip that it's not an abstract class.

I've added an issue to track this, and so it won't be forgotten. <a href="https://github.com/wxWidgets/Phoenix/issues/827" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FwxWidgets%2FPhoenix%2Fissues%2F827\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFNpTJ56B_gZpnT7sgIGCdfPF2Ojg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FwxWidgets%2FPhoenix%2Fissues%2F827\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFNpTJ56B_gZpnT7sgIGCdfPF2Ojg&#39;;return true;">https://github.com/wxWidgets/Phoenix/issues/827

--
Robin

--
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: Sub-classing wx.TextCompleter

Scott Talbert
Yes, looks like another bug.  TextCompleterSimple should only require
GetCompletions() to be overridden.

On Wed, 25 Apr 2018, Xaviou wrote:

> Hi.
> I think there is also a problem with wx.TextCompleterSimple : I've tried the
> sample code provided on the doc
> (https://wxpython.org/Phoenix/docs/html/wx.TextCompleterSimple.html) and I
> obtain an error when auto completion starts :
> NotImplementedError: TextCompleterSimple.Start() is abstract and must be
> overridden
>
> If I add a basic "Start" method witch returns a boolean, it also requires
> the "GetNext" one:
> NotImplementedError: TextCompleterSimple.GetNext() is abstract and must be
> overridden
>
> Regards
> Xav'
>
> On Tuesday, April 24, 2018 at 9:24:58 PM UTC+2, Robin Dunn wrote:
>       On Tuesday, April 24, 2018 at 8:46:19 AM UTC-7, Xaviou wrote:
>             Hi again...
> For people who prefer having a small test app : here it is.
>
> The line witch causes the error has been commented : see
> MainFrame.py line 28
>
>
>
> Thanks for the sample. I'll take a look when I can. It will probably
> need some extra tweaks for that class to convince sip that it's not an
> abstract class.
>
> I've added an issue to track this, and so it won't be
> forgotten. https://github.com/wxWidgets/Phoenix/issues/827
>
> --
> Robin
>
> --
> 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.
>
>
--
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: Sub-classing wx.TextCompleter

Scott Talbert
I submitted this to fix the TextCompleter issues:
https://github.com/wxWidgets/Phoenix/pull/829

On Wed, 25 Apr 2018, Scott Talbert wrote:

> Yes, looks like another bug.  TextCompleterSimple should only require
> GetCompletions() to be overridden.
>
> On Wed, 25 Apr 2018, Xaviou wrote:
>
>> Hi.
>> I think there is also a problem with wx.TextCompleterSimple : I've tried
>> the
>> sample code provided on the doc
>> (https://wxpython.org/Phoenix/docs/html/wx.TextCompleterSimple.html) and I
>> obtain an error when auto completion starts :
>> NotImplementedError: TextCompleterSimple.Start() is abstract and must be
>> overridden
>>
>> If I add a basic "Start" method witch returns a boolean, it also requires
>> the "GetNext" one:
>> NotImplementedError: TextCompleterSimple.GetNext() is abstract and must be
>> overridden
>>
>> Regards
>> Xav'
>>
>> On Tuesday, April 24, 2018 at 9:24:58 PM UTC+2, Robin Dunn wrote:
>>       On Tuesday, April 24, 2018 at 8:46:19 AM UTC-7, Xaviou wrote:
>>             Hi again...
>> For people who prefer having a small test app : here it is.
>>
>> The line witch causes the error has been commented : see
>> MainFrame.py line 28
>>
>>
>>
>> Thanks for the sample. I'll take a look when I can. It will probably
>> need some extra tweaks for that class to convince sip that it's not an
>> abstract class.
>>
>> I've added an issue to track this, and so it won't be
>> forgotten. https://github.com/wxWidgets/Phoenix/issues/827
>>
>> --
>> Robin
>>
>> --
>> 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.
>>
>>
>
> --
> 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.
>
--
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: Sub-classing wx.TextCompleter

Xaviou
Hi.

On Saturday, April 28, 2018 at 2:44:57 AM UTC+2, Scott Talbert wrote:
I submitted this to fix the TextCompleter issues:
<a href="https://github.com/wxWidgets/Phoenix/pull/829" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FwxWidgets%2FPhoenix%2Fpull%2F829\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNELuB1GaDbcBjA3MU3wE_ko_BsjMA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FwxWidgets%2FPhoenix%2Fpull%2F829\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNELuB1GaDbcBjA3MU3wE_ko_BsjMA&#39;;return true;">https://github.com/wxWidgets/Phoenix/pull/829

Thank you.
It works fine for TextCompleter.
But TextCompleterSimple still requires the "Start" and "GetNext" method to be overriden.

Regards
Xav'

--
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: Sub-classing wx.TextCompleter

Xaviou
I think there is a problem with the last snapshot build filenames :
  • wheels names are like "wxPython-4.0.2a1.dev3730+6e8d62e-cp36-cp36m-win_amd64.whl"
  • sources tarball name is "wxPython-4.0.2a1.dev3730+6e8d62e0.tar.gz" (1 more char in the commit ref)
So pip don't install the wheel : it tries to install from the sources.

Regards
Xav'

On Monday, April 30, 2018 at 8:52:41 AM UTC+2, Xaviou wrote:
Hi.

On Saturday, April 28, 2018 at 2:44:57 AM UTC+2, Scott Talbert wrote:
I submitted this to fix the TextCompleter issues:
<a href="https://github.com/wxWidgets/Phoenix/pull/829" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FwxWidgets%2FPhoenix%2Fpull%2F829\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNELuB1GaDbcBjA3MU3wE_ko_BsjMA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FwxWidgets%2FPhoenix%2Fpull%2F829\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNELuB1GaDbcBjA3MU3wE_ko_BsjMA&#39;;return true;">https://github.com/wxWidgets/Phoenix/pull/829

Thank you.
It works fine for TextCompleter.
But TextCompleterSimple still requires the "Start" and "GetNext" method to be overriden.

Regards
Xav'

--
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: Sub-classing wx.TextCompleter

Robin Dunn
In reply to this post by Xaviou
On Sunday, April 29, 2018 at 11:52:41 PM UTC-7, Xaviou wrote:
Hi.

On Saturday, April 28, 2018 at 2:44:57 AM UTC+2, Scott Talbert wrote:
I submitted this to fix the TextCompleter issues:
<a href="https://github.com/wxWidgets/Phoenix/pull/829" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FwxWidgets%2FPhoenix%2Fpull%2F829\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNELuB1GaDbcBjA3MU3wE_ko_BsjMA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FwxWidgets%2FPhoenix%2Fpull%2F829\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNELuB1GaDbcBjA3MU3wE_ko_BsjMA&#39;;return true;">https://github.com/wxWidgets/Phoenix/pull/829

Thank you.
It works fine for TextCompleter.
But TextCompleterSimple still requires the "Start" and "GetNext" method to be overriden.


Thanks. That will be an easy fix, I'll probably be able to get it taken care of this evening.
https://github.com/wxWidgets/Phoenix/issues/836

--
Robin

--
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: Sub-classing wx.TextCompleter

Robin Dunn
In reply to this post by Xaviou
On Sunday, April 29, 2018 at 11:58:36 PM UTC-7, Xaviou wrote:
I think there is a problem with the last snapshot build filenames :
  • wheels names are like "wxPython-4.0.2a1.dev3730+6e8d62e-cp36-cp36m-win_amd64.whl"
  • sources tarball name is "wxPython-4.0.2a1.dev3730+6e8d62e0.tar.gz" (1 more char in the commit ref)
So pip don't install the wheel : it tries to install from the sources.


Thanks. https://github.com/wxWidgets/Phoenix/issues/837
 
--Robin

--
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: Sub-classing wx.TextCompleter

Xaviou
Hi.

Thank you for all fixes on this point.

I also noticed that GetCompletions for the TextCompleterSimple class has changed (in a more logical way than it was before).

Regards
Xav'

--
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: Sub-classing wx.TextCompleter

Scott Talbert
On Wed, 2 May 2018, Xaviou wrote:

> Hi.
>
> Thank you for all fixes on this point.
>
> I also noticed that GetCompletions for the TextCompleterSimple class has
> changed (in a more logical way than it was before).

Good point - Robin, we should also update the example code to reflect
'res' being returned now instead of a parameter.

Scott

--
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: Sub-classing wx.TextCompleter

Robin Dunn
On Wednesday, May 2, 2018 at 6:22:02 AM UTC-7, Scott Talbert wrote:
On Wed, 2 May 2018, Xaviou wrote:

> Hi.
>
> Thank you for all fixes on this point.
>
> I also noticed that GetCompletions for the TextCompleterSimple class has
> changed (in a more logical way than it was before).

Good point - Robin, we should also update the example code to reflect
'res' being returned now instead of a parameter.


Yep, I changed it but apparently it didn't get checked in to the PR's branch. It will be there in the next build.


--
Robin

--
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.