tcl - Hide/show a widget with a menu checkbutton using [pack info] -


i want save info of frame want hide menu checkbutton. following error:

 option "-in .mainframe -anchor center -expand 0 -fill x -ipadx 0 -ipady 0 -padx 0 -pady 0 -side top" (option no value?)     while executing "pack $w $winfo"     (procedure "cmd_toggle" line 9)     invoked within "cmd_toggle .mainframe.l1"     (menu invoke) 

am using pack info wrong way?

package require tk package require ttk  # menu menu .menu menu .menu.m1 .menu add cascade -menu .menu.m1 -label "menu1" . config -menu .menu  # frame + label frame .mainframe label .mainframe.l1 -text "blabla" -width 22  .menu.m1 add checkbutton -label "toggle" -variable state -command [list cmd_toggle .mainframe.l1]  pack .mainframe.l1 -fill x pack .mainframe -side left  set winfo ""   ; # save of widget pack info  proc cmd_toggle { w } {    global state    global winfo     if {$state} {       set winfo [pack info $w]       pack forget $w    } else {       pack $w $winfo    } } 

thank time.

damien

no, not using pack info wrong way pack itself. pack $w needs list of arguments , presenting 1 single argument don't know.

the solution is, break $winfo list of arguments of {*} operator. changing line this

pack $w {*}$winfo 

gives desired result.

you can use winfo ismapped $w avoid global state variable if don't use checkbutton (that needs variable).

btw: state button showing inverted behaviour. should set true @ beginning , inverting if condition. if set, label shown. true, because command called after variable value has been changed, possible change value in command.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -