AutoCompletion question

13 views
Skip to first unread message

werner

unread,
Jun 8, 2011, 5:56:19 AM6/8/11
to edi...@googlegroups.com
No AutoCompletion for the following:

self.txt = wx.TextCtrl(panel1, id=wx.ID_ANY)

self.txt.

When entering the "." after txt on the second line I like to see
variables, methods for wx.TextCtrl.

I have not enabled something or ...?

Werner

Cody Precord

unread,
Jun 8, 2011, 8:44:07 AM6/8/11
to editra
Hi,
Autocompletion is not perfect, there may be something else in the file
that breaking the completion. You can watch the log window for [err]
messages from the completer when you type the '.' to get an idea why.


Cody


werner

unread,
Jun 8, 2011, 10:12:48 AM6/8/11
to edi...@googlegroups.com
Hhm, it works now (had rebooted machine in the mean time for other
reasons) - will watch out for it.

Werner

P.S.
Thanks also for the explanation on the Ctrl-f context menu option for
Find All - just great!!!!

werner

unread,
Jul 15, 2011, 9:50:29 AM7/15/11
to edi...@googlegroups.com
Hi Cody,

Here is a different script which gives me problems with AutoCompletion.

I see this in the log window:
[15:48:20][pycomp][err] local exec name 'proportion' is not defined
[flag = wx.EXPAND , proportion]

Do you see the same error if you try to do a completion for e.g.
"wx.RED" just after the import statement for wx?

Werner


scrolledwindow.py

werner

unread,
Jul 15, 2011, 9:55:18 AM7/15/11
to edi...@googlegroups.com
If I switch flag and proportion around then the error goes away but
"wx.RED" is still not found by the completion.

Werner

Cody Precord

unread,
Jul 15, 2011, 12:37:40 PM7/15/11
to edi...@googlegroups.com
Hi,

On Fri, Jul 15, 2011 at 8:55 AM, werner <wbr...@free.fr> wrote:
> On 07/15/2011 03:50 PM, werner wrote:
>>
>> Hi Cody,
>>
>> Here is a different script which gives me problems with AutoCompletion.
>>
>> I see this in the log window:
>> [15:48:20][pycomp][err] local exec name 'proportion' is not defined [flag
>> = wx.EXPAND , proportion]
>>

I see this as well. I think that the parser is failing for some reason
when it hits the 'wx.' in the parens of the method call, but it is not
so important as we don't need to provided completions for the
'proportion' object as its scope is only valid within the parens.

>> Do you see the same error if you try to do a completion for e.g. "wx.RED"
>> just after the import statement for wx?
>

Shows up just fine on my system (wx 2.8.12 / py2.7 / windows xp SP3)


> If I switch flag and proportion around then the error goes away but "wx.RED"
> is still not found by the completion.
>

Can you go into 'src/autocomp/pycomp.py' and in the 'evalsource'
method at around line 195 there is a block of commented out text. If
you uncomment that text and then start Editra and repeat the action
where the completion failed it will dump the generated source code to
a file that can be used to try and analyze the problem on your system.


Cody

werner

unread,
Jul 17, 2011, 5:54:36 AM7/17/11
to edi...@googlegroups.com
Cody,

On 07/15/2011 06:37 PM, Cody Precord wrote:

>> If I switch flag and proportion around then the error goes away but "wx.RED"
>> is still not found by the completion.
>>
> Can you go into 'src/autocomp/pycomp.py' and in the 'evalsource'
> method at around line 195 there is a block of commented out text. If
> you uncomment that text and then start Editra and repeat the action
> where the completion failed it will dump the generated source code to
> a file that can be used to try and analyze the problem on your system.
>

Tests are on Ubuntu 10.10, Python 2.6.6 and wxPython 2.8.12.0

Did this but no file seems to get generated. The log output I get:

