当然,您只需将范围定义为 85 到 99 并将分辨率设置为 0.1
layout = [[sg.Slider(range=(85.0,99.9), default_value=99.7, resolution=.1, size=(40,15), orientation='horizontal')]]
此处的文档中对此进行了讨论:
https ://pysimplegui.readthedocs.io/en/latest/#slider-element
IDE 中显示的文档字符串还显示范围可以是浮点数,并将其他值也列为可能是浮点数。如果它们没有出现在您的 IDE 中,请使用 Python 的帮助系统
python
Python 3.6.2 |Anaconda, Inc.| (default, Sep 19 2017, 08:03:39) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import PySimpleGUI as sg
>>> help(sg.Slider)
Help on class Slider in module PySimpleGUI:
class Slider(Element)
| A slider, horizontal or vertical
|
| Method resolution order:
| Slider
| Element
| builtins.object
|
| Methods defined here:
|
... removed a couple of methods to show just the init method
|
| __init__(self, range=(None, None), default_value=None, resolution=None, tick_interval=None, orientation=None, disable_number_display=False, border_width=None, relief=None, change_submits=False, enable_events=False, disabled=False, size=(None, None), font=None, background_color=None, text_color=None, key=None, pad=None, tooltip=None, visible=True)
| :param range: Union[Tuple[int, int], Tuple[float, float]] slider's range (min value, max value)
| :param default_value: Union[int, float] starting value for the slider
| :param resolution: Union[int, float] the smallest amount the slider can be moved
| :param tick_interval: Union[int, float] how often a visible tick should be shown next to slider
| :param orientation: (str) 'horizontal' or 'vertical' ('h' or 'v' also work)
| :param disable_number_display: (bool) if True no number will be displayed by the Slider Element
| :param border_width: (int) width of border around element in pixels