Skip to main content

Enhanced CTkScrollableDropdown with pagination, search and groups support

Project description

CTkScrollableDropdownPP

PyPI Downloads

CTkScrollableDropdownPP is an enhanced dropdown widget for CustomTkinter featuring pagination, live search, and grouping support.

Based on the original CTkScrollableDropdown project.

Features

  • Pagination for large lists
  • Real-time filtering
  • Grouped items (using regex or labels)
  • Autocomplete on typing
  • Fully customizable appearance

Installation

pip install ctkscrollabledropdownpp

Example

import customtkinter
from PIL import Image, ImageDraw
from CTkScrollableDropdownPP import CTkScrollableDropdown
import io


def create_color_image(color, width=20, height=20):
    """Create an image of the specified color"""
    img = Image.new('RGBA', (width, height), (0, 0, 0, 0))
    draw = ImageDraw.Draw(img)
    draw.rectangle((0, 0, width - 1, height - 1), fill=color)
    img_bytes = io.BytesIO()
    img.save(img_bytes, format='PNG')
    img_bytes.seek(0)
    return customtkinter.CTkImage(Image.open(img_bytes), size=(width, height))


def create_number_image(number, width=20, height=20):
    """Create an image with a digit"""
    img = Image.new('RGBA', (width, height), (0, 0, 0, 0))
    draw = ImageDraw.Draw(img)
    draw.rectangle((0, 0, width - 1, height - 1), fill="#FFFFFF")
    draw.text((width // 2, height // 2), str(number), fill="#000000", anchor="mm")
    img_bytes = io.BytesIO()
    img.save(img_bytes, format='PNG')
    img_bytes.seek(0)
    return customtkinter.CTkImage(Image.open(img_bytes), size=(width, height))


# Create main window
root = customtkinter.CTk()
root.geometry("500x400")

# Create CTkComboBox
combobox = customtkinter.CTkComboBox(root, width=250)
combobox.pack(pady=50)

# Data for dropdown list
colors = {
    "Red": "#FF0000",
    "Green": "#00FF00",
    "Blue": "#0000FF",
    "Yellow": "#FFFF00",
    "Orange": "#FFA500",
    "Purple": "#800080",
    "Pink": "#FFC0CB",
    "Brown": "#A52A2A",
    "Black": "#000000",
    "White": "#FFFFFF"
}

numbers = [str(i) for i in range(10)]  # Digits from 0 to 9

# Create lists of values and images
color_values = list(colors.keys())
color_images = [create_color_image(color_code) for color_code in colors.values()]

number_values = numbers
number_images = [create_number_image(num) for num in numbers]

# Combine all values and images
all_values = color_values + number_values
all_images = color_images + number_images

# Groups for sorting
groups = [
    ["Numbers", "^[0-9]$"],
    ["Colors", "__OTHERS__"]
]

# Create dropdown list
dropdown = CTkScrollableDropdown(attach=combobox, button_color="#2b2b2b", height=200, width=300, fg_color="#333333",
                                 values=all_values, command=lambda value: print(f"Selected: {value}"),
                                 image_values=all_images, text_color="#ffffff", hover_color="#3a3a3a",
                                 font=("Arial", 12), groups=groups, items_per_page=10)

root.mainloop()

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

ctkscrollabledropdownpp-2.1.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

ctkscrollabledropdownpp-2.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file ctkscrollabledropdownpp-2.1.tar.gz.

File metadata

  • Download URL: ctkscrollabledropdownpp-2.1.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for ctkscrollabledropdownpp-2.1.tar.gz
Algorithm Hash digest
SHA256 350dcee49f517090c0dc4dcdbc6a9d8b6959b83ac0a1f49b6496399870efc6bf
MD5 57fda6a07b9104edf020b832a70828de
BLAKE2b-256 0f84a7b6f84e3380253b7a4741dda826697a62f51ad281fc412cb74dad869a51

See more details on using hashes here.

File details

Details for the file ctkscrollabledropdownpp-2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ctkscrollabledropdownpp-2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f9001306655334b4738b705fe50cd428f4240af6c5d209285786cd61763fbdef
MD5 b82c0f6b388384340b23c55eb9cabb7a
BLAKE2b-256 ff394c9fcea55675fb5321347d7195dcdcba40c8274271e351e2ebc4e44cfa68

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