completions

This commit is contained in:
ThomasV 2013-02-20 15:06:49 +01:00
parent a0455725bd
commit 6be6738fac
1 changed files with 25 additions and 0 deletions

View File

@ -166,9 +166,34 @@ class Console(QtGui.QPlainTextEdit):
return
elif event.key() == QtCore.Qt.Key_L and event.modifiers() == QtCore.Qt.ControlModifier:
self.clear()
if event.key() == QtCore.Qt.Key_Tab:
self.completion()
return
super(Console, self).keyPressEvent(event)
def completion(self):
cmd = self.getCommand()
path = cmd.split('.')
ns = self.namespace.keys()
if len(path) == 1:
ns = ns
else:
obj = self.namespace.get(path[0])
ns = dir(obj)
print ns
prefixes = []
for x in ns:
if x.startswith(cmd):
prefixes.append(x)
if len(prefixes) == 1:
self.setCommand(prefixes[0])
welcome_message = '''
---------------------------------------------------------------
Welcome to a primitive Python interpreter.