Release: 16/10/2001

Creating windows that reside within another window should ideally be a straightforward process. Unfortunately, windows cannot be arbitrarily embedded within other windows as they need to be specially created with this in mind. However, this isn't too much of a problem as it only requires that such a window be informed of the possibility of such a fate and the actual window into which it is embedded can be left until later.

The program demonstrates the placing of a window inside another. The important part is as follows:

# Create two windows

# The main window
window1 = app.Window(0, 0, 512, 512, 256, 256, 'ctThva', 0, None)

app.add_window(window1, 'window1')

A window is created with no parents, its title is set and it is registered with the app module.

# A window contained within the first window
window2 = app.Window(0, 440, 1024, 72, 512, 72, 'h', 1, 'window1')

Another window is created with the information that its parent will be "window1". The screen coordinates are carefully chosen in reference to those in the first window so that this window will appear at the top of its work area.

Note that the following will also work:

window2 = app.Window(0, 440, 1024, 72, 512, 72, 'h', 1, 'badger')

window1.add_object(window2, 'window2', 0)

The second window is added to the first as an object and the first window is opened in the centre of the screen. Note that the centering must occur after the second window is added since the window placing depends on the screen positions of both windows.

David Boddie