'A single button that fires two self commands

I have two separate functions which were controlled by two buttons.

Button one:

self.generate_negative_binomial_distribution_points = Button(self.init_window_name,
                                                         text="Generate",
                                                         command=self.generate_points)

Button two:

self.str_trans_to_md5_button = Button(self.init_window_name,
                                      text="U Test",
                                      command=self.str_trans_to_md5) 

Now I am trying to call the two commands in one button:

self.figure_scatter_points = Button(self.init_window_name,
                                text="MC Sim",
                                command=lambda:(self.generate_points(), self.str_trans_to_md5())) 

I was told "'Button' object is not callable".

Anyone can tell me how to change this code?

Thx in advance.



Solution 1:[1]

I am not sure what framework you are using, but lmabda should be used with functions. Your code should be something like this

self.figure_scatter_points = Button(self.init_window_name, text="MC Sim", command=lambda:(self.generate_points(), self.str_trans_to_md5()))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 A. Ahmed