PySimpleGUI / PySimpleGUI/PySimpleGUI
[Bug] Spin element isn't triggering events in realtime
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 13.8k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied minimal example with Python 3.9.4, PySimpleGUI 4.40.0, and the tkinter port, then trace how Spin handles enable_events while its button is held. Done means repeated up/down value changes produce corresponding events before the click is released, while the existing example continues to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100