Skip to content
Permalink
Browse files

added remember last used dir for open tool in python console

  • Loading branch information
slarosa committed Sep 13, 2012
1 parent 39db80a commit c0c8f81efbab03ac0b4d5ee63133455bc72bcd3d
Showing with 7 additions and 5 deletions.
  1. +7 −5 python/console.py
@@ -197,15 +197,20 @@ def iface(self):
self.edit.commandConsole('iface')

def openScriptFile(self):
settings = QSettings()
lastDirPath = settings.value("/pythonConsole/lastDirPath").toString()
scriptFile = QFileDialog.getOpenFileName(
self, "Open File", "", "Script file (*.py)")
self, "Open File", lastDirPath, "Script file (*.py)")
if scriptFile.isEmpty() == False:
oF = open(scriptFile, 'r')
listScriptFile = []
for line in oF:
if line != "\n":
listScriptFile.append(line)
self.edit.insertTextFromFile(listScriptFile)

lastDirPath = QFileInfo(scriptFile).path()
settings.setValue("/pythonConsole/lastDirPath", QVariant(scriptFile))


def saveScriptFile(self):
@@ -223,13 +228,10 @@ def saveScriptFile(self):
is_first_line = True
for s in listText:
if s[0:3] in (">>>", "..."):
s.replace(">>> ", "")
s.replace("... ", "")
s.replace(">>> ", "").replace("... ", "")
if is_first_line:
# see, no write() in this branch
is_first_line = False
else:
# we've just written a line; add a newline
sF.write('\n')
sF.write(s)
sF.close()

0 comments on commit c0c8f81

Please sign in to comment.
You can’t perform that action at this time.