next up previous
Next: Other documentation Up: The Tk Packer Previous: Option-parameters

Using frames

Using only the abovementioned constructions it's not possible to create a window like

To create such a window, frames have to be used. A frame can be used as a kind of subwindow. Other widgets can be packed in a frame, and the frame (containing widgets) can then be packed to another window or frame. For the example this would mean that the leftmost buttons would be packed on top of eachother within a frame, and the frame would be packed at the left side of the window; space would then remain at the right side of the window. Next, the rightmost buttons would be packed at that remaining space.

For example:

    frame* f = new frame(".frame");         // frame is a child of the
                                            // main-window
    button* b1 = new button(f, ".b1", "-text Button1"); 
                                            // button is child of f
    button* b2 = new button(f, ".b2", "-text Button2");

    button* b3 = new button(".b3", "-text Button3");         
                                            // buttons on rightside are
                                            // children of main-window
    button* b4 = new button(".b4", "-text Button4");   

    b1 -> pack("-side top -fill both -expand true");
    b2 -> pack("-side bottom -fill both -expand true");

    f -> pack("-side left -fill both -expand true");

    b3 -> pack("-side top -fill both -expand true");
    b4 -> pack("-side bottom -fill both -expand true");



Megens SA
Thu Jun 20 11:34:42 MET DST 1996