PySimpleGUI / PySimpleGUI/PySimpleGUI

[Bug] Spin element isn't triggering events in realtime

未關閉
#4,258 5 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

enhancement
主要語言
Python
星號
13.8k
分支
1.8k
PR 合併指標
30 天內沒有已合併 PR

描述

Type of Issue (Enhancement, Error, Bug, Question)

The Spin element's up/down buttons update their value as you keep them pressed and yet they don't seem to trigger any events accordingly.


Operating System

Windows 10

PySimpleGUI Port (tkinter, Qt, Wx, Web)

tkinter


Versions

Python version (sg.sys.version)

3.9.4 (tags/v3.9.4:1f2e308, Apr 6 2021, 13:40:21) [MSC v.1928 64 bit (AMD64)]

PySimpleGUI Version (sg.__version__)

4.40.0

GUI Version (tkinter (sg.tclversion_detailed), PySide2, WxPython, Remi)

tkinter version: 8.6.9


Your Experience In Months or Years (optional)

Python programming experience: 0.5 month

Programming experience overall: 10 years

Have used another Python GUI Framework? (tkinter, Qt, etc) (yes/no is fine): no

Anything else you think would be helpful?:
My general dev knowledge is pretty broad - but not very deep.


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 Spin element's up/down buttons update their value as you keep them pressed - similar to RealTimeButton elements - and yet they don't seem to trigger any events like the RealTimeButtons; using enable_events=True only triggers once - and only once the click is released.

I searched for anyone else having a similar problem, but the only one I could find was from back when the up/down button didn't trigger at all.

Code To Duplicate

import PySimpleGUI as sg

endFrame = 0
endSpinF = 0

layout = [[
  sg.Spin(key='endSpinF',values=[i for i in range(0,1000)],initial_value=endFrame,size=(4,0),enable_events=True),
  sg.Text(endFrame,key='endFrame',size=(4,0))
]]

window = sg.Window('Spin Event Test',layout)

while True:
  event, values = window.read()

  if event == 'Exit' or event == sg.WIN_CLOSED:
    break

  elif event == 'endSpinF':
    last_endSpinF = endSpinF
    endSpinF = values['endSpinF']
    #this part is used to handle the under/overflow of the Spin (so in the real world application the update at the end would happen to the Spin itself)
    if (last_endSpinF == 0 and endSpinF == 0) or endSpinF < last_endSpinF:
      endFrame = endFrame-1
    else:
      endFrame = endFrame+1

    window['endFrame'].update(endFrame)

window.close()

Screenshot, Sketch, or Drawing

貢獻指南

開啟貢獻指南

從這裡開始

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

研究方向

先使用 Python 3.9.4、PySimpleGUI 4.40.0 和 tkinter port 執行提供的最小範例,接著追蹤 Spin 在其按鈕持續按下時如何處理 enable_events。在放開點擊之前,重複的向上/向下值變更會產生相應事件,同時現有範例仍能繼續運作,即表示完成。

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

評估

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

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

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