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

Method add_widget

src/__init__.py:10606–10622  ·  view source on GitHub ↗

Add a 'Widget' (form field).

(self, widget: Widget)

Source from the content-addressed store, hash-verified

10604 return self._add_text_marker(q, mupdf.PDF_ANNOT_UNDERLINE)
10605
10606 def add_widget(self, widget: Widget) -> Annot:
10607 """Add a 'Widget' (form field)."""
10608 CheckParent(self)
10609 doc = self.parent
10610 if not doc.is_pdf:
10611 raise ValueError("is no PDF")
10612 widget._validate()
10613 annot = self._addWidget(widget.field_type, widget.field_name)
10614 if not annot:
10615 return None
10616 annot.thisown = True
10617 annot.parent = weakref.proxy(self) # owning page object
10618 self._annot_refs[id(annot)] = annot
10619 widget.parent = annot.parent
10620 widget._annot = annot
10621 widget.update()
10622 return annot
10623
10624 def annot_names(self):
10625 '''

Callers 9

test_textFunction · 0.80
test_checkboxFunction · 0.80
test_listboxFunction · 0.80
test_comboboxFunction · 0.80
test_text2Function · 0.80
test_2411Function · 0.80
test_add_widgetFunction · 0.80
test_3180Function · 0.80

Calls 4

_addWidgetMethod · 0.95
CheckParentFunction · 0.85
_validateMethod · 0.80
updateMethod · 0.45

Tested by 9

test_textFunction · 0.64
test_checkboxFunction · 0.64
test_listboxFunction · 0.64
test_comboboxFunction · 0.64
test_text2Function · 0.64
test_2411Function · 0.64
test_add_widgetFunction · 0.64
test_3180Function · 0.64