Closed jrfrun closed 3 years ago
Yes, under windows you make dlg_open(filters = matrix(c("R or CSV file (*.R, *.csv)", "*.R;*.csv"), ncol = 2), rstudio = FALSE)
.
The filters=
argument takes a nx2 matrix with first column is name and second is the expression that indicates which files are OK. You can specify several lines in the matrix and the default choice will bet last one. For instance, if you want to let the users also select files with other extensions than .R or .csv (e.g., .txt), you will indicate:
dlg_open(filters = matrix(c("All files", "*.*", "R or CSV file (*R, *.csv)", "*.R;*.csv), ncol = 2, byrow = TRUE), rstudio = FALSE)
Note that I also added rstudio = FALSE
just in case this code is called from within RStudio, because filters=
is ignored in the RStudio version of that dialog box.
thanks for the response, thought it didnt work for me. I tried to get just csv files to display on the pop up window but still get everything in that folder displayed.
I used the following
msg = "Select the MIXTURE (.csv) File" m.file = dlgOpen(title = msg , filters = matrix(c("All files", ".", "CSV file (.csv)", "*.csv"), ncol = 2, byrow = TRUE), rstudio = FALSE)$res
Yes indeed! There is a bug when no default=
value is provided. It is corrected in version 1.0.3:
remotes::install_github("SciViews/svDialogs")
library(svDialogs)
msg = "Select the MIXTURE (.csv) File"
m.file = dlgOpen(title = msg , filters = c("CSV file (.csv)", "*.csv", "All files", "*.*"), rstudio = FALSE)$res
Note that I also have simplified the way you pass filters (you do not need to build the matrix) and the default filter is the first one now. You can also use rstudio = TRUE
and it works, but it only takes the first filter (this is an RStudio limitation).
thank you very much
still not working, but I appreciate your help, not a critical thing though
regards
is there a way for the filters = dlg_filters["All", ] part of dlgOpen to be restricted to just how either .R or .csv files right now it just shows all files in the folder.