Last modified: November 2016

URL: https://cxc.cfa.harvard.edu/chips/ahelp/add_window.html
AHELP for CIAO 4.11 ChIPS v1

add_window

Context: windows

Synopsis

Creates a window.

Syntax

add_window([id,] [attributes])
add_window([id,] width, height, units [,attributes])

Description

The function arguments.

Argument Description
id A ChipsId structure identifying the item.
width, height The width and height of the window.
units The units for the width and height values: one of 'inches', 'cm', 'mm', or 'pixels'.
attributes Configure object properties by giving an attribute string (a space-separated list of key=value pairs), list, dictionary, or a ChIPS object.

The add_window command creates a window whose attributes are specified by user preferences or in an attribute list. The new window becomes current by default; providing a ChipsId overrides the currency state.

Customizing the Window

There are several attributes that control the window characteristics. The attributes can be set to the ChIPS defaults, values provided in the add_window command, or values from the user's preference file.

Some of these attributes may also be modified with the set_window command at any time; see "ahelp set_window" and "ahelp setget" for more information.

Please see the section "Window Preferences and Attributes" below the examples for a list of the window preferences.


Examples

Example 1

chips> add_window()

Create a new ChIPS window.

Example 2

chips> add_window(8, 6, 'inches')

The window will be approximately 8 inches wide by 6 inches tall; the exact size depends on the DPI of the monitor. The output size will be exact for postscript and PDF formats.

Example 3

chips> add_window(["bgcolor", "navy", "id", "fig1"])

Add a window, specifying the attribute values in a list: the background color should be navy and the id - as reported by info() and used by current_window() - should be "fig1".

Example 4

chips> add_window(["display", False])
chips> add_curve([1,2,3], [-5,9,2], ["symbol.style", "none"])
chips> add_label(2, -2, r"\alpha=0.2", ["size", 16])
chips> print_window("plot.ps")
chips> print(info())
chips> set_window(["display", True])

A window is created with the display setting set to False, which means that no visible window will be created. A curve and label are added, and a postscript plot (called plot.ps) is created. The output of info() is as follows, which shows that the objects (e.g. curve and label) have been created, they have just not been displayed to the screen:

Window [win1]
  Frame [frm1]
    Plot [plot1]   (0.15,0.15)  .. (0.90,0.90)
      Border bottom [bx1]  top [bx2]  left [by1]  right [by2]
      X Axis [ax1]
      Y Axis [ay1]
      Curve [crv1]
      Label [lbl1]

The final call - to set_window() - changes the display setting to True, at which point a window will appear on screen. Any future changes to the visualization will now be immediately visible (until the display setting is changed back to False).

Example 5

chips> add_window(["smoothing", False])

In CIAO 4.7 the default for the window.smoothing attribute was changed to True. Turning smoothing on can create visually more-attractive plots - both on screen and in bitmap form - but can produce visual artifacts. It can be explicitly set when creating the window, as shown above.

The attribute - as with any other "parent" attribute - can also be changed if a call creates the window; for example:

chips> clear()
chips> add_curve(x, y, ["window.smoothing", False])

Example 6

chips> add_window(["geom", "+0+50", "id", "fig1", "prefix", ">>"])

Create a window, telling the window manager to place it at the left edge of the screen and with its top edge 50 pixels from the top of the screen (note that the window manager may not honor this request). The id of the window is set to "fig1", and the prefix ">>", which means that the window title will be ">>fig1" (which may or may not be displayed by the window manager).

If you want a space to be included in the prefix then the value must be doubly quoted: e.g.

chips> add_window(["prefix", "\"chips - \""])

Example 7

chips> ws = ChipsWindow()
chips> ws.bgcolor = "blue"
chips> ws.width = 20
chips> ws.height = 15
chips> ws.units = "cm"
chips> add_window(ws)

Populate the "ws" structure with the attribute values, then add a window.


Window Preferences and Attributes

The attributes associated with windows are given in the following table, where the "Set?" column refers to whether the attribute can be changed using the set_window() command. To change the window preference settings prepend "window." to the attribute name.

Attribute Description Options Default Set?
bgcolor Background Color of the window name or hex; see the Color section of "ahelp chipsopt" default: white in the ChIPS window, black on printout Yes
display Flag indicating whether the window should be rendered see the Booleans section of "ahelp chipsopt" true Yes
geom A geometry hint to the window manager to say where the ChIPS window should be created (this setting may be ignored, depending on the window manager in use). The format is either a blank string or a string containing two signed integers such as "+100+50", "+0+20", or "+0+0". No
grid.color The color to draw the grid lines. name or hex; see the Color section of "ahelp chipsopt" default No
grid.scale Where should the grid lines be drawn? One of quarterinch, halfinch, cm, or normalized (spacing of a tenth of the window width/height). These can also be specified as default (for quarterinch) or the enumerations 0, 1, 2, 3, 4 for default, quarterinch, halfinch, cm, normalized respectively. quarterinch No
grid.style The style used to draw the grid lines. see the Line Style section of "ahelp chipsopt" longdash No
grid.thickness The thickness used to draw the grid lines. 0.5 to 10.0; see the Thickness section of "ahelp chipsopt" 1 No
grid.visible Should the grid be visible or not. see the Booleans section of "ahelp chipsopt" false No
height window height Numerical value expressed in either inches, centimeters, millimeters or pixels 360 pixels No
scaleheight factor to scale window to display at approximate height positive floating point value 1.25 No
scalewidth factor to scale window to display at approximate width positive floating point value 1.25 No
smoothing use VTK's smoothing to reduce anti-aliasing see the Booleans section of "ahelp chipsopt" true No
stem Stem used for window id An alpha-numeric character sequence that does not contain a space win No
prefix Prefix added to window id to create the text that the window manager may use to label the ChIPS window. "chips - " No
units Units of the window width and height dimensions inches|cm|mm|pixels pixels No
width window width Numerical value expressed in either inches, centimeters, millimeters or pixels 360 pixels No

Bugs

See the bugs pages on the ChIPS website for an up-to-date listing of known bugs.

See Also

chips
chips, chipsgui, chipsrc, show_gui
concepts
aspectratio, attributes, chipsid, chipsopt, colors, coordsys, currency, depthcontrol, entitycreation, preferences, setget
utilities
clear
windows
current_window, deiconify_window, delete_window, get_window, iconify_window, print_window, set_window