Pergunta

I found this pie menu code for TCL/Tk here: http://wiki.tcl.tk/15400

There is a line of code I don't understand:

-command0 {bind .c <Button-1> {}; %W delete __pm; incr cnt} \

What does it mean? I think this happens: the global variable cnt is incremented. All items with the tag __pm will be removed from the canvas. This all happens if the mouse button is clicked. But this doesn't really make sense does it?

Foi útil?

Solução

It makes sense if you actually run the demo, which demonstrates pie menus with a varying number of buttons. Clicking the central "button" labelled "Ok" will delete the pie menu. Note that this central text element is item 0. %W is short-hand for the pathname of the window relating to the Tk event that fired. Incrementing the cnt (count) will cause the next pie menu to be created to have a different number of "button" elements.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top