arcade
arcade copied to clipboard
Provide dialogue to choose a file or path
Goal
A player should be able to choose a file or path on system, to support following use cases:
- choose save location for save files
- load a save file
- load an image as avatar
Main features
- Should provide a class interface like
UIMessageBox
- A callback should be called, with the chosen file/path
- Callback should receive None if no file/path was chosen
- Dialogue should close itself
- Developer can restrict which filetypes can be selected
- To start with: Single file selection
- Callback receives a list of selected files, which is for now always max 1 entry
- Should have a visual representation as a dialogue (border, some bg color)
- Should be scrollable
- Should provide buttons for home directory (and maybe other useful locations if available)
What should be available
- [ ] Example within
arcade.gui.examples
- [ ] Tests to test the general setup and interaction
- [ ] Documentation how to use the file dialogue
Active development
https://github.com/Ibrahim2750mi/arcade/blob/UIFileChooser/arcade/gui/widgets/layout.py#L365
Discussion summary
Main window vs separate window
We go for a a rendered dialogue within the main window, because:
- extra window can be achieved with tkinter or QT
- handling multiple windows within arcade requires a lot of changes to the whole window handling code
Drag
Start without drag support, go for the main features.
Modal
Start without any special modal features, go for the main features.
Example dialogues for inspiration
you can assign this issue to me
Recap of today's discord discussion:
Discussion resulted in a mockup for what an early minimal version of the file picker could look like:
Ibrahim made a good point: FileDialog
is probably the most appropriate name for this class. Also, we could omit scrollbars from an early PR to begin dogfooding this feature in our projects.
A favorites sidebar can wait until further releases, but I think there's a decent way of handling it in a reasonably cross-platform way:
- Use pathlib to get the home directory
- Start a dict:
{ 'Home' : resolved_home_path }
- Add an entry to the dict for each existing home subdirectory :
'Desktop', 'Documents', 'Downloads', 'Music', 'Pictures', 'Videos'
- Generate some buttons from the dict keys to put in the lefthand favorites sidebar
I think most current operating systems use the above convention for default home sub-directories. If some break with the convention, we could add platform specific lists if needed. It could also be useful to support overriding the favorites list with a constructor argument.
Currently waiting for #1523