Skip to content
Permalink
Browse files

[pyqgis-console] running script without shell window (for Windows OS)

- changed runscript icon to contextual menu
  • Loading branch information
slarosa committed Apr 30, 2013
1 parent 4c42cb1 commit 5407616bb791c8e2d04c32af59a29e095e7513df
Showing with 9 additions and 2 deletions.
  1. +9 −2 python/console/console_editor.py
@@ -258,6 +258,7 @@ def get_end_pos(self):
def contextMenuEvent(self, e):
menu = QMenu(self)
iconRun = QgsApplication.getThemeIcon("console/iconRunConsole.png")
iconRunScript = QgsApplication.getThemeIcon("console/iconRunScriptConsole.png")
iconCodePad = QgsApplication.getThemeIcon("console/iconCodepadConsole.png")
iconNewEditor = QgsApplication.getThemeIcon("console/iconTabEditorConsole.png")
iconCommentEditor = QgsApplication.getThemeIcon("console/iconCommentEditorConsole.png")
@@ -275,7 +276,7 @@ def contextMenuEvent(self, e):
runSelected = menu.addAction(iconRun,
"Enter selected",
self.runSelectedCode, 'Ctrl+E')
runScript = menu.addAction(iconRun,
runScript = menu.addAction(iconRunScript,
"Run Script",
self.runScriptCode, 'Shift+Ctrl+E')
menu.addSeparator()
@@ -431,7 +432,13 @@ def _runSubProcess(self, filename, tmp=False):
if dir not in sys.path:
sys.path.append(dir)
try:
p = subprocess.Popen(['python', str(filename)], shell=False, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
## set creationflags for runnning command without shell window
if sys.platform.startswith('win'):
p = subprocess.Popen(['python', str(filename)], shell=False, stdin=subprocess.PIPE,
stderr=subprocess.PIPE, stdout=subprocess.PIPE, creationflags=0x08000000)
else:
p = subprocess.Popen(['python', str(filename)], shell=False, stdin=subprocess.PIPE,
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
out, _traceback = p.communicate()

## Fix interrupted system call on OSX

0 comments on commit 5407616

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