Tk Source Code

View Ticket
Login
Ticket UUID: 2782353
Title: add -statevariable option to menus and possibly ttk widgets
Type: RFE Version: None
Submitter: nobody Created on: 2009-04-27 18:31:31
Subsystem: 10. Generic Menus Assigned To: tmh
Priority: 5 Medium Severity:
Status: Open Last Modified: 2009-04-29 13:30:47
Resolution: None Closed By:
    Closed on:
Description:
Many applications change state of menu items and toolbar buttons from normal to disabled and vice versa. Keeping them synchronized is complex. It would be easier to have -statevariable option for menus and ttk widgets, for example
  menu .m
  .m add command -statevariable ::statev0
  ttk::entry .e -statevariable ::statev0
  set ::statev0 disabled
  ... 
  set ::statev0 normal
Currently this could be implemented using traces and overriding widget commands, but script code becomes very complex.
User Comments: nobody added on 2009-04-29 13:30:47:
Well, my reason is to simplify access to menu item states - currently I have to remember which menu it belongs, and use -text value as index. But if I want to change application language (for example), I also have to track these changes and modify indices accordingly.

dkf added on 2009-04-28 03:04:59:
Ttk widgets have a more sophisticated state space model. And in any case, I'd much rather have an Action class (by analogy with the same thing in Java Swing, one of the bits which that toolkit gets pretty close to right) to take care of these details for me.