Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #305 from slarosa/master
python console: fix AttributeError, method PythonEdit.createStandardContextMenu doesn't exists
  • Loading branch information
brushtyler committed Oct 28, 2012
2 parents 46655cf + 50f3352 commit 8db3bdd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
4 changes: 2 additions & 2 deletions python/console_help/help.htm
@@ -1,5 +1,5 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "httpqrc://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="httpqrc://www.w3.org/1999/xhtml">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Help Python Console</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Expand Down
22 changes: 14 additions & 8 deletions python/console_output.py
Expand Up @@ -108,6 +108,9 @@ def __init__(self, parent=None):
self.SendScintilla(QsciScintilla.SCI_SETWRAPMODE, 2)
self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)

self.runShortcut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_E), self)
self.runShortcut.activated.connect(self.enteredSelected)

def refreshLexerProperties(self):
self.setLexers()

Expand Down Expand Up @@ -143,18 +146,16 @@ def clearConsole(self):

def contextMenuEvent(self, e):
menu = QMenu(self)
runAction = menu.addAction("Enter Selected")
copyAction = menu.addAction("Copy CTRL+C")
iconRun = QIcon(":/images/console/iconRunConsole.png")
runAction = menu.addAction(iconRun, "Enter Selected", self.enteredSelected, QKeySequence(Qt.CTRL + Qt.Key_E))
menu.addSeparator()
copyAction = menu.addAction("Copy", self.copy, QKeySequence.Copy)
runAction.setEnabled(False)
copyAction.setEnabled(False)
if self.hasSelectedText():
runAction.setEnabled(True)
copyAction.setEnabled(True)
action = menu.exec_(self.mapToGlobal(e.pos()))
if action == runAction:
cmd = self.selectedText()
self.edit.insertFromDropPaste(cmd)
self.edit.entered()
if action == copyAction:
self.copy()

def copy(self):
"""Copy text to clipboard... or keyboard interrupt"""
Expand All @@ -165,3 +166,8 @@ def copy(self):
else:
self.emit(SIGNAL("keyboard_interrupt()"))

def enteredSelected(self):
cmd = self.selectedText()
self.edit.insertFromDropPaste(cmd)
self.edit.entered()

15 changes: 6 additions & 9 deletions python/console_sci.py
Expand Up @@ -119,9 +119,7 @@ def __init__(self, parent=None):
self.newShortcutCAS.activated.connect(self.showHistory)
self.connect(self, SIGNAL('userListActivated(int, const QString)'),
self.completion_list_selected)

self.createStandardContextMenu()


def showHistory(self):
self.showUserList(1, QStringList(self.history))

Expand Down Expand Up @@ -413,13 +411,12 @@ def keyPressEvent(self, e):

def contextMenuEvent(self, e):
menu = QMenu(self)
copyAction = menu.addAction("Copy CTRL+C")
pasteAction = menu.addAction("Paste CTRL+V")
copyAction = menu.addAction("Copy", self.copy, QKeySequence.Copy)
pasteAction = menu.addAction("Paste", self.paste, QKeySequence.Paste)
copyAction.setEnabled(False)
if self.hasSelectedText():
copyAction.setEnabled(True)
action = menu.exec_(self.mapToGlobal(e.pos()))
if action == copyAction:
self.copy()
elif action == pasteAction:
self.paste()

def mousePressEvent(self, e):
"""
Expand Down

0 comments on commit 8db3bdd

Please sign in to comment.