Skip to content

Commit 8db3bdd

Browse files
committed
Merge pull request #305 from slarosa/master
python console: fix AttributeError, method PythonEdit.createStandardContextMenu doesn't exists
2 parents 46655cf + 50f3352 commit 8db3bdd

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

python/console_help/help.htm

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "httpqrc://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2-
<html xmlns="httpqrc://www.w3.org/1999/xhtml">
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml">
33
<head>
44
<title>Help Python Console</title>
55
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

python/console_output.py

+14-8
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ def __init__(self, parent=None):
108108
self.SendScintilla(QsciScintilla.SCI_SETWRAPMODE, 2)
109109
self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)
110110

111+
self.runShortcut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_E), self)
112+
self.runShortcut.activated.connect(self.enteredSelected)
113+
111114
def refreshLexerProperties(self):
112115
self.setLexers()
113116

@@ -143,18 +146,16 @@ def clearConsole(self):
143146

144147
def contextMenuEvent(self, e):
145148
menu = QMenu(self)
146-
runAction = menu.addAction("Enter Selected")
147-
copyAction = menu.addAction("Copy CTRL+C")
149+
iconRun = QIcon(":/images/console/iconRunConsole.png")
150+
runAction = menu.addAction(iconRun, "Enter Selected", self.enteredSelected, QKeySequence(Qt.CTRL + Qt.Key_E))
151+
menu.addSeparator()
152+
copyAction = menu.addAction("Copy", self.copy, QKeySequence.Copy)
148153
runAction.setEnabled(False)
154+
copyAction.setEnabled(False)
149155
if self.hasSelectedText():
150156
runAction.setEnabled(True)
157+
copyAction.setEnabled(True)
151158
action = menu.exec_(self.mapToGlobal(e.pos()))
152-
if action == runAction:
153-
cmd = self.selectedText()
154-
self.edit.insertFromDropPaste(cmd)
155-
self.edit.entered()
156-
if action == copyAction:
157-
self.copy()
158159

159160
def copy(self):
160161
"""Copy text to clipboard... or keyboard interrupt"""
@@ -165,3 +166,8 @@ def copy(self):
165166
else:
166167
self.emit(SIGNAL("keyboard_interrupt()"))
167168

169+
def enteredSelected(self):
170+
cmd = self.selectedText()
171+
self.edit.insertFromDropPaste(cmd)
172+
self.edit.entered()
173+

python/console_sci.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@ def __init__(self, parent=None):
119119
self.newShortcutCAS.activated.connect(self.showHistory)
120120
self.connect(self, SIGNAL('userListActivated(int, const QString)'),
121121
self.completion_list_selected)
122-
123-
self.createStandardContextMenu()
124-
122+
125123
def showHistory(self):
126124
self.showUserList(1, QStringList(self.history))
127125

@@ -413,13 +411,12 @@ def keyPressEvent(self, e):
413411

414412
def contextMenuEvent(self, e):
415413
menu = QMenu(self)
416-
copyAction = menu.addAction("Copy CTRL+C")
417-
pasteAction = menu.addAction("Paste CTRL+V")
414+
copyAction = menu.addAction("Copy", self.copy, QKeySequence.Copy)
415+
pasteAction = menu.addAction("Paste", self.paste, QKeySequence.Paste)
416+
copyAction.setEnabled(False)
417+
if self.hasSelectedText():
418+
copyAction.setEnabled(True)
418419
action = menu.exec_(self.mapToGlobal(e.pos()))
419-
if action == copyAction:
420-
self.copy()
421-
elif action == pasteAction:
422-
self.paste()
423420

424421
def mousePressEvent(self, e):
425422
"""

0 commit comments

Comments
 (0)