本文整理汇总了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