[11:18:18][pycomp][info] parseassignment: app = wx.PySimpleApp
[11:18:18][pycomp][info] parseassignment: f = wx.Frame
[11:18:18][pycomp][info] parseassignment: ps = wx.ScrolledWindow
[11:18:18][pycomp][info] parseassignment: ps.Sizer = wx.BoxSizer
[11:18:18][pycomp][info] parseassignment: ps.MinSize = 300
[11:18:18][pycomp][info] parseassignment: sz = wx.BoxSizer
[11:18:18][pycomp][info] parseassignment: proportion = 1
[11:18:18][pycomp][info] parseassignment: flag = wx.EXPAND
[11:18:18][pycomp][info] parseassignment: p = wx.Window
[11:18:18][pycomp][info] parseassignment: flag = wx.GROW
[11:18:18][pycomp][info] parseassignment: pin = wx.Panel
[11:18:18][pycomp][info] parseassignment: orient = wx.VERTICAL
[11:18:18][pycomp][info] parseassignment: proportion = 1
[11:18:18][pycomp][info] parseassignment: flag = wx.EXPAND
[11:18:18][pycomp][info] Generated source: """"""
[11:18:18][pycomp][info]try:
[11:18:18][pycomp][info] import wx
[11:18:18][pycomp][info]except ImportError:
[11:18:18][pycomp][info] pass
[11:18:18][pycomp][info]class _PyCmplNoType:
[11:18:18][pycomp][info] def __getattr__(self,name):
[11:18:18][pycomp][info] return None
[11:18:18][pycomp][info]app = wx.PySimpleApp
[11:18:18][pycomp][info]f = wx.Frame
[11:18:18][pycomp][info]ps = wx.ScrolledWindow
[11:18:18][pycomp][info]sz = wx.BoxSizer
[11:18:18][pycomp][info]def add(w,red):
[11:18:18][pycomp][info] pass
[11:18:18][pycomp][info]pin = wx.Panel
[11:18:18][pycomp][info]orient = wx.VERTICAL
[11:18:18][pycomp][info]proportion = 1
[11:18:18][pycomp][info]flag = wx.EXPAND
[11:18:18][pycomp][info] Successfully executed source code
[11:18:18][pycomp][info] Successfully executed: import wx
[11:18:18][pycomp][info] Successfully executed: app = wx.PySimpleApp
[11:18:18][pycomp][info] Successfully executed: f = wx.Frame
[11:18:18][pycomp][info] Successfully executed: ps = wx.ScrolledWindow
[11:18:18][pycomp][info] Successfully executed: sz = wx.BoxSizer
[11:18:18][pycomp][info] Successfully executed: pin = wx.Panel
[11:18:18][pycomp][info] Successfully executed: orient = wx.VERTICAL
[11:18:18][pycomp][info] Successfully executed: proportion = 1
[11:18:18][pycomp][info] Successfully executed: flag = wx.EXPAND
[11:18:18][pycomp][info] Completion eval time: 0.037756
[11:18:18][pycomp][info] get_completions('wx.','')
[11:18:18][pycomp][info] completing: stmt:wx
[11:18:18][codebrowser][info] Syncing tree for position 4
[11:18:19][codebrowser][info] Syncing tree for position 4
[11:18:26][codebrowser][info] Syncing tree for position 4
[11:18:26][codebrowser][info] Syncing tree for position 4
[11:18:26][codebrowser][info] Syncing tree for position 4
[11:19:19][ed_pages][evt] Control Changing from Page: 0 to Page: 1
[11:19:19][ed_pages][evt] Control Changing from Page: 0 to Page: 1
[11:19:19][Launch][info] Found commands [u'pylint', u'pylinterr', u'python']
[11:19:19][ed_pages][evt] Page Changed to 1
[11:19:19][ed_editv][info] Tab has file:
/home/wbruhin/devTools/Editra/src/autocomp/pycomp.py
[11:19:20][codebrowser][info] Syncing tree for position 198
[11:19:20][codebrowser][info] Syncing tree for position 198

Doing it on my VirtualBox Win7 install I see this:

[11:50:15][pycomp][err] _GetCompletionInfo: <type 'exceptions.IOError'>,
[Errno 13] Permission denied: 'pycompout.py'

And if I run as admin I see:

[11:52:19][pycomp][info] Generated source: """"""

All this is with latest SVN copy of Editra (i.e. 68295)

Werner


Cody Precord

unread,
Jul 17, 2011, 2:46:25 PM7/17/11
to edi...@googlegroups.com
Hi,

On Sun, Jul 17, 2011 at 4:54 AM, werner <wbr...@free.fr> wrote:
> Cody,
>
> On 07/15/2011 06:37 PM, Cody Precord wrote:
>
>>> If I switch flag and proportion around then the error goes away but
>>> "wx.RED"
>>> is still not found by the completion.
>>>
>> Can you go into 'src/autocomp/pycomp.py' and in the 'evalsource'
>> method at around line 195 there is a block of commented out text. If
>> you uncomment that text and then start Editra and repeat the action
>> where the completion failed it will dump the generated source code to
>> a file that can be used to try and analyze the problem on your system.
>>
> Tests are on Ubuntu 10.10, Python 2.6.6 and wxPython 2.8.12.0
>
> Did this but no file seems to get generated.  The log output I get:
>

see below

>
> Doing it on my VirtualBox Win7 install I see this:
>
> [11:50:15][pycomp][err] _GetCompletionInfo: <type 'exceptions.IOError'>,
> [Errno 13] Permission denied: 'pycompout.py'

