python - How to prevent tkinter button command from executing immediately the program is run -


this question has answer here:

so i'm working on, again code in this question...
im wondering how go doing this:

from tkinter import * tkinter import messagebox mb # ... def info(text):     mb.showinfo(text) # ... helpmenu.add_command(label="version", command=info("not yet realesed")) # ... 

what automaticly executes info().
how can prevent this?

you need use lambda function prevent info() being executed automatically:

helpmenu.add_command(label="version", command=lambda: info("not yet realesed"))  

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -