Re: Can't manage ... it's a top-level window



vnpenguin wrote:
Hi all,
I'm newbie to Tcl/Tk. Just install ActiveTcl8.4.16.0.282109 on my
Win2k box. I'm try now the follow code:
=========================================
set FR0 [ labelframe .fr0 -text "Test" ];

set lb1 [ label $FR0.name1 -text "Name:" ];
set op_menu1 [ tk_optionMenu $FR0.op1 v_op1 "A" "B" "C" ];
set lb2 [ label $FR0.name2 -text "Name2::" ];
set op_menu2 [ tk_optionMenu $FR0.op2 v_op2 "X" "Y" "Z" ];

grid $lb1 $op_menu1 -row 1
grid $lb2 $op_menu2 -row 2
pack $FR0
=========================================
But when I run I got error:

Can't manage ".fr0.op1.menu": it's a top-level window
while executing
"grid $lb1 $op_menu1 -row 1"
(file "test01.tcl" line 8)

Anyone could tell me how to fix that please,

The option menu widget you want to pack is $FR0.op1 and $FR0.op2. What tk_optionMenu returns is not that widget but the menu widget inside that widget. Yes, it's inconsistent with other widgets, but it's documented that way.

So, do it this way:

grid $lb1 $FR0.op1 -row 1
grid $lb2 $FR0.op2 -row 2



--
Bryan Oakley
http://www.tclscripting.com
.



Relevant Pages

  • Re: Do you agree, its a nonsense [winfo ismapped $x]?
    ... what it was some time before, when you created/deiconified that widget. ... In none of the popup dialogs I'm using "ismapped" - there's no need. ... pack .t.f.b1 ... objects can include the state variables as part of ...
    (comp.lang.tcl)
  • Re: tk widget
    ... Now where I set NOS for textvariable and use this variable when I bind is not working corrrectly. ... So, when you change the value in that textvariable, it changes every widget associated with that variable. ... foreach FN $SCR3 {set FN1 "Field $FN" frame .editFr$FN -borderwidth 10 pack .editFr$FN -side top -fill x ... The main drawback to binding on doesn't handle other cases such as when the user uses the tab or shift-tab key to go to a different field, or clicks in another field, etc. ...
    (comp.lang.tcl)
  • Re: How to rearrange already packed widgets?
    ... pack have been used while creating this UI. ... So I tried called 'grid ... default, if widget a was created before widget b, then widget a is below ... widget b in the stacking order and will be "covered" by widget b. ...
    (comp.lang.tcl)
  • Re: OO in 8.5! Re: TIP #257: Object Orientation for Tcl
    ... Currently it's missing initializing options based on ... WidgetClass Foo -superclass Widget ... pack ... my forward invoke1 $widgetpath.b1 invoke ...
    (comp.lang.tcl)
  • Packing cannot be that difficult, can it?
    ... How to a canvas at the very bottom of ... I found out that if I increase the height of my text widget the ... pack $leftFr -side left ... set rightFr [frame $parent.rightFr] ...
    (comp.lang.tcl)