spyoungtech / spyoungtech/FreeSimpleGUI

Bug Found from PySimpleGUI spin element

Open
#41 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
867
Forks
106
Avg merge
1m
Merged PRs (30d)
2

Description

Windows 10
FreeSimpleGUI / PySimpleGUI

The issue is with the sg.Spin element when holding down either up or down arrows buttons continuously.
When you release the mouse button or , the final value would of not been captured internally unless i suppose you do an additional write_event_value or whatever.

sg.Spin(
    values=[i for i in range(21)], 
    size=(2, 1), 
    font="Arial 9", 
    background_color=bgc, 
    enable_events=True, 
    readonly=True, 
    k="Lockout", 
    p=((8, 0), (30, 0))
)

in my code im busy with i cannot click additional time to get the final value using element.get()

So here if i start the default value as 5 and then hold down mouse button on the up arrow button in the spinbox.
When it reaches 20 and i let go the mouse button, i dont get the value 20 from call element.get() and infact while holding down the mouse button there are no more events fired for the spinbox.

They guys from PySimpleGUI actually had the correct code but then messed it up.

In the main __init__.py file find under element spin

if element.ChangeSubmits:
    element.TKSpinBox.configure(command=element._SpinboxSelectHandler)   -----   This needs to be commented out
    # element.TKSpinBox.bind('<ButtonRelease-1>', element._SpinChangedHandler) --- enable this again but use _SpinboxSelectHandler
    # element.TKSpinBox.bind('<Up>', element._SpinChangedHandler) --- leave as is
    # element.TKSpinBox.bind('<Down>', element._SpinChangedHandler) ---- leave as is

For me doing this fixed the spinbox.

Also this internal method _SpinChangedHandler from the class Spin is pointless at the moment as it does not get called anywhere because they changed to using _SpinboxSelectHandler.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the main init.py file at the Spin element's ChangeSubmits handling, then inspect _SpinboxSelectHandler and _SpinChangedHandler. Reproduce the issue by holding a spin arrow and releasing it; done means the final value is captured and the corresponding event is fired without another click.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
desktop
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.