@@ -55,8 +55,69 @@ def _serialize_value(value, _):
55
55
56
56
@register
57
57
class FileUpload (DescriptionWidget , ValueWidget , CoreWidget ):
58
- """
59
- Upload file(s) from browser to Python kernel as bytes
58
+ """File upload widget
59
+
60
+ This creates a file upload input that allows the user to select
61
+ one or more files to upload. The file metadata and content
62
+ can be retrieved in the kernel.
63
+
64
+ Examples
65
+ --------
66
+
67
+ >>> import ipywidgets as widgets
68
+ >>> uploader = widgets.FileUpload()
69
+
70
+ # After displaying `uploader` and uploading a file:
71
+
72
+ >>> uploader.value
73
+ [
74
+ {
75
+ 'name': 'example.txt',
76
+ 'type': 'text/plain',
77
+ 'size': 36,
78
+ 'last_modified': datetime.datetime(2020, 1, 9, 15, 58, 43, 321000, tzinfo=datetime.timezone.utc),
79
+ 'content': <memory at 0x10c1b37c8>
80
+ }
81
+ ]
82
+ >>> uploader.value[0].content.tobytes()
83
+ b'This is the content of example.txt.\n '
84
+
85
+ Parameters
86
+ ----------
87
+
88
+ accept: str, optional
89
+ Which file types to accept, e.g. '.doc,.docx'. For a full
90
+ description of how to specify this, see
91
+ https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-accept
92
+ Defaults to accepting all file types.
93
+
94
+ multiple: bool, optional
95
+ Whether to accept multiple files at the same time. Defaults to False.
96
+
97
+ disabled: bool, optional
98
+ Whether user interaction is enabled.
99
+
100
+ icon: str, optional
101
+ The icon to use for the button displayed on the screen.
102
+ Can be any Font-awesome icon without the fa- prefix.
103
+ Defaults to 'upload'. If missing, no icon is shown.
104
+
105
+ description: str, optional
106
+ The text to show on the label. Defaults to 'Upload'.
107
+
108
+ button_style: str, optional
109
+ One of 'primary', 'success', 'info', 'warning', 'danger' or ''.
110
+
111
+ style: widgets.widget_button.ButtonStyle, optional
112
+ Style configuration for the button.
113
+
114
+ value: List[Dict], optional
115
+ The value of the last uploaded file or set of files. See the
116
+ documentation for details of how to use this to retrieve file
117
+ content and metadata:
118
+ https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20List.html#File-Upload
119
+ error: str, optional
120
+ Whether the last upload triggered an error.
60
121
"""
61
122
_model_name = Unicode ('FileUploadModel' ).tag (sync = True )
62
123
_view_name = Unicode ('FileUploadView' ).tag (sync = True )
0 commit comments