You may need to modify the code you uncommented as it just does
'open('pycompout.py')' which will write to the same directory as the
pycomp file. As the error shows you don't have write permissions in
that directory it would seem. So you can just change the path to write
to your desktop or somewhere that you do.


Cody

werner

unread,
Jul 18, 2011, 3:35:08 AM7/18/11
to edi...@googlegroups.com
Good morning Cody,

On 07/17/2011 08:46 PM, Cody Precord wrote:
...


> Doing it on my VirtualBox Win7 install I see this:
>> [11:50:15][pycomp][err] _GetCompletionInfo:<type 'exceptions.IOError'>,
>> [Errno 13] Permission denied: 'pycompout.py'
> You may need to modify the code you uncommented as it just does
> 'open('pycompout.py')' which will write to the same directory as the
> pycomp file. As the error shows you don't have write permissions in
> that directory it would seem. So you can just change the path to write
> to your desktop or somewhere that you do.
>

Didn't notice that I only had access rights.

Changed it to write to /tmp and attached is the file it generates and
what it shows for completion.

Werner

pycompout.py
editraComp.png

Cody Precord

unread,
Jul 18, 2011, 10:41:02 AM7/18/11
to edi...@googlegroups.com
Hi,

Looks like that is on some version of Linux. What version of wxPython
is Editra running on on that machine?

If you type 'wx.' in PyShell does RED show up in the list?

Can't reproduce on my Windows machine but will double check on my
Linux setup when I get a chance though I wouldn't suspect any
different behavior in this feature.


Cody

werner

unread,
Jul 19, 2011, 11:05:05 AM7/19/11
to edi...@googlegroups.com
Cody,

Another question with regards to AutoCompletion.

I am working in module "a" which imports "b". When I add e.g. a new
method in "b" that is often not available when I go back to "a".

Is there a way to refresh "a" that AutoCompletion sees the new stuff (or
renamed/refactored) in "b"?

This is on my Ubuntu machine, haven't tried it on Windows.

Werner

Cody Precord

unread,
Jul 19, 2011, 11:23:45 AM7/19/11
to edi...@googlegroups.com
Hi,

On Tue, Jul 19, 2011 at 10:05 AM, werner <wbr...@free.fr> wrote:
> Cody,
>
> Another question with regards to AutoCompletion.
>
> I am working in module "a" which imports "b".  When I add e.g. a new method
> in "b" that is often not available when I go back to "a".
>
> Is there a way to refresh "a" that AutoCompletion sees the new stuff (or
> renamed/refactored) in "b"?

There isn't really a safe way to do it under the current design, since
the completions are evaluated in process. The only way would be to
force a module reload for modules already in sys.modules during the
eval.


Regards,

Cody

werner

unread,
Oct 8, 2011, 7:53:21 AM10/8/11
to edi...@googlegroups.com
Hi Cody,

Any chance that something like this will make it into one of the next
updates?

Werner

Cody Precord

unread,
Oct 8, 2011, 9:00:15 PM10/8/11
to editra
Hi,

On Oct 8, 6:53 am, werner <wbru...@free.fr> wrote:
> Hi Cody,
>
>
> Any chance that something like this will make it into one of the next
> updates?
>

No, its on my list of things I want to do but it is just a minor
inconvenience and requires a large amount of effort to rework the
autocomplete framework to run asynchronously in a separate process.


Cody

Cody Precord

unread,
Oct 11, 2011, 3:40:33 PM10/11/11
to editra
Hi,
Scratch that, a very simple solution came to mind over the last couple
days.

Committed to current SVN, will be an adequate solution until the new
completer interface can be reworked.


Cody

werner

unread,
Oct 12, 2011, 2:54:00 AM10/12/11
to edi...@googlegroups.com
On 10/11/2011 09:40 PM, Cody Precord wrote:
> Hi,
>
> On Oct 8, 8:00 pm, Cody Precord<codyprec...@gmail.com> wrote:
>> Hi,
>>
>> On Oct 8, 6:53 am, werner<wbru...@free.fr> wrote:
>>
>>> Hi Cody,
>>> Any chance that something like this will make it into one of the next
>>> updates?
>> No, its on my list of things I want to do but it is just a minor
>> inconvenience and requires a large amount of effort to rework the
>> autocomplete framework to run asynchronously in a separate process.
>>
> Scratch that, a very simple solution came to mind over the last couple
> days.
>
> Committed to current SVN, will be an adequate solution until the new
> completer interface can be reworked.
>
Thanks that works very nicely.

I have noted another issue with code completion in my code, will try and
narrow it down and open a ticket so it doesn't get overlooked whenever
you rework the completer interface.

Werner

Reply all
Reply to author
Forward
0 new messages