MCPcopy Index your code
hub / github.com/rawpython/remi / onchange

Method onchange

remi/gui.py:3409–3440  ·  view source on GitHub ↗
(self, value)

Source from the content-addressed store, hash-verified

3407 @decorate_set_on_listener("(self, emitter, value)")
3408 @decorate_event
3409 def onchange(self, value):
3410 _type = int
3411 try:
3412 _, _, _ = int(value), int(self.attributes['min']), int(self.attributes['max'])
3413 except:
3414 _type = float
3415
3416 try:
3417 _value = max(_type(value), _type(self.attributes['min']))
3418 _value = min(_type(_value), _type(self.attributes['max']))
3419
3420 self.disable_update()
3421 self.attributes['value'] = str(_value)
3422 self.enable_update()
3423
3424 #this is to force update in case a value out of limits arrived
3425 # and the limiting ended up with the same previous value stored in self.attributes
3426 # In this case the limitation gets not updated in browser
3427 # (because not triggering is_changed). So the update is forced.
3428 if _type(value) != _value:
3429 self.attributes.onchange()
3430 except:
3431 #if the value conversion fails the client gui is updated with its previous value
3432 _type = int
3433 try:
3434 _, _, _ = int(self.attributes['value']), int(self.attributes['min']), int(self.attributes['max'])
3435 except:
3436 _type = float
3437 _value = _type(self.attributes['value'])
3438 self.attributes.onchange()
3439
3440 return (_value, )
3441
3442
3443class Slider(Input):

Callers

nothing calls this directly

Calls 3

disable_updateMethod · 0.80
enable_updateMethod · 0.80
onchangeMethod · 0.45

Tested by

no test coverage detected