duit.ui.annotations.PathAnnotation
1from enum import Enum 2from typing import Optional, Dict 3 4from duit.ui.annotations.UIAnnotation import UIAnnotation 5 6 7class DialogType(Enum): 8 OpenFile = 0 9 OpenDirectory = 1 10 SaveFile = 2 11 12 13class PathAnnotation(UIAnnotation): 14 def __init__(self, name: str, placeholder_text: str = "", 15 tooltip: str = "", readonly: bool = False, 16 title: str = "Please choose a path", 17 dialog_type: DialogType = DialogType.OpenFile, 18 filters: Optional[Dict[str, str]] = None 19 ): 20 """ 21 Initialize a PathAnnotation. 22 23 :param name: The name of the path annotation. 24 :param placeholder_text: The placeholder text to display in the input field. 25 :param tooltip: The tooltip text for the annotation. 26 :param readonly: Whether the annotation is read-only (default is False). 27 :param title: The title of the file dialog. 28 :param dialog_type: The type of file dialog (default is DialogType.OpenFile). 29 :param filters: Optional file filters in the form of a dictionary (e.g. ".py": "Python") (default is an empty dictionary). 30 """ 31 super().__init__(name, tooltip, readonly) 32 self.placeholder_text = placeholder_text 33 self.title = title 34 self.dialog_type = dialog_type 35 self.filters = filters 36 37 if self.filters is None: 38 self.filters = {}
class
DialogType(enum.Enum):
OpenFile =
<DialogType.OpenFile: 0>
OpenDirectory =
<DialogType.OpenDirectory: 1>
SaveFile =
<DialogType.SaveFile: 2>
14class PathAnnotation(UIAnnotation): 15 def __init__(self, name: str, placeholder_text: str = "", 16 tooltip: str = "", readonly: bool = False, 17 title: str = "Please choose a path", 18 dialog_type: DialogType = DialogType.OpenFile, 19 filters: Optional[Dict[str, str]] = None 20 ): 21 """ 22 Initialize a PathAnnotation. 23 24 :param name: The name of the path annotation. 25 :param placeholder_text: The placeholder text to display in the input field. 26 :param tooltip: The tooltip text for the annotation. 27 :param readonly: Whether the annotation is read-only (default is False). 28 :param title: The title of the file dialog. 29 :param dialog_type: The type of file dialog (default is DialogType.OpenFile). 30 :param filters: Optional file filters in the form of a dictionary (e.g. ".py": "Python") (default is an empty dictionary). 31 """ 32 super().__init__(name, tooltip, readonly) 33 self.placeholder_text = placeholder_text 34 self.title = title 35 self.dialog_type = dialog_type 36 self.filters = filters 37 38 if self.filters is None: 39 self.filters = {}
An abstract base class for annotations.
PathAnnotation( name: str, placeholder_text: str = '', tooltip: str = '', readonly: bool = False, title: str = 'Please choose a path', dialog_type: DialogType = <DialogType.OpenFile: 0>, filters: Optional[Dict[str, str]] = None)
15 def __init__(self, name: str, placeholder_text: str = "", 16 tooltip: str = "", readonly: bool = False, 17 title: str = "Please choose a path", 18 dialog_type: DialogType = DialogType.OpenFile, 19 filters: Optional[Dict[str, str]] = None 20 ): 21 """ 22 Initialize a PathAnnotation. 23 24 :param name: The name of the path annotation. 25 :param placeholder_text: The placeholder text to display in the input field. 26 :param tooltip: The tooltip text for the annotation. 27 :param readonly: Whether the annotation is read-only (default is False). 28 :param title: The title of the file dialog. 29 :param dialog_type: The type of file dialog (default is DialogType.OpenFile). 30 :param filters: Optional file filters in the form of a dictionary (e.g. ".py": "Python") (default is an empty dictionary). 31 """ 32 super().__init__(name, tooltip, readonly) 33 self.placeholder_text = placeholder_text 34 self.title = title 35 self.dialog_type = dialog_type 36 self.filters = filters 37 38 if self.filters is None: 39 self.filters = {}
Initialize a PathAnnotation.
Parameters
- name: The name of the path annotation.
- placeholder_text: The placeholder text to display in the input field.
- tooltip: The tooltip text for the annotation.
- readonly: Whether the annotation is read-only (default is False).
- title: The title of the file dialog.
- dialog_type: The type of file dialog (default is DialogType.OpenFile).
- filters: Optional file filters in the form of a dictionary (e.g. ".py": "Python") (default is an empty dictionary).