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

Method _checker

src/__init__.py:9060–9079  ·  view source on GitHub ↗

Any widget type checks.

(self)

Source from the content-addressed store, hash-verified

9058 return
9059
9060 def _checker(self):
9061 """Any widget type checks.
9062 """
9063 if self.field_type not in range(1, 8):
9064 raise ValueError("bad field type")
9065
9066 # if setting a radio button to ON, first set Off all buttons
9067 # in the group - this is not done by MuPDF:
9068 if self.field_type == mupdf.PDF_WIDGET_TYPE_RADIOBUTTON and self.field_value not in (False, "Off") and hasattr(self, "parent"):
9069 # so we are about setting this button to ON/True
9070 # check other buttons in same group and set them to 'Off'
9071 doc = self.parent.parent
9072 kids_type, kids_value = doc.xref_get_key(self.xref, "Parent/Kids")
9073 if kids_type == "array":
9074 xrefs = tuple(map(int, kids_value[1:-1].replace("0 R","").split()))
9075 for xref in xrefs:
9076 if xref != self.xref:
9077 doc.xref_set_key(xref, "AS", "/Off")
9078 # the calling method will now set the intended button to on and
9079 # will find everything prepared for correct functioning.
9080
9081 def _parse_da(self):
9082 """Extract font name, size and color from default appearance string (/DA object).

Callers 1

_validateMethod · 0.95

Calls 2

xref_get_keyMethod · 0.80
xref_set_keyMethod · 0.80

Tested by

no test coverage detected