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

Class Widget

src/__init__.py:9001–9335  ·  view source on GitHub ↗

Class describing a PDF form field ("widget")

Source from the content-addressed store, hash-verified

8999 assert isinstance(self.named, dict)
9000
9001class Widget:
9002 '''
9003 Class describing a PDF form field ("widget")
9004 '''
9005
9006 def __init__(self):
9007 self.border_color = None
9008 self.border_style = "S"
9009 self.border_width = 0
9010 self.border_dashes = None
9011 self.choice_values = None # choice fields only
9012 self.rb_parent = None # radio buttons only: xref of owning parent
9013
9014 self.field_name = None # field name
9015 self.field_label = None # field label
9016 self.field_value = None
9017 self.field_flags = 0
9018 self.field_display = 0
9019 self.field_type = 0 # valid range 1 through 7
9020 self.field_type_string = None # field type as string
9021
9022 self.fill_color = None
9023 self.button_caption = None # button caption
9024 self.is_signed = None # True / False if signature
9025 self.text_color = (0, 0, 0)
9026 self.text_font = "Helv"
9027 self.text_fontsize = 0
9028 self.text_maxlen = 0 # text fields only
9029 self.text_format = 0 # text fields only
9030 self._text_da = "" # /DA = default appearance
9031
9032 self.script = None # JavaScript (/A)
9033 self.script_stroke = None # JavaScript (/AA/K)
9034 self.script_format = None # JavaScript (/AA/F)
9035 self.script_change = None # JavaScript (/AA/V)
9036 self.script_calc = None # JavaScript (/AA/C)
9037 self.script_blur = None # JavaScript (/AA/Bl)
9038 self.script_focus = None # JavaScript (/AA/Fo) codespell:ignore
9039
9040 self.rect = None # annot value
9041 self.xref = 0 # annot value
9042
9043 def __repr__(self):
9044 return f'Widget:(field_type={self.field_type_string} script={self.script})'
9045
9046 def _adjust_font(self):
9047 """Ensure text_font is from our list and correctly spelled.
9048 """
9049 if not self.text_font:
9050 self.text_font = "Helv"
9051 return
9052 valid_fonts = ("Cour", "TiRo", "Helv", "ZaDb")
9053 for f in valid_fonts:
9054 if self.text_font.lower() == f.lower():
9055 self.text_font = f
9056 return
9057 self.text_font = "Helv"
9058 return

Callers 3

nextMethod · 0.85
first_widgetMethod · 0.85
load_widgetMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…