Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

textual-filedrop

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

textual-filedrop

FileDrop widget for Textual, easily drag and drop files into your terminal apps.

  • 0.3.5
  • PyPI
  • Socket score

Maintainers
1

textual-filedrop

textual-filedrop

Add filedrop support to your Textual apps, easily drag and drop files into your terminal apps.

Tested on Windows and macOS.

Nerd Font is required to display file icons.

Install

pip install textual-filedrop

or

git clone https://github.com/agmmnn/textual-filedrop.git
cd textual-filedrop
poetry install

Note

Since version 0.10.0 Textual supports bubble for the paste event (Textualize/textual#1434). So if the terminal where your app is running treats the file drag and drop as a paste event, you can catch it yourself with the on_paste function without widget.

Usage

getfiles

getfiles returns an object containing the path, filename, extension and icon of the files.

from textual_filedrop import getfiles

class MyApp(App):
...
    def on_paste(self, event) -> None:
        files = getfiles(event)
        print(files)

FileDrop Widget

As long as the FileDrop widget is in focus, it will give the information of the dragged files and render the file names with their icons on the screen.

from textual_filedrop import FileDrop
# add FileDrop widget to your app
yield FileDrop(id="filedrop")
# focus the widget
self.query_one("#filedrop").focus()
# when the files are dropped
def on_file_drop_dropped(self, message: FileDrop.Dropped) -> None:
    path = message.path
    filepaths = message.filepaths
    filenames = message.filenames
    filesobj = message.filesobj
    print(path, filepaths, filenames, filesobj)


# output: path, [filepaths], [filenames], [filesobj]

You can find more examples here.

Examples

subdomain_lister.py

Drag and drop the subdomain list files and see the results as a tree list.

subdomain_lister

fullscreen.py

Fullscreen example, will show the results in the textual console.

hidden.py

As long as focus is on, the FileDrop widget will be active even if it is not visible on the screen.

without_widget.py

An example that renders the object with the information of the dragged files returned from the getfiles function to the screen with rich.json.

Dev

poetry install

textual console
poetry run textual run --dev examples/subdomain_lister.py

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc