MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / update

Method update

PySimpleGUI/PySimpleGUI.py:3493–3557  ·  view source on GitHub ↗

Changes some of the settings for the Spin Element. Must call `Window.Read` or `Window.Finalize` prior Note that the state can be in 3 states only.... enabled, disabled, readonly even though more combinations are available. The easy way to remember is that if you chan

(self, value=None, values=None, disabled=None, readonly=None, visible=None)

Source from the content-addressed store, hash-verified

3491 return
3492
3493 def update(self, value=None, values=None, disabled=None, readonly=None, visible=None):
3494 """
3495 Changes some of the settings for the Spin Element. Must call `Window.Read` or `Window.Finalize` prior
3496 Note that the state can be in 3 states only.... enabled, disabled, readonly even
3497 though more combinations are available. The easy way to remember is that if you
3498 change the readonly parameter then you are enabling the element.
3499
3500 Changes will not be visible in your window until you call window.read or window.refresh.
3501
3502 If you change visibility, your element may MOVE. If you want it to remain stationary, use the "layout helper"
3503 function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there
3504 when made visible.
3505
3506 :param value: set the current value from list of choices
3507 :type value: (Any)
3508 :param values: set available choices
3509 :type values: List[Any]
3510 :param disabled: disable. Note disabled and readonly cannot be mixed. It must be one OR the other
3511 :type disabled: (bool)
3512 :param readonly: make element readonly. Note disabled and readonly cannot be mixed. It must be one OR the other
3513 :type readonly: (bool)
3514 :param visible: control visibility of element
3515 :type visible: (bool)
3516 """
3517
3518 if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
3519 return
3520
3521 if self._this_elements_window_closed():
3522 _error_popup_with_traceback('Error in Spin.update - The window was closed')
3523 return
3524
3525 if values != None:
3526 old_value = self.TKStringVar.get()
3527 self.Values = values
3528 self.TKSpinBox.configure(values=values)
3529 self.TKStringVar.set(old_value)
3530 if value is not None:
3531 try:
3532 self.TKStringVar.set(value)
3533 self.DefaultValue = value
3534 except:
3535 pass
3536
3537 if readonly is True:
3538 self.Readonly = True
3539 self.TKSpinBox['state'] = 'readonly'
3540 elif readonly is False:
3541 self.Readonly = False
3542 self.TKSpinBox['state'] = 'normal'
3543 if disabled is True:
3544 self.TKSpinBox['state'] = 'disable'
3545 elif disabled is False:
3546 if self.Readonly:
3547 self.TKSpinBox['state'] = 'readonly'
3548 else:
3549 self.TKSpinBox['state'] = 'normal'
3550 self.Disabled = disabled if disabled is not None else self.Disabled

Callers

nothing calls this directly

Calls 7

_widget_was_createdMethod · 0.80
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected