Skip to main content

CTkSuggestions implements a suggestion dropdown for a customtkinter widget

Project description

CTkSuggestions

CTkSuggestions implements a suggestion dropdown for a customtkinter widget

Features

  • QWERTZ and QWERTY Layouts: Supports both QWERTZ and QWERTY keyboard layouts for different user preferences.
  • Enhanced Focus: Ensures improved focus with a dedicated entry for better text input.
  • Touch-Friendly: Designed specifically for touch displays, perfect for Raspberry Pi projects.
  • Special keys: Ensure easy entry of numbers and special characters.
  • Open Source: Free to use and modify.

Installation

pip install CTkSuggestions

Example

import customtkinter as ctk
from CTkSuggestion import suggestions
example_lst = [
    "apple","banana","cherry","date","elderberry","fig","grape",
    "honeydew","kiwi","lemon","mango","nectarine","orange",
    "papaya","quince","raspberry","strawberry","tangerine",
    "ugli fruit","vanilla","watermelon","zucchini"
]
#Setup Ctk window
app = ctk.CTk()

app.title("CTkSuggestions_example")

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

screen_width = app.winfo_screenwidth()
screen_height = app.winfo_screenheight()

#configure window size
window_width = screen_width // 2
window_height = screen_height // 2
app.geometry(f"{window_width}x{window_height}+{screen_width//4}+{screen_height//4}")

#Create entry fields
entry = ctk.CTkEntry(app, placeholder_text="Entry",justify="center", font=("Arial", 32, "bold"))
entry2 = ctk.CTkEntry(app, placeholder_text="Entry2",justify="center", font=("Arial", 32, "bold"))
entry3 = ctk.CTkEntry(app, placeholder_text="Entry3",justify="center", font=("Arial", 32, "bold"))

entry.pack(pady=10)
entry2.pack(pady=10)
entry3.pack(pady=10)

#Bind Suggestions on FocusIn event 
entry.bind("<FocusIn>", lambda e: suggestions(app,entry,example_lst))
entry2.bind("<FocusIn>", lambda e: suggestions(app,entry2,example_lst))
entry3.bind("<FocusIn>", lambda e: suggestions(app,entry3,example_lst))

app.mainloop()

Options

Option Description
Master CustomTkinter main window
Widget Entry widget to bind suggestion
List List with potential suggestions

Usage

To use CTkSuggestions in your project, follow these steps:

  • Bind to entry: Bind the suggestion function to the entry widget, and it should appear automatically when the entry widget is focused.

  • Run your code: Execute your code.

  • Focus entry: Klick into the entry and a suggestion table will appear.

  • Typing: After typing at least 3 letters and a suggestion with change.

  • List all: You can type "*" to show all entrys from the list will appear.

  • Confirm entry: Klick the option you search for or press Enter to insert it into the widget.

Credits

Note: Parts of the code in this example are from CustomTkinter and CTkListbox

If you find my code helpful and would like to support me, feel free to buy me a Ko-fi. However, if you don't want to, that's okay too!

I'm always open to feedback to improve this project further!

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

CTkSuggestions-0.2.2.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

CTkSuggestions-0.2.2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file CTkSuggestions-0.2.2.tar.gz.

File metadata

  • Download URL: CTkSuggestions-0.2.2.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.2

File hashes

Hashes for CTkSuggestions-0.2.2.tar.gz
Algorithm Hash digest
SHA256 e0c063e33904113b2a425df55670bd6b3c6c3d0854b6d930326a5db09e66801f
MD5 fc580c41ee9859876fb0f80709664216
BLAKE2b-256 887751ff24f15130677fb0941ba671fc5327b60a318191e1e26a3f1d2fa21f6e

See more details on using hashes here.

File details

Details for the file CTkSuggestions-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for CTkSuggestions-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e2b5ee0acd7a3068496a7f04e0756ba2b272c651a7e8c97748af19159fe630ce
MD5 d9a5dfb6f862291d8814e3232713e1f7
BLAKE2b-256 165cd2907b5a8aa20eaedb45f6b8babcee7b5b80130b379a814c8c0bdb7d3ff3

See more details on using hashes here.

Supported by

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