|
6 | 6 | if CLIENT_TYPE == "vue2": |
7 | 7 | from trame.widgets import vuetify2 as vuetify |
8 | 8 | from trame.ui.vuetify2 import SinglePageWithDrawerLayout |
| 9 | + from trame_vuetify.widgets.vuetify import HtmlElement |
9 | 10 | else: |
10 | 11 | from trame.widgets import vuetify3 as vuetify |
11 | 12 | from trame.ui.vuetify3 import SinglePageWithDrawerLayout |
| 13 | + from trame_vuetify.widgets.vuetify3 import HtmlElement |
12 | 14 | from trame.widgets import html, plotly, vtk |
13 | 15 |
|
14 | 16 |
|
| 17 | +class VFileInput(HtmlElement): |
| 18 | + """Custom VFileInput element, since the one provided by trame does not currently support all relevant attributes, such as e.g. 'accept'. |
| 19 | + """ |
| 20 | + |
| 21 | + |
| 22 | + def __init__(self, children=None, **kwargs): |
| 23 | + super().__init__("v-file-input", children, **kwargs) |
| 24 | + self._attr_names += [ |
| 25 | + "accept", |
| 26 | + "append_icon", |
| 27 | + "append_outer_icon", |
| 28 | + "autofocus", |
| 29 | + "background_color", |
| 30 | + "chips", |
| 31 | + "clear_icon", |
| 32 | + "clearable", |
| 33 | + "color", |
| 34 | + "counter", |
| 35 | + "counter_size_string", |
| 36 | + "counter_string", |
| 37 | + "counter_value", # JS functions unimplemented |
| 38 | + "dark", |
| 39 | + "dense", |
| 40 | + "disabled", |
| 41 | + "error", |
| 42 | + "error_count", |
| 43 | + "error_messages", |
| 44 | + "filled", |
| 45 | + "flat", |
| 46 | + "full_width", |
| 47 | + "height", |
| 48 | + "hide_details", |
| 49 | + "hide_input", |
| 50 | + "hide_spin_buttons", |
| 51 | + "hint", |
| 52 | + "id", |
| 53 | + "label", |
| 54 | + "light", |
| 55 | + "loader_height", |
| 56 | + "loading", |
| 57 | + "messages", |
| 58 | + "multiple", |
| 59 | + "outlined", |
| 60 | + "persistent_hint", |
| 61 | + "persistent_placeholder", |
| 62 | + "placeholder", |
| 63 | + "prefix", |
| 64 | + "prepend_icon", |
| 65 | + "prepend_inner_icon", |
| 66 | + "reverse", |
| 67 | + "rounded", |
| 68 | + "rules", |
| 69 | + "shaped", |
| 70 | + "show_size", |
| 71 | + "single_line", |
| 72 | + "small_chips", |
| 73 | + "solo", |
| 74 | + "solo_inverted", |
| 75 | + "success", |
| 76 | + "success_messages", |
| 77 | + "suffix", |
| 78 | + "truncate_length", |
| 79 | + "type", |
| 80 | + "validate_on_blur", |
| 81 | + "value", |
| 82 | + ] |
| 83 | + self._event_names += [ |
| 84 | + "blur", |
| 85 | + "change", |
| 86 | + "click", |
| 87 | + ("click_append", "click:append"), |
| 88 | + ("click_append_outer", "click:append-outer"), |
| 89 | + ("click_clear", "click:clear"), |
| 90 | + ("click_prepend", "click:prepend"), |
| 91 | + ("click_prepend_inner", "click:prepend-inner"), |
| 92 | + "focus", |
| 93 | + "input", |
| 94 | + "keydown", |
| 95 | + "mousedown", |
| 96 | + "mouseup", |
| 97 | + ("update_error", "update:error"), |
| 98 | + ] |
| 99 | + |
15 | 100 | def _toolbar(server_controller): |
16 | | - vuetify.VTextField(label=".dat file", v_model=("DAT_PATH",)) |
| 101 | + VFileInput( |
| 102 | + label=".dat file", |
| 103 | + v_model=("INPUT_FILE",), |
| 104 | + update_modelValue="flushState('INPUT_FILE')", |
| 105 | + accept = ".dat" |
| 106 | + ) |
17 | 107 | vuetify.VBtn( |
18 | 108 | text="CONVERT", |
19 | 109 | v_show=("VTU_PATH == ''",), |
|
0 commit comments