PySimpleGUI / PySimpleGUI/PySimpleGUI

Enhancement - Demo Program

未關閉
#6,284 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

Bug Demo Programs Port - TK
主要語言
Python
星號
13.8k
分支
1.8k
PR 合併指標
30 天內沒有已合併 PR

描述

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.

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 Demo_Multiple_Windows_read_all_windows_25_lines.py 開始,使用 tkinter port 執行提供的雙視窗範例。在視窗未暫停時關閉該視窗,以重現應用程式錯誤,然後將行為與回報的修正進行比較。當關閉視窗不再導致應用程式錯誤,且 demo 的事件迴圈仍能正確結束時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
desktop
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。