[ Bug] sg.WIN_CLOSED event is not generated, after catching mouse down events in same window for read_all_windows calls
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 28/100
Línea de trabajo
Reproduce el problema con el ejemplo proporcionado usando sg.read_all_windows, un Graph con change_submits y drag_submits, y el port de tkinter en macOS. Comienza con la implementación de read_all_windows en PySimpleGUI.py y el manejo de eventos de Graph. Se considera terminado cuando hacer clic en Graph y después en el icono de cierre de la ventana produce sg.WIN_CLOSED y sale del bucle de eventos como se espera.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Type of Issue (Enhancement, Error, Bug, Question)
Bug
Operating System
MacOs 10.14.6
PySimpleGUI Port (tkinter, Qt, Wx, Web)
tkinter
Versions
Version information can be obtained by calling sg.main_get_debug_data()
Or you can print each version shown in ()
Python version: 3.12.2 | packaged by conda-forge | (main, Feb 16 2024, 21:00:12) [Clang 16.0.6 ]
port: tkinter
tkinter version: 8.6.13
PySimpleGUI version: 4.60.5
PySimpleGUI filename: /Users/cm/anaconda3/envs/sg/lib/python3.12/site-packages/PySimpleGUI/PySimpleGUI.py
Python version (sg.sys.version)
3.12.2 | packaged by conda-forge | (main, Feb 16 2024, 21:00:12) [Clang 16.0.6 ]
PySimpleGUI Version (sg.__version__)
4.60.5
GUI Version (tkinter (sg.tclversion_detailed), PySide2, WxPython, Remi)
8.6.13
Your Experience In Months or Years (optional)
Years Python programming experience
4 years
Years Programming experience overall
30 years
Have used another Python GUI Framework? (tkinter, Qt, etc) (yes/no is fine)
no
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. It is recommend you use the Demo Browser! Demos.PySimpleGUI.org
- None of your GUI code was generated by an AI algorithm like GPT
- 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
- Have upgraded to the latest release of PySimpleGUI on PyPI (lastest official version)
- Tried running the Development Build. Your problem may have already been fixed but not released
Detailed Description
The sg.WIN_CLOSED event is not generated, after catching mouse down events in same window.
If I open a window and if I hit the "window close" icon in the left upper corner (MacOsX), the close event is generated and the window closes and in the event loop is exited.
If I click inside of the window before clicking the close window icon, it will not accept the close window icon any more. If I click on the close icon I get the window, event, value as follows:
<PySimpleGUI.PySimpleGUI.Window object at 0x10a700a10> -GRAPH2-+UP {'-GRAPH2-': (3, 293)}
The coordinate is a coordinate inside of the close window icon.
This only happens after generating a mouse down event in the window.
Code To Duplicate
This pre-formatted code block is all set for you to paste in your bit of code:
import PySimpleGUI as sg
from PIL import Image, ImageDraw, ImageTk
import io
## Indeed, it should be possible to combine the following two create window functions to one general function:
def make_overview_window(h, w):
layout_overview_window = [[sg.Graph(
canvas_size=(h, w),
graph_bottom_left=(0, 0),
graph_top_right=(h, w),
key="-GRAPH1-",
change_submits=True, # mouse click events
background_color='white',
drag_submits=True), ],
[sg.Text(key='info1', size=(60, 1))]]
return sg.Window("Main zoom selection window", layout_overview_window, finalize=True)
if __name__ == '__main__':
# Load JPG images using Pillow
image1 = Image.open('image1.jpg')
h0, w0 = image1.size
print("Size: ", h0, " ", w0)
# Convert images to bytes
img_bytes1 = io.BytesIO()
image1.save(img_bytes1, format='PNG')
window_overview = make_overview_window(h0, w0)
# get the graph element for ease of use later
graph_overview_window = window_overview["-GRAPH1-"]
graph_overview_window.draw_image(data=img_bytes1.getvalue(), location=(0, h0))
while True:
window, event, values = sg.read_all_windows() # timeout=10)
print(window, event, values)
if window == window_overview:
if event == sg.WIN_CLOSED:
break # exit
if event == "-GRAPH1-": # if there's a "Graph" event, then it's a mouse
x, y = values["-GRAPH1-"]
print(event, " ", x, " ", y)
# Close the window
window_overview.close()
Screenshot, Sketch, or Drawing
Watcha Makin?
If you care to share something about your project, it would be awesome to hear what you're building.
- Lenguaje dominante
- Python
- Estrellas
- 13.8k
- Forks
- 1.8k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de PySimpleGUI/PySimpleGUI
-
Bug Done - Install Dev Build (see docs for how) Platform Specific Issue - Linux Port - TK
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
PySimpleGUI/PySimpleGUI#6904 · 15 comentarios ·
-
Bug Demo Programs Done - Install Dev Build (see docs for how) Interoperability Port - TK workaround available
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
PySimpleGUI/PySimpleGUI#6900 · 1 comentario ·
-
Done - Install Dev Build (see docs for how) enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
PySimpleGUI/PySimpleGUI#3251 · 12 comentarios ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 74/100
PySimpleGUI/PySimpleGUI#6906 · 1 comentario · 1 reacción ·
-
Bug Done - Install Dev Build (see docs for how) Port - TK
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
PySimpleGUI/PySimpleGUI#6902 · 1 comentario ·
Todos los issues de PySimpleGUI/PySimpleGUI
Issues similares
-
essnmx good first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
-
[Feature] 奇物选择添加优先级 Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
syfoud/Simulated_Scepter#174 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Giskard-AI/giskard-oss#2840 · 1 comentario ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Abiertoarea: repo bug perceived difficulty: 2
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
yeti-platform/yeti#1380 ·