From bf68962fbedac61717d1db2d53a3fa9debec3fe0 2008-07-17 06:25:00 From: Gael Varoquaux Date: 2008-07-17 06:25:00 Subject: [PATCH] Calltips are now working. --- diff --git a/IPython/frontend/wx/console_widget.py b/IPython/frontend/wx/console_widget.py index cf86f42..1d4e29e 100644 --- a/IPython/frontend/wx/console_widget.py +++ b/IPython/frontend/wx/console_widget.py @@ -289,16 +289,15 @@ class ConsoleWidget(editwindow.EditWindow): self.new_prompt(self.prompt % (self.last_result['number'] + 1)) self.replace_current_edit_buffer(current_buffer) else: - #possibilities.sort() # Python sorts are case sensitive self.AutoCompSetIgnoreCase(False) self.AutoCompSetAutoHide(False) - #let compute the length ot text)last word - splitter = [' ', '(', '[', '{'] - last_word = self.get_current_edit_buffer() - for breaker in splitter: - last_word = last_word.split(breaker)[-1] + # compute the length ot the last word + separators = [' ', '(', '[', '{', '\n', '\t', '.'] + symbol = self.get_current_edit_buffer() + for separator in separators: + symbol = symbol.split(separator)[-1] self.AutoCompSetMaxHeight(len(possibilities)) - self.AutoCompShow(len(last_word), " ".join(possibilities)) + self.AutoCompShow(len(symbol), " ".join(possibilities)) def scroll_to_bottom(self): diff --git a/IPython/frontend/wx/wx_frontend.py b/IPython/frontend/wx/wx_frontend.py index 64d69bd..20fccaa 100644 --- a/IPython/frontend/wx/wx_frontend.py +++ b/IPython/frontend/wx/wx_frontend.py @@ -25,11 +25,12 @@ import wx import re from wx import stc from console_widget import ConsoleWidget +import __builtin__ from IPython.frontend.prefilterfrontend import PrefilterFrontEnd #_COMMAND_BG = '#FAFAF1' # Nice green -_RUNNING_BUFFER_BG = '#FDFFBE' # Nice yellow +_RUNNING_BUFFER_BG = '#FDFFD3' # Nice yellow _RUNNING_BUFFER_MARKER = 31 @@ -73,6 +74,25 @@ class IPythonWxController(PrefilterFrontEnd, ConsoleWidget): self.write_completion(completions, mode=mode) + def do_calltip(self): + # compute the length ot the last word + separators = [' ', '(', '[', '{', '\n', '\t'] + symbol = self.get_current_edit_buffer() + for separator in separators: + symbol_string = symbol.split(separator)[-1] + base_symbol_string = symbol_string.split('.')[0] + if base_symbol_string in self.shell.user_ns: + symbol = self.shell.user_ns[base_symbol_string] + elif base_symbol_string in self.shell.user_global_ns: + symbol = self.shell.user_global_ns[base_symbol_string] + elif base_symbol_string in __builtin__.__dict__: + symbol = __builtin__.__dict__[base_symbol_string] + else: + return False + for name in base_symbol_string.split('.')[1:] + ['__doc__']: + symbol = getattr(symbol, name) + self.CallTipShow(self.GetCurrentPos(), symbol) + def update_completion(self): line = self.get_current_edit_buffer() if self.AutoCompActive() and not line[-1] == '.': @@ -144,6 +164,9 @@ class IPythonWxController(PrefilterFrontEnd, ConsoleWidget): self.do_completion(mode='text') else: event.Skip() + elif event.KeyCode == ord('('): + event.Skip() + self.do_calltip() else: ConsoleWidget._on_key_down(self, event, skip=skip)