Code Monkey home page Code Monkey logo

directfolderbrowser's Introduction

DirectFolderBrowser

A file and folder browser for Panda3D using DirectGUI

Features

This is a simple fullscreen file and folder browser with a basic featureset. Currently implemented are:

  • Browsing files and folders
  • Display content as symbols or in a detailed list
  • Show/Hide hidden files (using unix like leading dot)
  • Create new folders
  • Filter by file extension
  • Resizes with window size changes
  • Makes use of the Tooltip class

Install

Install the DirectFolderBrowser via pip

pip install DirectFolderBrowser

How to use

To add a browser instance to your running Panda3D application, just instantiate it like shown here:

from DirectFolderBrowser.DirectFolderBrowser import DirectFolderBrowser

# this command will be called by the browser
def callbackCommand(ok):
    if ok == 1:
        print("User Clicked OK")

        # print the selected file
        print(browser.get())

        browser.hide()
        # Destroy the browser if it's not needed anymore
        #browser.destroy()
    elif ok == 0:
        print("User Clicked Cancel")
        browser.hide()
        browser.destroy()

# show the browser as file browser
browser = DirectFolderBrowser(callbackCommand, fileBrowser=True)

Parameters

The DirectFolderBrowser accepts a few arguments.

  • command: The command that will be called on closing the browser
  • fileBrowser: If set to True the browser will show files, otherwise it will only show folders
  • defaultPath: The initial path the browser will be set to show
  • defaultFilename: The filename that will be set by default, only usefull if fileBrowser is True
  • fileExtensions: A list of extensions. Only files with those extensions will be shown. Only usefull if fileBrowser is True
  • tooltip: An instance of the Tooltip class to display tooltips for certain parts of the editor
  • iconDir: A directory path that contains replacement images. It must contain all required images which are:
    File.png
    Folder.png
    FolderNew.png
    FolderShowHidden.png
    FolderUp.png
    Reload.png
  • parent: Another DirectGUI element which has pixel2d as root parent.
    The browser frame is placed centered so a frame for example should have equal sizes in horizontal and vertical directions
    e.g. frameSize=(-250,250,-200,200)
  • askForOverwrite: If an existing file is selected, a dialog will pop up ask the user if the file should be overwritten.
  • oneClickNavigate: If true, navigating into folders is done with a single click rather than double. Also configurable via the boolean "DirectFolderBrowser-one-click-navigate" configuration variable.
  • usePathBar: Determines if selected files should be set in the path bar or in a dedicated selected file bar.
  • title: If a title is given it will create a title bar at the top of the browser frame displaying the title text, if title is an empty string, the title bar will be collapsed.
  • fileFilters: A dictionary containing a display text as key and a list of file extension strings that should be used when selected. NOTE: This will overwrite the fileExtensions parameter!

directfolderbrowser's People

Contributors

fireclawthefox avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

cosmonium

directfolderbrowser's Issues

Add selectable file extension filtering

Current file browsers allow to limit the visible files by selecting a set of predefined file extensions.
This should also be available in this browser.
By default this should be "All files (.)"

Add "ask for override" dialog

Add a pop up dialog which will ask if an existing selected file should be overridden on accepting the browser.
This should be optional and configurable by the developer (maybe also by the user later)
If Dialog is closed with a negative answer, the browser should stay open allowing a new selection by the user.

Add title for browser

Give the possibility to add a header/title to the browser so users can directly see what the browser is used for, e.g. if it is used to load a specific file or select an empty folder for storing things in etc.

This should be optional and only be shown if a value is given.

Open folder browser in dedicated window

Sometimes it's more viable to have the folder browser in a separate window rather than tucked in or even occupying the main window.
That way the user can easily drag the browser around, sizing it and still be able to see information which would otherwise be hidden behind it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.