-- a simple counter GUI to demonstrate the use of menu buttons import Tk import Read counter_widget = TkCol [] [ TkLabel [TkText "A simple counter:"], TkRow [] [TkEntry [TkRef val, TkText "0", TkBackground "yellow"], TkMenuButton [TkText "Menu", TkMenu [TkMButton (tkUpdate incrText val) "Increment", TkMButton (tkSetValue val "0") "Reset", TkMSeparator, TkMMenuButton "Menu again" [TkMButton (tkUpdate incrText val) "Increment", TkMButton (tkSetValue val "0") "Reset", TkMSeparator, TkMButton tkExit "Stop"], TkMSeparator, TkMMenuButton "Small menu" [TkMButton (tkUpdate incrText val) "Increment", TkMButton (tkSetValue val "99") "Set 99"], TkMSeparator, TkMButton tkExit "Stop"]]], TkRow [] [TkButton (tkUpdate incrText val) [TkText "Increment"], TkButton (tkSetValue val "0") [TkText "Reset"], TkButton tkExit [TkText "Stop"]]] where val free incrText s = show (readInt s + 1) main = runWidget "Counter Demo with Menu" counter_widget