arcade icon indicating copy to clipboard operation
arcade copied to clipboard

Provide dialogue to choose a file or path

Open eruvanos opened this issue 2 years ago • 3 comments

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

image image image

eruvanos avatar Apr 26 '22 17:04 eruvanos

you can assign this issue to me

Ibrahim2750mi avatar Apr 26 '22 17:04 Ibrahim2750mi

Recap of today's discord discussion: Discussion resulted in a mockup for what an early minimal version of the file picker could look like: image

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:

  1. Use pathlib to get the home directory
  2. Start a dict: { 'Home' : resolved_home_path }
  3. Add an entry to the dict for each existing home subdirectory : 'Desktop', 'Documents', 'Downloads', 'Music', 'Pictures', 'Videos'
  4. 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.

pushfoo avatar Jun 19 '22 23:06 pushfoo

Currently waiting for #1523

Ibrahim2750mi avatar Mar 25 '23 09:03 Ibrahim2750mi