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

Does not dynamically update submenus #72

Open
RazielRV13 opened this issue Apr 23, 2022 · 2 comments
Open

Does not dynamically update submenus #72

RazielRV13 opened this issue Apr 23, 2022 · 2 comments

Comments

@RazielRV13
Copy link

I have created a main menu that has as options scan the time and add it to a file if the numbers are even, on this same main menu I have an option that accesses a submenu that loads the file data to place them as options.

The problem I have is that if I add data to the file on execution when I try to enter the submenu it only shows me the options that the file had when I executed es script.py and not the ones that were added now. How can I make the submenu dynamic, that is, load the new values that were added to the file?

@adriancuevas99
Copy link

Hi! I have the same problem, could you solve it? I see you can redraw the console with the method draw() but i can't make it to work or is not what I am looking for.

@gnalbandian
Copy link

gnalbandian commented May 23, 2024

Same issue here. Any workarounds?

EDIT: After 5 minues reading the code I found where is the issue.

Well, its not an issue itself, but just the way in which the library is done.

The FunctionItem class inherits from ExternalItem which inherits from MenuItem.

In MenuItem is where the tet property is, and is the one that holds the string.
The string inside text is static. It will not change even thou we change a variable that was part of the text as buiding the menu:
ie:
func_item = FunctionItem(f"Set minimun ratio[{config_parameters.min_ratio}]", set_ratio_threshole, [config_parameters])

I'll try to refactor the library and come up with a solution.

EDIT 2:
After 5 more minutes reading...
You can pass a Callable to the text argument. i.e:

func_item = FunctionItem(lambda :f"Set minimun ratio[{config_parameters.min_ratio}]", set_ratio_threshole, [config_parameters])

This will make the library call the lambda function everytime it needs to rewrite the menu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants