MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / on_state

Method on_state

src/__init__.py:9281–9300  ·  view source on GitHub ↗

Return the "On" value for button widgets. This is useful for radio buttons mainly. Checkboxes will always return "Yes". Radio buttons will return the string that is unequal to "Off" as returned by method button_states(). If the radio button is new / being cre

(self)

Source from the content-addressed store, hash-verified

9279 return self._annot.next
9280
9281 def on_state(self):
9282 """Return the "On" value for button widgets.
9283
9284 This is useful for radio buttons mainly. Checkboxes will always return
9285 "Yes". Radio buttons will return the string that is unequal to "Off"
9286 as returned by method button_states().
9287 If the radio button is new / being created, it does not yet have an
9288 "On" value. In this case, a warning is shown and True is returned.
9289 """
9290 if self.field_type not in (2, 5):
9291 return None # no checkbox or radio button
9292 bstate = self.button_states()
9293 if bstate is None:
9294 bstate = dict()
9295 for k in bstate.keys():
9296 for v in bstate[k]:
9297 if v != "Off":
9298 return v
9299 message("warning: radio button has no 'On' value.")
9300 return True
9301
9302 def reset(self):
9303 """Reset the field value to its default.

Callers 2

test_2391Function · 0.80
test_4055Function · 0.80

Calls 2

button_statesMethod · 0.95
messageFunction · 0.70

Tested by 2

test_2391Function · 0.64
test_4055Function · 0.64