0

Hello i have just installed pydev because of code completition. my first sketch is some simple qt widget.

i'm ovverriding mouseMoveEvent:

def mouseMoveEvent(self, event):

    mouse = event.pos()

now.. i know that event variable is a QtCore.QPoint type.. but code completition does not work.. ok i understand it: there is no hard typing, there is duck typing, in theory event could be of any possible type..

instead if i have this code:

point = QtCore.QPoint()

when i write point. code completition works fine (of course it knows the type without doubt!)

i want code completition also in overriding mouseMoveEvent.. what else can i do besides change language and shift in c++ or java?

SOLUTION: as gary pointed me in this thread this trick works:

def mouseMoveEvent(self, event):
    assert(isinstance(event, QtGui.QMouseEvent))

    mouse = event.
Community
  • 1
  • 1
nkint
  • 11,513
  • 31
  • 103
  • 174
  • 1
    See this answer: http://stackoverflow.com/questions/1678953/komodo-python-auto-complete-type-inference-by-variable-metadata/1681587#1681587 I do this alot in komodo, I'm not sure if it works in pydev, but it's worth a try. – Gary van der Merwe Jan 18 '12 at 05:52
  • @nkint I'll have to correct you: `assert(isinstance(inst, class))` didn't work for me, however `assert isinstance(inst, class)` works perfectly. – Alex Okrushko Aug 24 '12 at 21:07

1 Answers1

0

I'm certain that this is not a problem Python, but rather with how your PyDev is set up.

There are plenty of Python IDE's available that have no problem handling the sort of code-completion you mention - such as eric, for instance.

So if you can't get PyDev to do the right thing, the answer is not to switch languages, but to switch IDE's.

ekhumoro
  • 115,249
  • 20
  • 229
  • 336
  • @nkint. Yes, but I think eric uses a more pragmatic approach. It will show _all_ possible completions taken from the current document and/or the currently installed APIs rather than those specific to the current object. I don't use eric myself, but I use an editor which works in a similar way, and I find that style of auto-completion works very well for me (practicality beats purity and all that). – ekhumoro Jan 18 '12 at 18:50