Star 历史趋势
数据来源: GitHub API · 生成自 Stargazers.cn
README.md

CTkScrollableDropdown

Replace the old looking tkMenu and add this new scrollable dropdown menu to customtkinter optionmenu, combobox, entries, buttons etc...

Features

  • Rounded corners
  • Define custom height for the menu
  • Automatic resize
  • Transparency effects
  • Autocomplete options
  • Full customisability
  • Add images to options
  • Automatic bindings added for ctkoptionmenu/ctkcombobox

Platform

screenshots

Installation

GitHub repo size

Download the source code, paste the CTkScrollableDropdown folder in the directory where your program is present.

Note: this type of dropdown was discontinued from ctk because of some tkinter OS-related bugs. But I have tried to fix them by experimenting with different window attributes. Current Status: Windows: ✅ Linux: ✅ Mac OS: ⚠️ (random crashes can happen, help wanted)

Simple Usage

CTkScrollableDropdown(attach=widget_name, values=option_list)

Full Example

from CTkScrollableDropdown import *
import customtkinter

root = customtkinter.CTk()

customtkinter.CTkLabel(root, text="Different Dropdown Styles").pack(pady=5)

# Some option list
values = ["python","tkinter","customtkinter","widgets",
          "options","menu","combobox","dropdown","search"]

# Attach to OptionMenu 
optionmenu = customtkinter.CTkOptionMenu(root, width=240)
optionmenu.pack(fill="x", padx=10, pady=10)

CTkScrollableDropdown(optionmenu, values=values)

# Attach to Combobox
combobox = customtkinter.CTkComboBox(root, width=240)
combobox.pack(fill="x", padx=10, pady=10)

CTkScrollableDropdown(combobox, values=values, justify="left", button_color="transparent")

# Attach to Entry
customtkinter.CTkLabel(root, text="Live Search Values").pack()

entry = customtkinter.CTkEntry(root, width=240)
entry.pack(fill="x", padx=10, pady=10)

CTkScrollableDropdown(entry, values=values, command=lambda e: entry.insert(1, e),
                      autocomplete=True) # Using autocomplete

# Attach to Button 
button = customtkinter.CTkButton(root, text="choose options", width=240)
button.pack(fill="x", padx=10, pady=10)

CTkScrollableDropdown(button, values=values, height=270, resize=False, button_height=30,
                      scrollbar=False, command=lambda e: button.configure(text=e))

root.mainloop()

Arguments

ParameterDescription
attachparent widget to which the dropdown menu will be attached
xoptional, change the horizontal offset of the widget manually
yoptional, change the vertical offset of the widget manually
widthoptional, change the default width of the menu
heightoptional, change the default height of the menu
valuesadd the list of options in the dropdown menu
image_valuesoptional, add list of images in options
fg_colorchange the fg_color of the scrollable frame
button_colorchange the fg_color of the buttons/options
hover_colorchange the hover_color of the buttons/options
text_colorchange the text_color of the buttons/options
button_heightchange the height of the buttons if required
autocompleteadd live search options for ctkcombobox or ctkentry widget
alphachange the transparency of the whole dropdown widget (range: 0-1)
justifychange the anchor of the option text
frame_corner_radiusadjust roundness of the frame corners
double_clickbind double click for menu popup
resizeresize the menu dynamically, default: True
frame_border_widthchange the border_width of the frame if required
frame_border_colorchange the border_color of the frame
scrollbarhide the scrollbar if required, default: True
commandadd the command when option is selected
*Other ParametersAll other parameters for ctkbutton or scrollbar can be passed in dropdownmenu

Methods

  • .insert(value="new_option", ...)

    Add a new option to the list

  • .configure(values=new_values, height=500, ...)

    Update some parameters for the dropdown

  • .live_update(string="option")

    filter options dynamically

  • .destroy_popup()

    Remove the dropdown completely

  • .popup(x, y)

    Show popup menu manually

Note: if you are facing some issues then try using the CTkScrollableDropdownFrame.

关于 About

Easily add a new scrollable dropdown menu in customtkinter widgets (extension/add-on)
customtkinterdropdown-menudropdown-menuspopup-menuscrollable-menutkintertkinter-guitkinter-python

语言 Languages

Python100.0%

提交活跃度 Commit Activity

代码提交热力图
过去 52 周的开发活跃度
0
Total Commits
峰值: 1次/周
Less
More

核心贡献者 Contributors