selectInput()

Input / Files

Description

Opens a file chooser dialog to select an input file. Returns the selected path.

Syntax

std::string selectInput(std::string prompt, std::string filter)

Parameters

NameTypeDescription
promptstd::stringdialog message
filterstd::stringfile extension filter (optional)

Returns

std::string

Related

Under the Hood

From Processing.h:

static std::string selectInput(const std::string& prompt="", const std::string& filter="");

Under the Hood

From Processing.cpp:

std::string PApplet::selectInput(const std::string& prompt,const std::string&){ std::string cmd="zenity --file-selection --title=\""+prompt+"\" 2>/dev/null"; FILE* p=popen(cmd.c_str(),"r"); if(!p)return ""; char buf[4096]=""; fgets(buf,sizeof(buf),p); pclose(p); std::string r(buf); if(!r.empty()&&r.back()=='\n')r.pop_back(); return r; }