In my View class I want to use pydispatcher.dispatcher send method in a tkinter Button command to signal to my Controller class in a MVC design that the button has been pressed. I do this:
self.calc_button = tkinter.Button(self.bottom_frame,text='Convert', \
command=dispatcher.send(signal = 'valueToConvert', sender=dispatcher.Any, message='Kilo'))
The weird thing (to me) is that the dispatcher.send is “activated” when the button is created. Why? Further the dispatcher.send is never “activated” when the button is pressed. Why?
In the controller class this is the “listener” construction:
class Controller():
def __init__(self):
dispatcher.connect(self.myListener,
signal='valueToConvert',
sender=dispatcher.Any)
self.model = Model()
self.view = View()
def myListener(self, message, arg2=None):
print("Received the following message: " + message)