Pysimplegui: It seems that float values are not supported by Slider

Created on 5 Jan 2019  ·  3Comments  ·  Source: PySimpleGUI/PySimpleGUI

When executing:

import PySimpleGUI as sg
layout = [[sg.Slider(change_submits=True, range=(-1, 1), 
                resolution=0.01, orientation='h', default_value=-0.1)]]       

window = sg.Window('Window that stays open').Layout(layout)   
while True:       
    event, values = window.Read()
    if event is None or event == 'Exit':
        break
    print(values[0])

window.Close()

I expect to see floats on the console. Instead I only see either -1, 0 or 1.

Bug Done - Download from GitHub

Most helpful comment

Sorry about that.... Needed to get the value differently.

I've checked in a change into the Master Branch. To get the fitx download a new PySimpleGUI.py file and place into your application folder.

All 3 comments

Sorry about that.... Needed to get the value differently.

I've checked in a change into the Master Branch. To get the fitx download a new PySimpleGUI.py file and place into your application folder.

Note that for PySimpleGUIQt... it only returns floats. The user is required to do the necessary math to convert int to float in their code. If you have plans to possibly move to Qt, then I would suggest setting the slider to go from 0 to 100 and then divide by 100 after you get the value.

Released to PyPI so closing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MikeTheWatchGuy picture MikeTheWatchGuy  ·  5Comments

ihouses picture ihouses  ·  6Comments

MikeTheWatchGuy picture MikeTheWatchGuy  ·  6Comments

ECOM-Klaus picture ECOM-Klaus  ·  4Comments

flowerbug picture flowerbug  ·  4Comments