A better way to write the event handlers linking the input widgets and the graph widget