Skip to main content

Unopinionated, minimalist, reusable, slightly configurable, general-purpose file-dialog.

Project description

Universal File Dialog

Install & Get Started:

pip install Ufd --upgrade

or

git clone https://github.com/emboiko/Ufd.git

or

Download the .zip here

Import:

from Ufd.Ufd import Ufd

Construct:

dialog = Ufd(**Kwargs)
result = dialog()

or specify a bunch of options:

dialog = Ufd(
    title="My Dialog",
    icon="path/to/some_icon.ico",
    show_hidden=True,
    multiselect=False
    select_dirs=False
)
result = dialog()

Ufd's full constructor signature looks like this:

def __init__(
    self,
    title:str="Universal File Dialog",
    icon:str="",
    show_hidden:bool=False,
    include_files:bool=True,
    multiselect:bool=True,
    select_dirs:bool=True,
    select_files:bool=True,
    unix_delimiter:bool=True,
    stdout:bool=False
):

title : str: Window title

icon : str: Path to your custom icon.ico file

show_hidden : bool: Include hidden file(s) or folder(s) in treeview

include_files : bool: Include file(s) in treeview

multiselect : bool: File-list multiselect support, returns a list either way

select_dirs : bool: File-list shows directories (folder-browser)

select_files : bool: File-list shows files (file-browser)

unix_delimiter : bool: Return paths delimited with "/" or "\"

stdout : bool: Print a newline delimited list of the dialog selection to stdout before returning (Useful if you aren't calling the dialog from a Python)

Ufd still has several [boolean constructor parameters] options & behavioral tweaks in development that will optionally restrict / expand upon its behavior to match the context in which it is used.

Using Ufd without Python

Ufd.exe is a Windows binary compiled with PyInstaller for x64 systems. (dist_win64/Ufd/Ufd.exe)

#include <iostream>
#include <fstream>
#include <string>
#include <vector>

int main(int argc, char *argv[]) {
    system("/path/to/ufd.exe stdout=True > paths.txt");
    std::ifstream inFile("paths.txt");

    std::vector<std::string> results;
    std::string result;

    while (getline(inFile, result)) results.push_back(result);

    inFile.close();
    std::remove("paths.txt");

    for (std::string path : results) std::cout << path << "\n";

    std::cin.ignore();
    return 0;
}

Why should I use Ufd?

  • It's easy
  • No external dependencies
  • Ufd doesn't care what kind of dialog it's serving as. You get to deal with any ambiguities in your own way.

Want to select 3 directories and 2 files from the same dialog, and have their paths returned as a list?

dialog = Ufd()
result = dialog()
>> result
>> ["C:some_dir/dir1", "C:some_dir/dir2", "C:some_dir/dir3", "C:some_dir/file1.ext", "C:some_dir/file2.ext"]

Or if you'd prefer to corral the user into selecting a single file:

dialog = Ufd(multiselect=False, select_dirs=False)
result = dialog()
>> result
>> ["C:some_dir/file1.ext"]

Tips & Tricks:

  • Drill through the treeview with <Doubleclick>, <Enter>, and/or ArrowKeys.
  • Treeview supports single-select via <Doubleclick> or the submit button.
  • Navigate the listbox on the right with the mouse or arrow keys. Multiselect is supported with <Shift> (span) & <Ctrl> (individuals), or by clicking + dragging the mouse. Select all with <Ctrl+A> as expected. Confirm selection in the listbox with <Enter> or the submit button.
  • Cancelling via <Ctrl-w>, the cancel button, or the window manager will both return an empty list from the dialog.

Todo
  • Treeview only mode / folderbrowser mode
  • Treeview bugged x_scroll
  • Treeview bugged border
  • Listbox Filter
  • Listbox Navigation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Ufd-1.0.0.tar.gz (45.6 kB view details)

Uploaded Source

Built Distribution

Ufd-1.0.0-py3-none-any.whl (43.4 kB view details)

Uploaded Python 3

File details

Details for the file Ufd-1.0.0.tar.gz.

File metadata

  • Download URL: Ufd-1.0.0.tar.gz
  • Upload date:
  • Size: 45.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

File hashes

Hashes for Ufd-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d1decdccb6e2915d5c73b3f1828196b93142a2d5233b38d04b32a4e9725d36a1
MD5 e3885293498e7099848522574abd8b7b
BLAKE2b-256 09c309696cccbe861eda2faf809c19ddd51c73e81ad32c47d7c58fe5bc0d2add

See more details on using hashes here.

File details

Details for the file Ufd-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: Ufd-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 43.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

File hashes

Hashes for Ufd-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d70385b89570dc1e426a6d305f83e0a29882b6eb9d8ea233c42396fdf357456b
MD5 d2450655fbf443eb73bc10e740f8f580
BLAKE2b-256 b6413beb629440578a824e32a170e183149705359b4abc2de63e9a1143177f7b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page