my $viewbutton = $mw->Button(-text=>"Change view", -command=>\&changeView); ... sub changeView { $viewmode++; if($viewmode > 3) { $viewmode = 0; } updateGraph(); return; } #### The only events for which bindings may be specified are those related to the mouse and keyboard (such as Enter, Leave, ButtonPress, Motion, and KeyPress) or virtual events. The handling of events in canvases uses the current item defined in "ITEM IDS AND TAGS" above. Enter and Leave events trigger for an item when it becomes the current item or ceases to be the current item; note that these events are different than Enter and Leave events for windows. Mouse-related events are directed to the current item, if any. Keyboard-related events are directed to the focus item, if any (see the focus method below for more on this). If a virtual event is used in a binding, that binding can trigger only if the virtual event is defined by an underlying mouse-related or keyboard-related event.