Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Enhancement - Demo Program

Abierto
#6,284 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
python
Área
desktop

Línea de trabajo

Comienza con Demo_Multiple_Windows_read_all_windows_25_lines.py y ejecuta el ejemplo proporcionado de dos ventanas con el port de tkinter. Reproduce el error de la aplicación cerrando una ventana mientras no está pausada y, a continuación, compara el comportamiento con la corrección indicada. La tarea estará terminada cuando cerrar ventanas ya no provoque el error de la aplicación y el bucle de eventos de la demo siga terminando correctamente.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Bug Demo Programs Port - TK
Type of Issue (Enhancement, Error, Bug, Question)

Enhancement


Operating System

Wndows 10

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 Interpeter: C:\Users\AndyJ\AppData\Local\Programs\Python\Python311\python.exe
Python version: 3.11.1
Platform: Windows
Platform version: ('10', '10.0.19045', 'SP0', 'Multiprocessor Free')
Port: PySimpleGUI
tkinter version: 8.6.12
PySimpleGUI version: 4.60.4.145
PySimpleGUI filename: C:\Users\AndyJ\AppData\Local\Programs\Python\Python311\Lib\site-packages\PySimpleGUI\PySimpleGUI.py

Your Experience In Months or Years (optional)

Years Python programming experience
2 years
Years Programming experience overall
30 years
Have used another Python GUI Framework? (tkinter, Qt, etc) (yes/no is fine)

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
  • 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 using the PySimpleGUI.py file on GitHub. Your problem may have already been fixed but not released
Detailed Description

demo program - Demo_Multiple_Windows_read_all_windows_25_lines.py - causes application error if a windows is closed when its not paused.
I have worked out a fix - pasted below.
I am not sure if thats the best way to do it, but it works as far as I can see

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:


# Paste your code here
#!/usr/bin/env python
"""
    Demo - Multiple read_all_window(timeout=20)
        A 2-window event loop run in async mode

    Super-simple, 25 lines of code.

    Copyright 2021 PySimpleGUI
"""

import PySimpleGUI as sg

sg.set_options(font='_ 18')

window1 = sg.Window('ONE', [[sg.T('Window 1',size=(30,1),k='-T-')],[sg.B('Run', k='-B-'), sg.B('Exit')]],
                    finalize=True,
                    metadata="Open")

window2 = sg.Window('TWO', [[sg.T('Window 2',k='-T-')],[sg.B('Run', k='-B-'),sg.B('Exit')]], finalize=True,
                    location=(window1.current_location()[0]-250,window1.current_location()[1]),
                    metadata="Open")

i, paused = 0, [False, False]

while True:             # Event Loop
    window, event, values = sg.read_all_windows(timeout=10)
    print(window, event, values) if event != sg.TIMEOUT_EVENT else None
    if window == sg.WIN_CLOSED and event == sg.WIN_CLOSED:
        window1.close()
        window2.close()
        sg.popup_auto_close('Exiting...')
        break
    if event in (sg.WINDOW_CLOSED, 'Exit'):
        window.metadata = 'Closed"'
        window.close()
        continue
    if (not paused[0]) and window1.metadata == 'Open':
        window1['-T-'].update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100))
    if (not paused[1]) and window2.metadata == 'Open':
        window2['-T-'].update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100))
    if event == '-B-':
        paused[0 if window == window1 else 1] = not paused[0 if window == window1 else 1]
        window['-B-'].update('Run' if not paused[0 if window == window1 else 1] else 'Pause')
    i += 1

Screenshot, Sketch, or Drawing

image


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

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PySimpleGUI/PySimpleGUI

Todos los issues de PySimpleGUI/PySimpleGUI

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.