The Layout container is similar to the Fixed container except that it implements an infinite (where infinity is less than 2^32) scrolling area. The X window system has a limitation where windows can be at most 32767 pixels wide or tall. The Layout container gets around this limitation by doing some exotic stuff using window and bit gravities, so that you can have smooth scrolling even when you have many child widgets in your scrolling area. A Layout container is created using:
As you can see, you can optionally specify the Adjustment objects (see Chapter 7, Adjustments) that the Layout widget will use for its scrolling. If you don't specify the Adjustment objects, new ones will be created. You can add and move widgets in the Layout container using the following two methods:
The size of the Layout container can be set and retrieved using the next methods:
The final four methods for use with Layout widgets are for manipulating the horizontal and vertical adjustment widgets:
The layout.py example program creates three buttons and puts them in a layout widget. when a button is clicked, it is moved to a random location in the layout. Figure 10.3, “Layout Example” illustrates the starting display of the program: The layout.py source code is:
|