本文整理匯總了Python中popup.Popup.showMethodCompletionList方法的典型用法代碼示例。如果您正苦於以下問題:Python Popup.showMethodCompletionList方法的具體用法?Python Popup.showMethodCompletionList怎麽用?Python Popup.showMethodCompletionList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類popup.Popup
的用法示例。
在下文中一共展示了Popup.showMethodCompletionList方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from popup import Popup [as 別名]
# 或者: from popup.Popup import showMethodCompletionList [as 別名]
#.........這裏部分代碼省略.........
"""
self.history = History(self)
if namespace != None:
self.locals = namespace
else:
self.locals = {}
self.buffer = [] # buffer for multi-line commands
self.interp = Interpreter(self, self.locals)
sys.stdout = StdOutRedirector(self)
self.text_pane = JTextPane(keyTyped = self.keyTyped, keyPressed = self.keyPressed)
self.__initKeyMap()
self.doc = self.text_pane.document
self.__propertiesChanged()
self.__inittext()
self.initialLocation = self.doc.createPosition(self.doc.length-1)
# Don't pass frame to popups. JWindows with null owners are not focusable
# this fixes the focus problem on Win32, but make the mouse problem worse
self.popup = Popup(None, self.text_pane)
self.tip = Tip(None)
# get fontmetrics info so we can position the popup
metrics = self.text_pane.getFontMetrics(self.text_pane.getFont())
self.dotWidth = metrics.charWidth('.')
self.textHeight = metrics.getHeight()
# add some handles to our objects
self.locals['console'] = self
def insertText(self, text):
"""insert text at the current caret position"""
# seems like there should be a better way to do this....
# might be better as a method on the text component?
caretPosition = self.text_pane.getCaretPosition()
self.text_pane.select(caretPosition, caretPosition)
self.text_pane.replaceSelection(text)
self.text_pane.setCaretPosition(caretPosition + len(text))
def getText(self):
"""get text from last line of console"""
offsets = self.__lastLine()
text = self.doc.getText(offsets[0], offsets[1]-offsets[0])
return text.rstrip()
def getDisplayPoint(self):
"""Get the point where the popup window should be displayed"""
screenPoint = self.text_pane.getLocationOnScreen()
caretPoint = self.text_pane.caret.getMagicCaretPosition()
# BUG: sometimes caretPoint is None
# To duplicate type "java.aw" and hit '.' to complete selection while popup is visible
x = screenPoint.getX() + caretPoint.getX() + self.dotWidth
y = screenPoint.getY() + caretPoint.getY() + self.textHeight
return Point(int(x),int(y))
def hide(self, event=None):
"""Hide the popup or tip window if visible"""
if self.popup.visible:
self.popup.hide()
if self.tip.visible:
self.tip.hide()
def hideTip(self, event=None):
self.tip.hide()
self.insertText(')')
def showTip(self, event=None):
# get the display point before writing text
# otherwise magicCaretPosition is None
displayPoint = self.getDisplayPoint()
if self.popup.visible:
self.popup.hide()
line = self.getText()
self.insertText('(')
(name, argspec, tip) = jintrospect.getCallTipJava(line, self.locals)
if tip:
self.tip.showTip(tip, displayPoint)
def showPopup(self, event=None):
"""show code completion popup"""
try:
line = self.getText()
list = jintrospect.getAutoCompleteList(line, self.locals, includeSingle=self.include_single_underscore_methods, includeDouble=self.include_double_underscore_methods)
if len(list) > 0:
self.popup.showMethodCompletionList(list, self.getDisplayPoint())
except Exception, e:
print >> sys.stderr, "Error getting completion list: ", e