nova-trame 0.24.0__py3-none-any.whl → 0.25.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,14 @@ from .remote_file_input import RemoteFileInput
10
10
  class FileUpload(vuetify.VBtn):
11
11
  """Component for uploading a file from either the user's filesystem or the server filesystem."""
12
12
 
13
- def __init__(self, v_model: str, base_paths: Optional[List[str]] = None, label: str = "", **kwargs: Any) -> None:
13
+ def __init__(
14
+ self,
15
+ v_model: str,
16
+ base_paths: Optional[List[str]] = None,
17
+ label: str = "",
18
+ return_contents: bool = True,
19
+ **kwargs: Any,
20
+ ) -> None:
14
21
  """Constructor for FileUpload.
15
22
 
16
23
  Parameters
@@ -23,6 +30,9 @@ class FileUpload(vuetify.VBtn):
23
30
  Passed to :ref:`RemoteFileInput <api_remotefileinput>`.
24
31
  label : str, optional
25
32
  The text to display on the upload button.
33
+ return_contents : bool, optional
34
+ If true, the file contents will be stored in v_model. If false, a file path will be stored in v_model.
35
+ Defaults to true.
26
36
  **kwargs
27
37
  All other arguments will be passed to the underlying
28
38
  `Button component <https://trame.readthedocs.io/en/latest/trame.widgets.vuetify3.html#trame.widgets.vuetify3.VBtn>`_.
@@ -36,6 +46,7 @@ class FileUpload(vuetify.VBtn):
36
46
  self._base_paths = base_paths
37
47
  else:
38
48
  self._base_paths = ["/"]
49
+ self._return_contents = return_contents
39
50
  self._ref_name = f"nova__fileupload_{self._next_id}"
40
51
 
41
52
  super().__init__(label, **kwargs)
@@ -49,12 +60,15 @@ class FileUpload(vuetify.VBtn):
49
60
  # Serialize the content in a way that will work with nova-mvvm and then push it to the server.
50
61
  update_modelValue=(
51
62
  f"{self._v_model}.arrayBuffer().then((contents) => {{"
52
- f"trigger('decode_blob_{self._id}', [contents]); "
63
+ f" trigger('decode_blob_{self._id}', [contents]); "
53
64
  "});"
54
65
  ),
55
66
  )
56
67
  self.remote_file_input = RemoteFileInput(
57
- v_model=self._v_model, base_paths=self._base_paths, input_props={"classes": "d-none"}, return_contents=True
68
+ v_model=self._v_model,
69
+ base_paths=self._base_paths,
70
+ input_props={"classes": "d-none"},
71
+ return_contents=self._return_contents,
58
72
  )
59
73
 
60
74
  with self:
@@ -65,7 +79,7 @@ class FileUpload(vuetify.VBtn):
65
79
 
66
80
  @self.server.controller.trigger(f"decode_blob_{self._id}")
67
81
  def _decode_blob(contents: bytes) -> None:
68
- self.remote_file_input.decode_file(contents)
82
+ self.remote_file_input.decode_file(contents, self._return_contents)
69
83
 
70
84
  def select_file(self, value: str) -> None:
71
85
  """Programmatically set the RemoteFileInput path.
@@ -172,7 +172,7 @@ class InputField:
172
172
  The following example would set the auto_grow and label attributes on
173
173
  `VTextarea <https://trame.readthedocs.io/en/latest/trame.widgets.vuetify3.html#trame.widgets.vuetify3.VTextarea>`_:
174
174
 
175
- .. literalinclude:: ../tests/gallery/app.py
175
+ .. literalinclude:: ../tests/gallery/views/app.py
176
176
  :start-after: InputField kwargs example start
177
177
  :end-before: InputField kwargs example end
178
178
  :dedent:
@@ -1,6 +1,7 @@
1
1
  """View implementation for RemoteFileInput."""
2
2
 
3
3
  from functools import partial
4
+ from tempfile import NamedTemporaryFile
4
5
  from typing import Any, Optional, Union, cast
5
6
 
6
7
  from trame.app import get_server
@@ -207,9 +208,15 @@ class RemoteFileInput:
207
208
  with open(file_path, mode="rb") as file:
208
209
  self.decode_file(file.read())
209
210
 
210
- def decode_file(self, bytestream: bytes) -> None:
211
+ def decode_file(self, bytestream: bytes, set_contents: bool = False) -> None:
211
212
  decoded_content = bytestream.decode("latin1")
212
- self.set_v_model(decoded_content)
213
+ if set_contents:
214
+ self.set_v_model(decoded_content)
215
+ else:
216
+ with NamedTemporaryFile(mode="w", delete=False, encoding="utf-8") as temp_file:
217
+ temp_file.write(decoded_content)
218
+ temp_file.flush()
219
+ self.set_v_model(temp_file.name)
213
220
 
214
221
  def select_file(self, value: str) -> None:
215
222
  """Programmatically set the v_model value."""
