File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -197,15 +197,20 @@ def iface(self):
197
197
self .edit .commandConsole ('iface' )
198
198
199
199
def openScriptFile (self ):
200
+ settings = QSettings ()
201
+ lastDirPath = settings .value ("/pythonConsole/lastDirPath" ).toString ()
200
202
scriptFile = QFileDialog .getOpenFileName (
201
- self , "Open File" , "" , "Script file (*.py)" )
203
+ self , "Open File" , lastDirPath , "Script file (*.py)" )
202
204
if scriptFile .isEmpty () == False :
203
205
oF = open (scriptFile , 'r' )
204
206
listScriptFile = []
205
207
for line in oF :
206
208
if line != "\n " :
207
209
listScriptFile .append (line )
208
210
self .edit .insertTextFromFile (listScriptFile )
211
+
212
+ lastDirPath = QFileInfo (scriptFile ).path ()
213
+ settings .setValue ("/pythonConsole/lastDirPath" , QVariant (scriptFile ))
209
214
210
215
211
216
def saveScriptFile (self ):
@@ -223,13 +228,10 @@ def saveScriptFile(self):
223
228
is_first_line = True
224
229
for s in listText :
225
230
if s [0 :3 ] in (">>>" , "..." ):
226
- s .replace (">>> " , "" )
227
- s .replace ("... " , "" )
231
+ s .replace (">>> " , "" ).replace ("... " , "" )
228
232
if is_first_line :
229
- # see, no write() in this branch
230
233
is_first_line = False
231
234
else :
232
- # we've just written a line; add a newline
233
235
sF .write ('\n ' )
234
236
sF .write (s )
235
237
sF .close ()
You can’t perform that action at this time.
0 commit comments