{"id":16225688,"url":"https://github.com/agmmnn/textual-filedrop","last_synced_at":"2025-03-19T12:31:03.113Z","repository":{"id":64973751,"uuid":"579416011","full_name":"agmmnn/textual-filedrop","owner":"agmmnn","description":"FileDrop widget for Textual, easily drag and drop files into your terminal apps.","archived":false,"fork":false,"pushed_at":"2023-03-22T17:59:15.000Z","size":150,"stargazers_count":31,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T07:11:13.305Z","etag":null,"topics":["cli","python","rich","textual","tui"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/textual-filedrop","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/agmmnn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-17T16:14:30.000Z","updated_at":"2025-02-18T00:42:34.000Z","dependencies_parsed_at":"2024-10-27T20:44:23.542Z","dependency_job_id":null,"html_url":"https://github.com/agmmnn/textual-filedrop","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agmmnn%2Ftextual-filedrop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agmmnn%2Ftextual-filedrop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agmmnn%2Ftextual-filedrop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agmmnn%2Ftextual-filedrop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agmmnn","download_url":"https://codeload.github.com/agmmnn/textual-filedrop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244426578,"owners_count":20450991,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","python","rich","textual","tui"],"created_at":"2024-10-10T12:45:55.940Z","updated_at":"2025-03-19T12:31:02.868Z","avatar_url":"https://github.com/agmmnn.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![textual-filedrop](https://user-images.githubusercontent.com/16024979/208708722-e550d8ca-22a7-47f0-adf9-16cad570cdfd.png)\n\n# textual-filedrop\n\nAdd filedrop support to your [Textual](https://github.com/textualize/textual/) apps, easily drag and drop files into your terminal apps.\n\n\u003e _Tested on `Windows` and [`macOS`](https://github.com/Textualize/textual/discussions/1414#discussioncomment-4467029)._\n\n\u003e _[Nerd Font](https://www.nerdfonts.com/font-downloads) is required to display file icons._\n\n## Install\n\n```\npip install textual-filedrop\n```\n\nor\n\n```\ngit clone https://github.com/agmmnn/textual-filedrop.git\ncd textual-filedrop\npoetry install\n```\n\n## Note\n\nSince version [0.10.0](https://github.com/Textualize/textual/releases/tag/v0.10.0) Textual supports [bubble](https://textual.textualize.io/guide/events/#bubbling) for the [paste event](https://textual.textualize.io/events/paste/) ([Textualize/textual#1434](https://github.com/Textualize/textual/issues/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.\n\n## Usage\n\n### `getfiles`\n\n`getfiles` returns an object containing the _path, filename, extension_ and _icon_ of the files.\n\n```py\nfrom textual_filedrop import getfiles\n\nclass MyApp(App):\n...\n    def on_paste(self, event) -\u003e None:\n        files = getfiles(event)\n        print(files)\n```\n\n![](https://i.imgur.com/1xdpivC.png)\n\n### `FileDrop` Widget\n\nAs 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.\n\n```py\nfrom textual_filedrop import FileDrop\n```\n\n```py\n# add FileDrop widget to your app\nyield FileDrop(id=\"filedrop\")\n```\n\n```py\n# focus the widget\nself.query_one(\"#filedrop\").focus()\n```\n\n```py\n# when the files are dropped\ndef on_file_drop_dropped(self, message: FileDrop.Dropped) -\u003e None:\n    path = message.path\n    filepaths = message.filepaths\n    filenames = message.filenames\n    filesobj = message.filesobj\n    print(path, filepaths, filenames, filesobj)\n\n\n# output: path, [filepaths], [filenames], [filesobj]\n```\n\nYou can find more examples [here](./examples).\n\n## Examples\n\n### [subdomain_lister.py](./examples/subdomain_lister.py)\n\nDrag and drop the subdomain list files and see the results as a tree list.\n\n![subdomain_lister](https://user-images.githubusercontent.com/16024979/208706132-0a33bb21-51b8-441a-aeb9-668dbfcb382c.gif)\n\n### [fullscreen.py](./examples/fullscreen.py)\n\nFullscreen example, will show the results in the textual console.\n\n### [hidden.py](./examples/hidden.py)\n\nAs long as focus is on, the `FileDrop` widget will be active even if it is not visible on the screen.\n\n### [without_widget.py](./examples/without_widget.py)\n\nAn example that renders the object with the information of the dragged files returned from the `getfiles` function to the screen with `rich.json`.\n\n## Dev\n\n```\npoetry install\n\ntextual console\npoetry run textual run --dev examples/subdomain_lister.py\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagmmnn%2Ftextual-filedrop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagmmnn%2Ftextual-filedrop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagmmnn%2Ftextual-filedrop/lists"}