Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:dgarcia:python312:numeric
python-ipyfilechooser
ipyfilechooser_examples.ipynb
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ipyfilechooser_examples.ipynb of Package python-ipyfilechooser
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# ipyfilechooser examples" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from ipyfilechooser import FileChooser\n", "import os\n", "\n", "# Create new FileChooser:\n", "# Path: current directory\n", "# File: test.txt\n", "# Title: <b>FileChooser example</b>\n", "# Show hidden files: no\n", "# Use the default path and filename as selection: yes\n", "# Only show folders: no\n", "fdialog = FileChooser(\n", " os.getcwd(),\n", " filename='test.txt',\n", " title='<b>FileChooser example</b>',\n", " show_hidden=False,\n", " select_default=True,\n", " show_only_dirs=False\n", ")\n", "\n", "display(fdialog)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Get the selected value\n", "fdialog.selected" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Callback example\n", "def change_title(chooser):\n", " chooser.title = '<b>Callback function executed</b>'\n", "\n", "# Register callback function\n", "fdialog.register_callback(change_title)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Set or change the title\n", "fdialog.title = '<b>Select the output file</b>'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Show hidden files, change rows to 10, and hide folder icons\n", "fdialog.show_hidden = True\n", "fdialog.rows = 10\n", "fdialog.dir_icon = None" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Change folder icon to `os.sep` and append it to the folder name\n", "fdialog.dir_icon = os.sep\n", "fdialog.dir_icon_append = True" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Restrict navigation\n", "fdialog.sandbox_path = '/Users/jdoe'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Switch to folder-only mode\n", "fdialog.show_only_dirs = True" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Switch back to standard mode\n", "fdialog.show_only_dirs = False" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Set a file filter pattern (uses https://docs.python.org/3/library/fnmatch.html)\n", "fdialog.filter_pattern = '*.txt'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Set multiple file filter patterns (uses https://docs.python.org/3/library/fnmatch.html)\n", "fdialog.filter_pattern = ['*.jpg', '*.png']" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Change the default path and filename\n", "fdialog.default_path = os.path.abspath(os.path.join(os.getcwd(), '..'))\n", "fdialog.default_filename = 'foobar.txt'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Reset to defaults and clear the selected value\n", "fdialog.reset()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# String representation\n", "print(fdialog)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Print the version number\n", "import ipyfilechooser\n", "ipyfilechooser.__version__" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.3" } }, "nbformat": 4, "nbformat_minor": 4 }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor