Skip to main content

A modern file dialog for CustomTkinter

Project description

CTkFileDialog-plus

A modern and fully customizable File Dialog for CustomTkinter — a must-have extension pack!

[!WARNING] Unfortunately parameters like video_preview, preview_img, and tooltip are not compatible with the mini dialog and will not be applied. View modes and sorting are exclusive to the Default dialog.


🚀 Features

  • 🔍 Autocomplete in the path entry field (with Tab, Up, and Down)
  • � Search/filter files in real-time
  • 🖼️ Live image preview
  • 🎥 Video thumbnail preview
  • 📁 Directory selection
  • 💾 Save file dialog (return path or open file)
  • ❔ Tooltip support
  • 🖥️ Shell Path Syntax Support
  • ⌨️ Backspace using Alt + Left Arrow shortcut
  • 👀 Multiple view modes (Grid and List view in Default dialog)
  • 📊 Sort files by name, date, size, type, or last modified
  • 💡 Data type validation at runtime and for static type analyzers

📦 Installation

# Using bash 
git clone https://github.com/hmidani-abdelilah/CTkFileDialog-plus
cd CTkFileDialog-plus
python3 -m venv .venv
source .venv/bin/activate
pip3 install -r requirements.txt

# On Windows 
git clone https://github.com/hmidani-abdelilah/CTkFileDialog-plus 
cd CTkFileDialog-plus
python3 -m venv .venv 
.\.venv\Scripts\activate.ps1 # In Powershell
pip3 install -r requirements.txt 

# Or using pip 

python3 -m venv .venv 
source .venv/bin/activate # In Powershell -> .\.venv\Scripts\activate.ps1
pip3 install CTkFileDialog-plus

[!WARNING] You should install the Hack Nerd Fonts if u wanna see the icons without problems :)


🧪 Demo — All Methods

🗂️ Open File

import customtkinter as ctk
from CTkFileDialog import askopenfilename

ctk.set_appearance_mode("Dark")
ctk.set_default_color_theme("blue")

def open_file():
    path = askopenfilename(preview_img=True, autocomplete=True)
    if path:
        result_label.configure(text=f"Selected file:\n{path}")

app = ctk.CTk()
app.title("askopenfilename Demo")
app.geometry("500x200")

ctk.CTkButton(app, text="Open File", command=open_file).pack(pady=20)
result_label = ctk.CTkLabel(app, text="Waiting for file selection...")
result_label.pack()

app.mainloop()

🗂️ Open Multiple Files

import customtkinter as ctk
from CTkFileDialog import askopenfilenames

ctk.set_appearance_mode("Dark")
ctk.set_default_color_theme("blue")

def open_files():
    paths = askopenfilenames(preview_img=True, autocomplete=True)
    if paths:
        result_label.configure(text="Selected files:\n" + "\n".join(paths))

app = ctk.CTk()
app.title("askopenfilenames Demo")
app.geometry("500x300")

ctk.CTkButton(app, text="Open Multiple Files", command=open_files).pack(pady=20)
result_label = ctk.CTkLabel(app, text="Waiting for file selection...", wraplength=450)
result_label.pack()

app.mainloop()

📁 Select Directory

import customtkinter as ctk
from CTkFileDialog import askdirectory

ctk.set_appearance_mode("Dark")
ctk.set_default_color_theme("blue")

def select_directory():
    folder = askdirectory(autocomplete=True)
    if folder:
        result_label.configure(text=f"Selected directory:\n{folder}")

app = ctk.CTk()
app.title("askdirectory Demo")
app.geometry("500x200")

ctk.CTkButton(app, text="Select Directory", command=select_directory).pack(pady=20)
result_label = ctk.CTkLabel(app, text="Waiting for directory selection...")
result_label.pack()

app.mainloop()

💾 Save As (get path only)

import customtkinter as ctk
from CTkFileDialog import asksaveasfilename

ctk.set_appearance_mode("Dark")
ctk.set_default_color_theme("blue")

def save_as_filename():
    path = asksaveasfilename(autocomplete=True)
    if path:
        result_label.configure(text=f"Save file as:\n{path}")

app = ctk.CTk()
app.title("asksaveasfilename Demo")
app.geometry("500x200")

ctk.CTkButton(app, text="Save As (Filename Only)", command=save_as_filename).pack(pady=20)
result_label = ctk.CTkLabel(app, text="Waiting for filename...")
result_label.pack()

app.mainloop()

💾 Save As (write to file)

import customtkinter as ctk
from CTkFileDialog import asksaveasfile

ctk.set_appearance_mode("Dark")
ctk.set_default_color_theme("blue")

def save_as_file():
    f = asksaveasfile(autocomplete=True)
    if f:
        f.write("This file was created using the demo.")
        f.close()
        result_label.configure(text=f"File saved:\n{f.name}")

app = ctk.CTk()
app.title("asksaveasfile Demo")
app.geometry("500x200")

ctk.CTkButton(app, text="Save As (Real File)", command=save_as_file).pack(pady=20)
result_label = ctk.CTkLabel(app, text="Waiting for save location...")
result_label.pack()

app.mainloop()

🧩 Parameters

Parameter Description
hidden Show hidden files or directories (False by default).
preview_img Enable image preview in the file dialog.
video_preview Show first frame of video files as thumbnail (experimental).
autocomplete Enable path autocompletion with Tab, Up, and Down.
initial_dir Set the initial directory when opening the dialog.
tool_tip Enable the tool tip.
style Defines the dialog style, by default it will be 'Default' but you can choose a small one ('Mini')
geometry You define the geometry string in a tuple: Example ('NormalGM', 'MiniGeometry')
title Define the title from the app, default will be "CTkFileDialog"

🌙 Dark Mode Preview

☀️ Light Mode Preview


🎯 Using New Features

🔎 Search/Filter Files

Both Default and Mini dialogs include a search bar. Simply type in the search field to filter files and directories in real-time:

file = askopenfilename(style='Default')
# Use the search bar in the dialog to filter results

👀 View Modes (Default Dialog Only)

The Default dialog supports two view modes:

  • Grid View: Icon-based grid layout (default)
  • List View: Detailed list with file info (size, date modified, type)

Toggle between modes using the view buttons in the toolbar.

📊 Sorting Options (Default Dialog Only)

Sort files by:

  • Name (alphabetical)
  • Date (creation/modification time)
  • Type (file extension)
  • Size (file size)
  • Last Modified (most recent first)

Select a sort option from the sort menu in the toolbar.


This module has constants that can be used outside or inside the dialog, they are used to obtain paths like /home/user or /home/user/.config/ Here is a basic example

#!/usr/bin/env python3 
import customtkinter as ctk 
from CTkFileDialog import askopenfilename
from CTkFileDialog.Constants import HOME

root = ctk.CTk()

def open_file(): 
    f = askopenfilename(initial_dir=HOME, autocomplete=True)
    if f: 
        print(f"file selected: {f}")

ctk.CTkButton(master=root, command=open_file, text="Open File").pack(padx=10, pady=10, anchor=ctk.CENTER)

root.mainloop()

And here are the constants available from the package

Parameter Description
PWD Current working directory (e.g., where the program was launched)
HOME User's home directory (e.g., /home/user or C:\Users\user)
TEMP Temporary directory (fallback to /tmp if no env vars are set)
CONFIG_DIR XDG-compliant user configuration directory (default: ~/.config)
CACHE_DIR XDG-compliant user cache directory (default: ~/.cache)
PATH System PATH split into a list of directories
DATA_DIR XDG-compliant user data directory (default: ~/.local/share)
VENV Active Python virtual environment (venv or conda), fallback to PWD

Mini Dialog

The mini dialog is a compact alternative to the Default dialog. It does not support tooltip, preview_img, or video_preview.

🌙 Dark Mode Preview

☀️ Light Mode Preview

The mini design created by user, and the default design created by user and all credit goes to them. I also want to thank them for creating that design in advance.

I translate the code to English and add this futures:

  • � Search/filter files in real-time
  • 👀 Multiple view modes (Grid and List view in Default dialog)
  • 📊 Sort files by name, date, size, type, or last modified

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

ctkfiledialog_plus-0.5.1.tar.gz (213.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ctkfiledialog_plus-0.5.1-py3-none-any.whl (222.3 kB view details)

Uploaded Python 3

File details

Details for the file ctkfiledialog_plus-0.5.1.tar.gz.

File metadata

  • Download URL: ctkfiledialog_plus-0.5.1.tar.gz
  • Upload date:
  • Size: 213.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for ctkfiledialog_plus-0.5.1.tar.gz
Algorithm Hash digest
SHA256 9cb5778523e35ce1e9b9fb0d02ac7a38b2bc04ecf1147dda47a7f8df80a045ee
MD5 a01bd24706b366ac46b5f47d7d589bc8
BLAKE2b-256 40b021be23888aebc03bf42d85b23e7d359fac2270c367c11d3555431ba4733e

See more details on using hashes here.

File details

Details for the file ctkfiledialog_plus-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ctkfiledialog_plus-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8b3e5c1bf04a0bfd24625628d44d2ed7837d4fb7ead58e9a74ef6f97790b8fc0
MD5 57c703813379971fb8fe0ad904f2e5d6
BLAKE2b-256 c4fdf66c3be8439d76df13dbe236b78327bb6606ddbfe1ed0a742c78c203b1fd

See more details on using hashes here.

Supported by

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