@@ -53,7 +53,7 @@ class GridLayout(html.Div):
53
53
  --------
54
54
  Basic usage:
55
55
 
56
- .. literalinclude:: ../tests/gallery/app.py
56
+ .. literalinclude:: ../tests/gallery/views/app.py
57
57
  :start-after: setup grid
58
58
  :end-before: setup grid complete
59
59
  :dedent:
@@ -133,7 +133,7 @@ class GridLayout(html.Div):
133
133
 
134
134
  Example
135
135
  -------
136
- .. literalinclude:: ../tests/gallery/app.py
136
+ .. literalinclude:: ../tests/gallery/views/app.py
137
137
  :start-after: grid row and column span example
138
138
  :end-before: grid row and column span example end
139
139
  :dedent:
@@ -51,7 +51,7 @@ class HBoxLayout(html.Div):
51
51
 
52
52
  Example
53
53
  -------
54
- .. literalinclude:: ../tests/gallery/app.py
54
+ .. literalinclude:: ../tests/gallery/views/app.py
55
55
  :start-after: setup hbox
56
56
  :end-before: setup hbox complete
57
57
  :dedent:
@@ -51,7 +51,7 @@ class VBoxLayout(html.Div):
51
51
 
52
52
  Example
53
53
  -------
54
- .. literalinclude:: ../tests/gallery/app.py
54
+ .. literalinclude:: ../tests/gallery/views/app.py
55
55
  :start-after: setup vbox
56
56
  :end-before: setup vbox complete
57
57
  :dedent:
@@ -149,6 +149,10 @@ html {
149
149
  }
150
150
  }
151
151
 
152
+ .v-tabs {
153
+ height: 32px !important;
154
+ }
155
+
152
156
  .v-tab.v-btn {
153
157
  height: 30px !important;
154
158
  min-width: fit-content !important;
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: nova-trame
3
- Version: 0.24.0
3
+ Version: 0.25.0
4
4
  Summary: A Python Package for injecting curated themes and custom components into Trame applications
5
5
  License: MIT
6
6
  Keywords: NDIP,Python,Trame,Vuetify
@@ -7,23 +7,23 @@ nova/trame/model/remote_file_input.py,sha256=9KAf31ZHzpsh_aXUrNcF81Q5jvUZDWCzW1Q
7
7
  nova/trame/view/components/__init__.py,sha256=60BeS69aOrFnkptjuD17rfPE1f4Z35iBH56TRmW5MW8,451
8
8
  nova/trame/view/components/data_selector.py,sha256=EJ8fYCrkhRgDExAcewiUb7jTs7Qzo-GKVYWx7oFlrT0,14592
9
9
  nova/trame/view/components/execution_buttons.py,sha256=fIkrWKI3jFZqk3GHhtmYh3nK2c-HOXpD3D3zd_TUpi0,4049
10
- nova/trame/view/components/file_upload.py,sha256=7VcpfA6zmiqMDLkwVPlb35Tf0IUTBN1xsHpoUFnSr1w,3111
11
- nova/trame/view/components/input_field.py,sha256=q6WQ_N-BOlimUL9zgazDlsDfK28FrrKjH4he8e_HzRA,16088
10
+ nova/trame/view/components/file_upload.py,sha256=Q3t7TUJ8w6wlEqb1mnJ23yBsM1XmQPtm0awaoBrlLXo,3509
11
+ nova/trame/view/components/input_field.py,sha256=Rtcl_eszvhgyC1rhTI7OMSLHjrE7DNH44eY08k7UXks,16094
12
12
  nova/trame/view/components/ornl/__init__.py,sha256=HnxzzSsxw0vQSDCVFfWsAxx1n3HnU37LMuQkfiewmSU,90
13
13
  nova/trame/view/components/ornl/neutron_data_selector.py,sha256=YTYuLD5eDn3AsKguT8ksPx2Yme2RxheuXQGlhuTLOOc,12527
14
14
  nova/trame/view/components/progress_bar.py,sha256=fCfPw4MPAvORaeFOXugreok4GLpDVZGMkqvnv-AhMxg,2967
15
- nova/trame/view/components/remote_file_input.py,sha256=ByrBFj8svyWezcardCWrS_4Ag3fgTYNg_11lDW1FIA8,9669
15
+ nova/trame/view/components/remote_file_input.py,sha256=6mUz6JZVhLO_Y4mZaQd_lpPe33KLtSpjxXS7uTNUmFI,10004
16
16
  nova/trame/view/components/tool_outputs.py,sha256=-6pDURd2l_FK_8EWa9BI3KhU_KJXJ6uyJ_rW4nQVc08,2337
17
17
  nova/trame/view/components/visualization/__init__.py,sha256=reqkkbhD5uSksHHlhVMy1qNUCwSekS5HlXk6wCREYxU,152
18
18
  nova/trame/view/components/visualization/interactive_2d_plot.py,sha256=foZCMoqbuahT5dtqIQvm8C4ZJcY9P211eJEcpQJltmM,3421
19
19
  nova/trame/view/components/visualization/matplotlib_figure.py,sha256=GGH2cx-dQFkMAOTnlCrzMGDb2TN451I9J3gAS8tx2cs,12147
20
20
  nova/trame/view/layouts/__init__.py,sha256=cMrlB5YMUoK8EGB83b34UU0kPTVrH8AxsYvKRtpUNEc,141
21
- nova/trame/view/layouts/grid.py,sha256=BYoylq-VN1l55BXBWMJ_7zvHcQYmfOo811nzD72IBOQ,5522
22
- nova/trame/view/layouts/hbox.py,sha256=qlOMp_iOropIkC9Jxa6D89b7OPv0pNvJ73tUEzddyhQ,3513
21
+ nova/trame/view/layouts/grid.py,sha256=vqEX-jghs6j9_sVtijdRH7uhlD9loWNi90k2qgg4Dhg,5534
22
+ nova/trame/view/layouts/hbox.py,sha256=cdwnGk93ec6dXAeEamRQx1WTj5T7Ygsmsy0xz130tWM,3519
23
23
  nova/trame/view/layouts/utils.py,sha256=Hg34VQWTG3yHBsgNvmfatR4J-uL3cko7UxSJpT-h3JI,376
24
- nova/trame/view/layouts/vbox.py,sha256=hzhzPu99R2fAclMe-FwHZseJWk7iailZ31bKdGhi1hk,3514
24
+ nova/trame/view/layouts/vbox.py,sha256=XRV14e32MY1HWc9FTVTv1vOatWWbhLMd0lYwZP-isTg,3520
25
25
  nova/trame/view/theme/__init__.py,sha256=70_marDlTigIcPEOGiJb2JTs-8b2sGM5SlY7XBPtBDM,54
26
- nova/trame/view/theme/assets/core_style.scss,sha256=AJ-2hyQRVkyOGWJB0lGMzlQeshbCJP5BGNYCt9e9AOI,4208
26
+ nova/trame/view/theme/assets/core_style.scss,sha256=uZKMMhXRsvVy_17dK32ETNJn-4c7_xzj01FRkx7axY0,4262
27
27
  nova/trame/view/theme/assets/favicon.png,sha256=Xbp1nUmhcBDeObjsebEbEAraPDZ_M163M_ZLtm5AbQc,1927
28
28
  nova/trame/view/theme/assets/js/delay_manager.js,sha256=mRV6KoO8-Bxq3tG5Bh9CQYy-CRVbkj3IYlqNb-Og7cI,526
29
29
  nova/trame/view/theme/assets/js/lodash.min.js,sha256=KCyAYJ-fsqtp_HMwbjhy6IKjlA5lrVrtWt1JdMsC57k,73016
@@ -38,8 +38,8 @@ nova/trame/view_model/ornl/neutron_data_selector.py,sha256=l1l_e0CFsVZ0h-9MPSjXT
38
38
  nova/trame/view_model/progress_bar.py,sha256=6AUKHF3hfzbdsHqNEnmHRgDcBKY5TT8ywDx9S6ovnsc,2854
39
39
  nova/trame/view_model/remote_file_input.py,sha256=ojEOJ8ZPkajpbAaZi9VLj7g-uBjhb8BMrTdMmwf_J6A,3367
40
40
  nova/trame/view_model/tool_outputs.py,sha256=ev6LY7fJ0H2xAJn9f5ww28c8Kpom2SYc2FbvFcoN4zg,829
41
- nova_trame-0.24.0.dist-info/LICENSE,sha256=Iu5QiDbwNbREg75iYaxIJ_V-zppuv4QFuBhAW-qiAlM,1061
42
- nova_trame-0.24.0.dist-info/METADATA,sha256=pSBLrSiLCUFV9pg6yj-m9ZlQjUYT7Ms2uef6QYr2gKI,1688
43
- nova_trame-0.24.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
44
- nova_trame-0.24.0.dist-info/entry_points.txt,sha256=J2AmeSwiTYZ4ZqHHp9HO6v4MaYQTTBPbNh6WtoqOT58,42
45
- nova_trame-0.24.0.dist-info/RECORD,,
41
+ nova_trame-0.25.0.dist-info/LICENSE,sha256=Iu5QiDbwNbREg75iYaxIJ_V-zppuv4QFuBhAW-qiAlM,1061
42
+ nova_trame-0.25.0.dist-info/METADATA,sha256=Vr8vS4k_Z0Bi4yHF24w5fYtRDcHh8KxcuSO8BWmv0AM,1688
43
+ nova_trame-0.25.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
44
+ nova_trame-0.25.0.dist-info/entry_points.txt,sha256=J2AmeSwiTYZ4ZqHHp9HO6v4MaYQTTBPbNh6WtoqOT58,42
45
+ nova_trame-0.25.0.dist-info/RECORD,,