@@ -75,6 +75,7 @@ def __init__(self, parent=None):
75
75
sys .stdout = writeOut (self , sys .stdout )
76
76
sys .stderr = writeOut (self , sys .stderr , "traceback" )
77
77
78
+ self .insertInitText ()
78
79
self .setLexers ()
79
80
self .setReadOnly (True )
80
81
@@ -95,7 +96,7 @@ def __init__(self, parent=None):
95
96
self .setCaretLineVisible (True )
96
97
self .setCaretLineBackgroundColor (QColor ("#fcf3ed" ))
97
98
98
- self .setMinimumHeight (80 )
99
+ self .setMinimumHeight (120 )
99
100
100
101
# Folding
101
102
#self.setFolding(QsciScintilla.BoxedTreeFoldStyle)
@@ -117,7 +118,13 @@ def __init__(self, parent=None):
117
118
self .copyShortcut .activated .connect (self .copy )
118
119
self .selectAllShortcut = QShortcut (QKeySequence .SelectAll , self )
119
120
self .selectAllShortcut .activated .connect (self .selectAll )
120
-
121
+
122
+ def insertInitText (self ):
123
+ txtInit = QCoreApplication .translate ("PythonConsole" ,
124
+ "## To access Quantum GIS environment from this console\n "
125
+ "## use qgis.utils.iface object (instance of QgisInterface class). Read help for more info.\n \n " )
126
+ initText = self .setText (txtInit )
127
+
121
128
def refreshLexerProperties (self ):
122
129
self .setLexers ()
123
130
@@ -150,6 +157,7 @@ def getTextFromEditor(self):
150
157
def clearConsole (self ):
151
158
#self.SendScintilla(QsciScintilla.SCI_CLEARALL)
152
159
self .setText ('' )
160
+ self .insertInitText ()
153
161
154
162
def contextMenuEvent (self , e ):
155
163
menu = QMenu (self )
@@ -175,6 +183,7 @@ def contextMenuEvent(self, e):
175
183
self .selectAll ,
176
184
QKeySequence .SelectAll )
177
185
runAction .setEnabled (False )
186
+ clearAction .setEnabled (False )
178
187
copyAction .setEnabled (False )
179
188
pastebinAction .setEnabled (False )
180
189
selectAllAction .setEnabled (False )
@@ -184,6 +193,7 @@ def contextMenuEvent(self, e):
184
193
pastebinAction .setEnabled (True )
185
194
if not self .text () == '' :
186
195
selectAllAction .setEnabled (True )
196
+ clearAction .setEnabled (True )
187
197
action = menu .exec_ (self .mapToGlobal (e .pos ()))
188
198
189
199
def copy (self ):
@@ -214,14 +224,15 @@ def keyPressEvent(self, e):
214
224
215
225
def pastebin (self ):
216
226
import urllib2 , urllib
217
- #listText = self.getTextFromEditor()
218
227
listText = self .selectedText ().split ('\n ' )
219
228
getCmd = []
220
- for s in listText :
221
- if s [0 :3 ] in (">>>" , "..." ):
222
- if not s [4 ] == "_" :
223
- s .replace (">>> " , "" ).replace ("... " , "" )
224
- getCmd .append (unicode (s ))
229
+ for strLine in listText :
230
+ if strLine != "" :
231
+ #if s[0:3] in (">>>", "..."):
232
+ # filter for special command (_save,_clear) and comment
233
+ if strLine [4 ] != "_" and strLine [:2 ] != "##" :
234
+ strLine .replace (">>> " , "" ).replace ("... " , "" )
235
+ getCmd .append (unicode (strLine ))
225
236
pasteText = u"\n " .join (getCmd )
226
237
url = 'http://codepad.org'
227
238
values = {'lang' : 'Python' ,
0 commit comments