You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs.openc3.com/docs/guides/scripting-api.md
+86-38Lines changed: 86 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -312,6 +312,83 @@ match value:
312
312
</TabItem>
313
313
</Tabs>
314
314
315
+
### open_file_dialog
316
+
317
+
### open_files_dialog
318
+
319
+
The open_file_dialog and open_files_dialog methods create a file dialog box so the user can select a single or multiple files. The selected file(s) is returned.
320
+
321
+
Note: COSMOS 5 has deprecated the save_file_dialog and open_directory_dialog methods. save_file_dialog can be replaced by put_target_file if you want to write a file back to the target. open_directory_dialog doesn't make sense in new architecture so you must request individual files.
| Title | The title to put on the dialog. Required. |
346
+
| Message | The message to display in the dialog box. Optional parameter. |
347
+
| filter | Named parameter to filter allowed file types. Optional parameter, specified as comma delimited file types, e.g. ".txt,.doc". See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept for more information. |
348
+
349
+
<TabsgroupId="script-language">
350
+
<TabItemvalue="ruby"label="Ruby Example">
351
+
352
+
```ruby
353
+
file = open_file_dialog("Open a single file", "Choose something interesting", filter:".txt")
354
+
puts file # Ruby File object
355
+
puts file.read
356
+
file.delete
357
+
358
+
files = open_files_dialog("Open multiple files") # message is optional
359
+
puts files # Array of File objects (even if you select only one)
360
+
files.each do |file|
361
+
puts file
362
+
puts file.read
363
+
file.delete
364
+
end
365
+
```
366
+
367
+
</TabItem>
368
+
369
+
<TabItemvalue="python"label="Python Example">
370
+
371
+
```python
372
+
file= open_file_dialog("Open a single file", "Choose something interesting", filter=".txt")
373
+
print(file)
374
+
print(file.read())
375
+
file.close()
376
+
377
+
files = open_files_dialog("Open multiple files") # message is optional
378
+
print(files) # Array of File objects (even if you select only one)
379
+
forfilein files:
380
+
print(file)
381
+
print(file.read())
382
+
file.close()
383
+
```
384
+
385
+
</TabItem>
386
+
</Tabs>
387
+
388
+
## File Manipulation
389
+
390
+
These methods provide capability to interact with files in the target directory.
391
+
315
392
### get_target_file
316
393
317
394
Return a file handle to a file in the target directory
The open_file_dialog and open_files_dialog methods create a file dialog box so the user can select a single or multiple files. The selected file(s) is returned.
550
+
### download_file
478
551
479
-
Note: COSMOS 5 has deprecated the save_file_dialog and open_directory_dialog methods. save_file_dialog can be replaced by put_target_file if you want to write a file back to the target. open_directory_dialog doesn't make sense in new architecture so you must request individual files.
552
+
Prompts the user to download a file from the OpenC3 system to their local machine.
| Title | The title to put on the dialog. Required. |
504
-
| Message | The message to display in the dialog box. Optional parameter. |
505
-
| filter | Named parameter to filter allowed file types. Optional parameter, specified as comma delimited file types, e.g. ".txt,.doc". See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept for more information. |
0 commit comments