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

Function test_checkbox

tests/test_widgets.py:47–75  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45
46
47def test_checkbox():
48 doc = pymupdf.open()
49 page = doc.new_page()
50 widget = pymupdf.Widget()
51 widget.border_style = "b"
52 widget.field_name = "Button-1"
53 widget.field_label = "a simple check box button"
54 widget.field_type = pymupdf.PDF_WIDGET_TYPE_CHECKBOX
55 widget.fill_color = gold
56 widget.rect = rect
57 widget.text_color = blue
58 widget.text_font = "ZaDb"
59 widget.field_value = True
60 page.add_widget(widget) # create the field
61 field = page.first_widget
62 assert field.field_type_string == "CheckBox"
63
64 # Check #2350 - setting checkbox to readonly.
65 #
66 widget.field_flags |= pymupdf.PDF_FIELD_IS_READ_ONLY
67 widget.update()
68 path = f"{scriptdir}/test_checkbox.pdf"
69 doc.save(path)
70
71 doc = pymupdf.open(path)
72 page = doc[0]
73 widget = page.first_widget
74 assert widget
75 assert widget.field_flags == pymupdf.PDF_FIELD_IS_READ_ONLY
76
77
78def test_listbox():

Callers

nothing calls this directly

Calls 4

updateMethod · 0.95
new_pageMethod · 0.80
add_widgetMethod · 0.80
saveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…