https://github.com/akascape/ctklistbox
A simple listbox for customtkinter (extenstion/add-on)
https://github.com/akascape/ctklistbox
customtkinter customtkinter-widgets listbox tkinter tkinter-gui tkinter-widgets
Last synced: 3 months ago
JSON representation
A simple listbox for customtkinter (extenstion/add-on)
- Host: GitHub
- URL: https://github.com/akascape/ctklistbox
- Owner: Akascape
- License: mit
- Created: 2023-06-21T10:42:33.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-02T14:42:41.000Z (11 months ago)
- Last Synced: 2024-10-31T09:04:51.168Z (8 months ago)
- Topics: customtkinter, customtkinter-widgets, listbox, tkinter, tkinter-gui, tkinter-widgets
- Language: Python
- Homepage:
- Size: 76.2 KB
- Stars: 161
- Watchers: 4
- Forks: 14
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# CTkListbox
This is a **listbox widget** for customtkinter, works just like the tkinter listbox.
## Installation
```
pip install CTkListbox
```
### [](https://github.com/Akascape/CTkListbox/archive/refs/heads/main.zip)
## Usage
```python
import customtkinter
from CTkListbox import *def show_value(selected_option):
print(selected_option)
root = customtkinter.CTk()listbox = CTkListbox(root, command=show_value)
listbox.pack(fill="both", expand=True, padx=10, pady=10)listbox.insert(0, "Option 0")
listbox.insert(1, "Option 1")
listbox.insert(2, "Option 2")
listbox.insert(3, "Option 3")
listbox.insert(4, "Option 4")
listbox.insert(5, "Option 5")
listbox.insert(6, "Option 6")
listbox.insert(7, "Option 7")
listbox.insert("END", "Option 8")root.mainloop()
```
## Arguments
| Parameter | Description |
|-----------| ------------|
| **master** | parent widget |
| width | **optional**, set width of the listbox |
| height | **optional**, set height of the listbox |
| fg_color | foreground color of the listbox |
| border_color | border color of the listbox frame |
| border_width | width of the border frame |
| text_color | set the color of the option text |
| hover | Enable/Disable hover effect (bool) |
| hover_color | set hover color of the options |
| button_color | set color of unselected buttons |
| highlight_color | set the selected color of the option |
| font | set font of the option text, must be a tuple or CTkFont |
| wraplength | change the number of letter per option line |
| justify | change the text anchor; left, right or center |
| command | calls a command when a option is selected |
| multiple_selection | select multiple options in the listbox, `default=False`|
| listvariable | use a tkinter variable to change the listbox content |
| *other_parameters | _all other parameters of ctk_scrollable frame can be passed_ |## Methods
- **.insert(index, option)**
add new option to the listbox
- **.get()**
get the selected option(s)
- **.delete(index)**
delete any option from the listbox. `.delete("all")` deletes all options
- **.size()**
get the size of the listbox
- **.activate(index)**
activate any option
- **.deactivate(index)**
deactivate any option
- **.curselection()**
returns indexes of selected options
- **.configure()**
change some parameters for the listbox.
- **.see(index)**
move the listbox scrollbar to the index place
- **.move_up(index)/.move_down(index)**
Reorder options in the listbox
### Thanks for visiting! Hope it will help :)