PySimpleGUI / PySimpleGUI/PySimpleGUI
[Bug] MacOS - Clicking on the window's X button does not close the window if enable_close_attempted_event
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 13.8k
- Fork
- 1.8k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
Type of Issue (Enhancement, Error, Bug, Question)
Bug
Operating System
MacOS
PySimpleGUI Port (tkinter, Qt, Wx, Web)
Tkinter
Versions
Python version: 3.10.0 (v3.10.0:b494f5935c, Oct 4 2021, 14:59:20) [Clang 12.0.5 (clang-1205.0.22.11)]
port: tkinter
tkinter version: 8.6.11
PySimpleGUI version: 4.53.0
PySimpleGUI filename: /Users/Nacho/PycharmProjects/test/venv-3.10/lib/python3.10/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? (tkinter, Qt, etc) (yes/no is fine): 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
A sg.Window created with enable_close_attempted_event=True and that uses a timeout upon read like sg.Window.read(timeout=100), does not close when clicking the standard window X button.
This happens ONLY on tkinter 8.6.11 bundled with Python 3.10. If I switch to Python 3.9 (tkinter 8.6.8) the window closes fine.
I also tested this behavior on Windows and could not reproduce it on the latest tkinter on Python 3.10, but the latest there is < 8.6.11.
If I remove the timeout on the sg.Windows.read call, then the window closes fine. It is the combination of using sg.Window.read(timeout=100) and sg.Window(enable_close_attempted_event=True) and tkinter 8.6.11 what sees to cause this strange behavior.
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)
This pre-formatted code block is all set for you to paste in your bit of code:
import PySimpleGUI as sg
window = sg.Window(title='Window',
enable_close_attempted_event=True,
layout=[[sg.Text(text='Test')],
[sg.CloseButton(button_text='Close')]])
while True:
event, values = window.read(timeout=100)
if event in ('Close', sg.WIN_CLOSED):
break
if event == sg.WINDOW_CLOSE_ATTEMPTED_EVENT:
break
window.close()
Screenshot, Sketch, or Drawing
This is on Python 3.10 (tkinter 8.6.11):
https://user-images.githubusercontent.com/7527257/138787863-9262e42f-ef68-452d-b40a-b5bb4c3877e1.mov
This is on Python 3.9 (tkinter 8.6.8):
https://user-images.githubusercontent.com/7527257/138787938-63ffd69f-4861-423e-a8cc-a3fe05c1b1ec.mov
Watcha Makin?
If you care to share something about your project, it would be awesome to hear what you're building.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách chạy ví dụ Window được cung cấp trên macOS với Python 3.10, tkinter 8.6.11, enable_close_attempted_event=True và read(timeout=100), sau đó so sánh với Python 3.9 và tkinter 8.6.8. Theo dõi tương tác giữa thao tác đọc có timeout và lần thử đóng cửa sổ; được xem là hoàn tất khi nút X tiêu chuẩn tạo ra sự kiện đóng như mong đợi và ví dụ kết thúc.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- macos, python
- Lĩnh vực
- desktop
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100