hide window, open file not folder

This commit is contained in:
j 2016-02-01 00:49:25 +05:30
parent e0ba5ec2b2
commit 0e3794e6a3
2 changed files with 13 additions and 2 deletions

View file

@ -61,6 +61,12 @@ def page(pdf, page):
'-scale-to', '1024', '-cropbox', '-scale-to', '1024', '-cropbox',
os.path.join(tmp, 'page') os.path.join(tmp, 'page')
] ]
if sys.platform == 'win32':
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = subprocess.SW_HIDE
p = subprocess.Popen(cmd, close_fds=True, startupinfo=startupinfo)
else:
p = subprocess.Popen(cmd, close_fds=True) p = subprocess.Popen(cmd, close_fds=True)
p.wait() p.wait()
image = glob('%s/*' % tmp) image = glob('%s/*' % tmp)
@ -229,6 +235,11 @@ def extract_text(pdf):
if sys.platform == 'win32': if sys.platform == 'win32':
pdf = get_short_path_name(pdf) pdf = get_short_path_name(pdf)
cmd = ['pdftotext', pdf, '-'] cmd = ['pdftotext', pdf, '-']
if sys.platform == 'win32':
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = subprocess.SW_HIDE
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, startupinfo=startupinfo)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate() stdout, stderr = p.communicate()
stdout = stdout.decode() stdout = stdout.decode()

View file

@ -368,7 +368,7 @@ def open_folder(folder=None, path=None):
elif sys.platform.startswith('linux'): elif sys.platform.startswith('linux'):
cmd += ['xdg-open', folder] cmd += ['xdg-open', folder]
elif sys.platform == 'win32': elif sys.platform == 'win32':
path = '\\'.join(folder.split('/')) path = '\\'.join(path.split('/'))
os.system('explorer.exe /select,"%s"' % path) os.system('explorer.exe /select,"%s"' % path)
cmd = [] cmd = []
else: else: