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

Passing arguments for the function in menu_options. #31

Open
ChemicalSmart opened this issue Oct 23, 2020 · 1 comment
Open

Passing arguments for the function in menu_options. #31

ChemicalSmart opened this issue Oct 23, 2020 · 1 comment

Comments

@ChemicalSmart
Copy link

Hi, i am pretty new to python.

I am not able to pass any argument to any of the functions that are in the menu_options tree?
Could someone explain how to do it?

When i click one of the options of the menu i want to call a function that needs two arguments but i am not able to pass them, it gives me an error, like if the function didn't accept any arguments.
And also whenever i run the project , the function in the menu_options tree always runs even though i dont click the button in the tray area for it run.

Thanks in advanced.

@MarkimGarito
Copy link

MarkimGarito commented Nov 7, 2020

You can use lambda:

def say_hello(argument):
    print "Hello, World!\n" + argument
menu_options = (("Say Hello", None, lambda x: say_hello("I'm a argument"),)

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

2 participants