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

Method button_states

src/__init__.py:9228–9275  ·  view source on GitHub ↗

Return the on/off state names for button widgets. A button may have 'normal' or 'pressed down' appearances. While the 'Off' state is usually called like this, the 'On' state is often given a name relating to the functional context.

(self)

Source from the content-addressed store, hash-verified

9226 return True # all done
9227
9228 def button_states(self):
9229 """Return the on/off state names for button widgets.
9230
9231 A button may have 'normal' or 'pressed down' appearances. While the 'Off'
9232 state is usually called like this, the 'On' state is often given a name
9233 relating to the functional context.
9234 """
9235 if self.field_type not in (2, 5):
9236 return None # no button type
9237 if hasattr(self, "parent"): # field already exists on page
9238 doc = self.parent.parent
9239 else:
9240 return
9241 xref = self.xref
9242 states = {"normal": None, "down": None}
9243 APN = doc.xref_get_key(xref, "AP/N")
9244 if APN[0] == "dict":
9245 nstates = []
9246 APN = APN[1][2:-2]
9247 apnt = APN.split("/")[1:]
9248 for x in apnt:
9249 nstates.append(x.split()[0])
9250 states["normal"] = nstates
9251 if APN[0] == "xref":
9252 nstates = []
9253 nxref = int(APN[1].split(" ")[0])
9254 APN = doc.xref_object(nxref)
9255 apnt = APN.split("/")[1:]
9256 for x in apnt:
9257 nstates.append(x.split()[0])
9258 states["normal"] = nstates
9259 APD = doc.xref_get_key(xref, "AP/D")
9260 if APD[0] == "dict":
9261 dstates = []
9262 APD = APD[1][2:-2]
9263 apdt = APD.split("/")[1:]
9264 for x in apdt:
9265 dstates.append(x.split()[0])
9266 states["down"] = dstates
9267 if APD[0] == "xref":
9268 dstates = []
9269 dxref = int(APD[1].split(" ")[0])
9270 APD = doc.xref_object(dxref)
9271 apdt = APD.split("/")[1:]
9272 for x in apdt:
9273 dstates.append(x.split()[0])
9274 states["down"] = dstates
9275 return states
9276
9277 @property
9278 def next(self):

Callers 1

on_stateMethod · 0.95

Calls 3

xref_get_keyMethod · 0.80
xref_objectMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected