Skip to content
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

Change text of item in scroll menu #61

Closed
EGAMAGZ opened this issue Jul 11, 2020 · 3 comments
Closed

Change text of item in scroll menu #61

EGAMAGZ opened this issue Jul 11, 2020 · 3 comments
Labels
Feature Request Add for a new feature request Good first issue Good for newcomers Widgets Add for issues having to do with widgets
Milestone

Comments

@EGAMAGZ
Copy link

EGAMAGZ commented Jul 11, 2020

This feature request is not related with any problem. It's just something that with the use of the library I notice and I think is missing

The feature I'm telling is the possibilty to change the text of a selected item in a Scroll Menu with a method. This method could receive the index of the item you want to change and the new text, or only recieve the new text and take the value of the index that is inside the class.

Finally, I want to tell you that I really like the way you're developing this library, is really easy to use.

@EGAMAGZ EGAMAGZ added the Feature Request Add for a new feature request label Jul 11, 2020
@jwlodek
Copy link
Owner

jwlodek commented Jul 12, 2020

Sure I think this is a good idea. Will probably wait till the next release since the current next one has a lot of features and fixes included and I don't want to make too many changes at once.

And glad you like it! My goal was to make it as easy/intuitive as possible.

@jwlodek jwlodek added Widgets Add for issues having to do with widgets Good first issue Good for newcomers labels Jul 12, 2020
@jwlodek jwlodek added this to the v0.1.3 milestone Jul 12, 2020
@jupiterbjy
Copy link
Contributor

I think we can simply use a public method dating back to a991d91 for this one.

py_cui/py_cui/ui.py

Lines 863 to 872 in b4938dd

def get_item_list(self):
"""Function that gets list of items in a scroll menu
Returns
-------
item_list : list of str
list of items in the scrollmenu
"""
return self._view_items

Since this returns direct reference to the list, we can just modify it.

Previously I used to clear, re-add lines within context manager so I can retain selected item and items currently visible on widget. That complex work could be done in one line with this method.

Or adding a convenient method would do.

# in MenuImplementation

def set_item(self, idx: int, text: str):
    self.get_item_list()[idx] = text

@jwlodek
Copy link
Owner

jwlodek commented Feb 20, 2021

A new function set_selected_item was added in the above PR, it will be available once v0.1.3 is released (hopefully by the end of the month).

@jwlodek jwlodek closed this as completed Feb 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Add for a new feature request Good first issue Good for newcomers Widgets Add for issues having to do with widgets
Projects
None yet
Development

No branches or pull requests

3 participants