I'm working on a tkinter ttk interface to automate/facilitate some relatively complex reporting.
I have a function which performs a complex data scan across a directory. To execute the function you click a button widget in the toolbar:
fileMenu.add_command(label="Generate Report",command=ScanActiveProjects)
However I would like to reuse the code in this function by adding an additional parameter (simple=True/False) so that I can map a partial and a complete execution of the function to individual buttons.
I thought that I could do this fairly simply like this:
fileMenu.add_command(label="Generate Management Report",command=ScanActiveProjects(simple=True)
fileMenu.add_command(label="Generate Detailed Report",command=ScanActiveProjects(simple=False)
The result of this is that the button is automatically pressed on starting up the program - which I don't understand. So my questions are:
1) Why is the button automatically pressed when adding the (simple=True)/(simple=False)parameters?
2) How can I bind a callback function to a button but have the button provide a specific constructor parameter?