Skip to content

Commit f534786

Browse files
committed
fix path when you havent opened a file
1 parent 7f3fcbc commit f534786

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

plugins/Code editor/pyeditor.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,13 @@ def savetext(self, fileName):
339339
os.chdir(str(self.path))
340340

341341
def runto(self):
342-
self.path = QtCore.QFileInfo(self.filename).path()
342+
try:
343+
self.path = QtCore.QFileInfo(self.filename).path()
344+
except AttributeError:
345+
pass
343346
g = globals()
344347
os.chdir(str(self.path))
348+
os.path.join(os.path.expanduser('~'), os.path.expandvars(str(self.path)))
345349
script = str(self.codebox.text())
346350
try:
347351
exec (script, g)
@@ -418,6 +422,4 @@ def Author(self):
418422
MainWindow.show()
419423
MainWindow.resize(1000, 600)
420424
if app.exec_():
421-
os.chdir(dn)
422-
423-
425+
os.chdir(dn)

0 commit comments

Comments
 (0)