PySimpleGUI / PySimpleGUI/PySimpleGUI
[Bug] Modal windows not working on MacOS
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 13.8k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
Type of Issue (Enhancement, Error, Bug, Question)
Bug
Operating System
MacOS Catalina (Version 10.15.7)
PySimpleGUI Port (tkinter, Qt, Wx, Web)
tkinter
Versions
Python version: 3.8.3 (v3.8.3:6f8c8320e9, May 13 2020, 16:29:34)
[Clang 6.0 (clang-600.0.57)]
port: tkinter
tkinter version: 8.6.8
PySimpleGUI version: 4.45.0
PySimpleGUI filename: /Users/Nacho/PycharmProjects/test/venv/lib/python3.8/site-packages/PySimpleGUI/PySimpleGUI.py
Your Experience In Months or Years (optional)
Years Python programming experience: 3 years
Years Programming experience overall: 20 years
Have used another Python GUI Framework? Qt
Anything else you think would be helpful?
Troubleshooting
These items may solve your problem. Please check those you've done by changing - [ ] to - [X]
- Searched main docs for your problem www.PySimpleGUI.org
- Looked for Demo Programs that are similar to your goal Demos.PySimpleGUI.org
- If not tkinter - looked for Demo Programs for specific port
- For non tkinter - Looked at readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
- Run your program outside of your debugger (from a command line)
- Searched through Issues (open and closed) to see if already reported Issues.PySimpleGUI.org
- Tried using the PySimpleGUI.py file on GitHub. Your problem may have already been fixed but not released
Detailed Description
The modal parameter for a sg.Window class constructor does not have any effect whatsoever in MacOS.
There is no error message or warning, the windows are simply non-modal, you can click a "parent" window after a "child" window, that is supposed to be modal, is opened.
According to the PySimpleGUI documentation:
NOTE - as of PySimpleGUI 4.25.0 Modal Windows are supported! By default the popup windows that block will be marked Modal by default.
But that does not seem to hold true. Calling any popup function like sg.popup, sg.popup_ok, etc... using or not the modal parameter, does not cause any changes to the "modality" of a window; meaning you are able to interact with the "caller" window completely, although events are not processed while the "child" window is open.
Code To Duplicate
A short program that isolates and demonstrates the problem (Do not paste your massive program, but instead 10-20 lines that clearly show the problem)
import PySimpleGUI as sg
window = sg.Window(title='Parent Window',
layout=[[sg.Button(button_text='Open child 1', key='-OPEN1-'),
sg.Button(button_text='Open child 2', key='-OPEN2-')],
[sg.CloseButton(button_text='Close')]])
while True:
event, values = window.read()
if event == 'Close' or event == sg.WIN_CLOSED:
break
if event == '-OPEN1-':
sg.popup_ok('Child one', modal=True)
elif event == '-OPEN2-':
sg.Window(title='Child 2',
layout=[[sg.Text('I am the second child')],
[sg.CloseButton(button_text='Close')]],
modal=True).read(close=True)
window.close()
Screenshot, Sketch, or Drawing
Note that in the following screenshot, produced by the sample program above, features the child window in the back of the parent window, although the child window is supposed to be modal. The parent window should not have been able to come to the front when clicking on it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied reproduction on macOS Catalina with Python 3.8.3, PySimpleGUI 4.45.0, and the tkinter port, then trace the existing handling for the Window modal parameter and popup functions. Done means the child window remains modal on macOS: the parent cannot be brought to the front or interacted with until the child closes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- desktop, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100