class UrlFieldFormatType
An enumeration class that defines constants for specifying the display format of URL fields, supporting hyperlink and image formats.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/fields/urlFieldFormatType.py
1 - 8
simple
Purpose
This class serves as a simple enumeration to standardize the representation of URL field formats in applications. It provides two display options: a standard hyperlink (anchor tag) and an image that functions as a hyperlink. This is typically used in UI rendering contexts where URL fields need to be displayed differently based on their intended visual representation.
Source Code
class UrlFieldFormatType:
"""Specifies the display format used for URL fields."""
Hyperlink = 0
"""Represents a usual anchor tag."""
Image = 1
"""Represents an image that serves as a hyperlink."""
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
- | - |
Parameter Details
bases: The base classes from which UrlFieldFormatType inherits. In this case, it inherits from the default object class (implicit in Python 3).
Return Value
Instantiating this class returns a UrlFieldFormatType object, though the class is designed to be used via its class-level constants (Hyperlink=0, Image=1) rather than through instantiation. The constants return integer values representing different format types.
Class Interface
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
Hyperlink |
int | Constant value (0) representing a standard hyperlink format displayed as an anchor tag | class |
Image |
int | Constant value (1) representing an image format that serves as a hyperlink | class |
Usage Example
# Using the UrlFieldFormatType constants
from module_name import UrlFieldFormatType
# Check format type
format_type = UrlFieldFormatType.Hyperlink
if format_type == UrlFieldFormatType.Hyperlink:
print("Display as hyperlink")
elif format_type == UrlFieldFormatType.Image:
print("Display as image hyperlink")
# Use in a function
def render_url_field(url, format_type):
if format_type == UrlFieldFormatType.Hyperlink:
return f'<a href="{url}">Link</a>'
elif format_type == UrlFieldFormatType.Image:
return f'<a href="{url}"><img src="{url}" /></a>'
html = render_url_field("https://example.com", UrlFieldFormatType.Hyperlink)
Best Practices
- Use the class constants (UrlFieldFormatType.Hyperlink or UrlFieldFormatType.Image) directly rather than instantiating the class
- Do not modify the class-level constants as they are intended to be immutable
- Consider using Python's enum.Enum for more robust enumeration if extending this functionality
- Use these constants in comparison operations to determine URL field rendering behavior
- This class follows a simple constant pattern and does not require instantiation for normal use
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class DateTimeFieldFormatType 68.2% similar
-
class FieldUrl 62.9% similar
-
class DateTimeFormat 55.7% similar
-
class FieldUrlValue 55.6% similar
-
class PageType 54.3% similar