+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

Python script terminates itself after calling a subprocess withing an IF statement

发布于2021-03-06 18:32     阅读(402)     评论(0)     点赞(25)     收藏(3)


0

1

2

3

4

5

6

7

I am working on a GUi based study manager, and when a user clicks on a button, the script opens a chrome window containing a mathemathics exercises repo. The script runs fine, but upon clicking on the button, it terminates itself. The GUI is being created via PySimpleGUI.

This is the layout portion of the code, containing the button:

layout = [[sg.Text('Your typed chars appear here:')],
          [sg.Text('It. Lit. pages', size=(15, 1)), sg.Input(key='str_ITLP')],
          [sg.Text('MAT quiz pages', size=(15, 1)), sg.Input(key='str_MATQ')],
          [sg.Text('Math exercises', size=(15, 1)), sg.Input(key='str_MATH')],
          [sg.Button('Show'), sg.Button('Exit'), sg.Button('Maths exercise repo')]]
window = sg.Window('Pattern 2B', layout)

This is the subprocess code:

if event == 'Maths exercises repo':
        sp = subprocess.Popen([CHROME, 'url'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

What I would need to happen is that the script keeps running (i.e. the GUI doesn't just nuke itself upon opening chrome) so that I may continue using the ohter functions of the script.

P. S. Yes, both subprocess and the chrome path are imported within the script, given that chrome actually runs.

P. P. S. I am an absolute python beginner and this is literally my first script, so please show mercy towards my code.


解决方案


暂无回答

0

1

2

3

4



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接: https://www.pythonheidong.com/blog/article/879592/b8beeca1189a0d6e3bff/

来源: python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

25 0
收藏该文
已收藏

评论内容:(最多支持255个字符)