Pysimplegui: Popup() freezes until the following subprocess() command is finished

Created on 12 Dec 2019  路  10Comments  路  Source: PySimpleGUI/PySimpleGUI

Type of Issues (Bug)

Operating System: Manjaro arch linux kde

Python version: Python 3.6 and python 3.8

PySimpleGUI Port and Version: tkinter 4.11.0

Your Experience Levels In Months or Years

_________ Python programming experience
_________ Programming experience overall
_________ Have used another Python GUI Framework (tkiner, Qt, etc) previously (yes/no is fine)?

You have completed these steps:

  • [x] Read instructions on how to file an Issue
  • [x] Searched through main docs http://www.PySimpleGUI.org for your problem
  • [x] Searched through the readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
  • [x] Looked for Demo Programs that are similar to your goal http://www.PySimpleGUI.com
  • [x] Note that there are also Demo Programs under each port on GitHub
  • [x] Run your program outside of your debugger (from a command line)
  • [x] Searched through Issues (open and closed) to see if already reported

In below code if i use a normal popup followed by a subprocess command it will freeze until subprocess finished, but this is not the case with using a normal window() and close it by window.Close() before proceeding

i believe the popup function has a Window() object and needs to be closed once or before the function return

Code or partial code causing the problem

import PySimpleGUI as sg
import subprocess

def do_something():
    # cmd = 'python -m pip install fakeModule'
    cmd = 'sleep 3' # consume time
    r = subprocess.run(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    print(r.stdout.decode())

sg.popup('Popup will freeze until next function finish', title='sg.popup')
do_something()

window=sg.Window('normal window', layout=[[sg.T('this window will close normally no problem')], [sg.Ok()]])
window()
window.close() # this line close window properly
do_something()

print('End of script')
Bug Done - Download from GitHub

All 10 comments

Hmmmm... must be something with the CloseButton that is used in Popup but very little other places.

It's odd that it doesn't close the window. It's working OK on Windows.

I added a time.sleep(5) after the popup and it closes the window with no problem. That should be a similar thing to the test you're running.

I'll try it with Linux to see what the difference might be.

Can you try with a sleep as a test as that should do the same kind of delay?

I could see problems if the popup was non-blocking, but not with a normal popup.

I just tried with time.sleep(3) it did the same, popup freezes for 3 seconds

Just tried it on Linux and was able to duplicate it.

Fixed. I'll investigate what's up with the CloseButtons. Popups were the last place they're used in any of the PySimpleGUI code. Care has been exercised to no longer use them in examples. They're from an era long ago and really weren't need in this case.

Get a new PySimpleGUI.py file from GitHub and you should be good to go.

Version you want is 4.11.0.2

Thanks a lot, it works as expected

This is a pretty serious problem in my opinion, but it's not been reported before so I guess no one has run into it until now. I'm at a loss as to how long it's been this way. I'll know more when I look at the CloseButton code. I would love to remove it entirely, but I can't as who knows how much it's used by the install base.

Actually, I can tell there are 138 different files on GitHub that are using PySimpleGUI's CloseButton. WOW... that's kinda weird to see.

so CloseButton will stay a little longer, no harm, better not to break someone's code

Yea.... I just need to fix it now is all.

Fixed in 4.12.0 and released to PyPI last night. The CloseButton problem remains but that's in another issue.

Was this page helpful?
0 / 5 - 0 ratings