Skip to content

Some adjustments to ctk_scrollable_dropdown.py #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

TuneMeIn
Copy link

@TuneMeIn TuneMeIn commented May 26, 2025

Some tweaks and improvements to the functionality and design of "ctk_scrollable_dropdown.py":

  1. Removed "time.sleep" in order to prevent typing delay in combo boxes, a different method may work better in the future to add a delay to the dropdown appearing without the program being paused completely.

  2. When autocomplete is enabled and a string is typed into a combobox that doesn't match any strings in "values", there won't be any dropdown window that appears automatically. Previously, a dropdown would appear and state "No matches"; however, this doesn't seem to be necessary if a combobox is used similarly to an entry box and takes up screen real estate, potentially covering other elements in the window. This could still be useful if the use case requires the user to type a value that is the same as one of the values in the list, so this adjustment isn't crucial and could potentially become an argument instead.

  3. When autocomplete is enabled and a string is typed into a combobox that doesn't match any strings in "values", though the automatic dropdown no longer appears, pressing the dropdown button manually will show all available strings in "values" rather than displaying "No matches", making it easier for users to choose between either their own typed values or the saved list values.

  4. When using a specified background colour for the window/frame/canvas/etc behind the dropdown, there will be either a black or white pixelation (depending on CTk appearance mode) on the outer edge of the rounded corners of the dropdown, which becomes incredibly noticeable unless using the predefined background colour that comes with the Light and Dark appearance modes. This might be an issue specific to Windows, as I haven't tested on other platforms. Regardless, I have made a workaround by adding an argument for "bg_color", which works the same way as some other CTk widgets, where "bg_color" specifies the colour outside of the border, which you would see if the corners are rounded on some CTk widgets, such as buttons. If a color is specified for the "bg_color" argument, the pixelations will become that color, and this could be used by setting "bg_color" to the same color as any element that is behind the dropdown in order to make the pixelation blend in. If no color is specified, it will simply work like the original code which relies on the appearance mode.

  5. Fixed the scaling of the dropdown window, as it originally had extra blank space beneath the lowest button. Also added functionality for the dropdown to resize when displaying autocomplete options, allocating space for just the visible buttons provided by autocomplete.

  6. Fixed a bug where deleting the final character by pressing backspace, then trying to click off the dropdown would require two clicks. This has been fixed by simply withdrawing the dropdown when the combobox has an empty string (""). There was also an issue after this, where, after the dropdown was removed automatically, pressing the button for it would require two clicks. This has been solved by adding "self.hide = True" under the withdraw command.

I hope these adjustments will help!

@TuneMeIn TuneMeIn changed the title Update ctk_scrollable_dropdown.py A few adjustments to ctk_scrollable_dropdown.py May 26, 2025
@TuneMeIn TuneMeIn changed the title A few adjustments to ctk_scrollable_dropdown.py Some adjustments to ctk_scrollable_dropdown.py May 26, 2025
@Akascape Akascape added the enhancement New feature or request label May 26, 2025
@Akascape
Copy link
Owner

@TuneMeIn Thanks for the enhancements, I will merge this soon!

@TuneMeIn
Copy link
Author

@TuneMeIn Thanks for the enhancements, I will merge this soon!

No worries at all, happy to help!!

TuneMeIn added 2 commits May 27, 2025 17:22
Fixed issue where autocomplete window would show up, and clicking somewhere other than the dropdown in order to remove the dropdown would require two clicks instead of one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants