gtk.gdk.Visual
gtk.gdk.Visual — an object containing hardware display
information
Description
A gtk.gdk.Visual
describes a particular video hardware display format. It includes
information about the number of bits used for each color, the way the bits
are translated into an RGB value for display, and the way the bits are
stored in memory. For example, a piece of display hardware might support
24-bit color, 16-bit color, or 8-bit color; meaning 24/16/8-bit pixel sizes.
For a given pixel size, pixels can be in different formats; for example the
"red" element of an RGB pixel may be in the top 8 bits of the pixel, or may
be in the lower 4 bits.
Usually you can avoid thinking about visuals in
PyGTK. Visuals are useful to interpret the contents of a
gtk.gdk.Image,
but you should avoid gtk.gdk.Image
precisely because its contents depend on the display hardware; use gtk.gdk.Pixbuf
instead, for all but the most low-level purposes. Also, anytime you provide
a gtk.gdk.Colormap,
the visual is implied as part of the colormap (see the gtk.gdk.Colormap.get_visual()
method), so you won't have to provide a visual in addition.
There are several standard visuals. The visual returned by the
gtk.gdk.visual_get_system()
function is the system's default visual. The gtk.gdk.rgb_get_visual()
function returns the visual most suited to displaying full-color image data.
If you use the calls in GdkRGB, you should create your windows using this
visual (and the colormap returned by the gtk.gdk.rgb_get_colormap()
function).
A number of functions are provided for determining the "best"
available visual. For the purposes of making this determination, higher bit
depths are considered better, and for visuals of the same bit depth,
gtk.gdk.VISUAL_PSEUDO_COLOR is preferred at 8bpp,
otherwise, the visual types are ranked in the order of (highest to lowest)
gtk.gdk.VISUAL_DIRECT_COLOR,
gtk.gdk.VISUAL_TRUE_COLOR,
gtk.gdk.VISUAL_PSEUDO_COLOR,
gtk.gdk.VISUAL_STATIC_COLOR,
gtk.gdk.VISUAL_GRAYSCALE, then
gtk.gdk.VISUAL_STATIC_GRAY.
Constructor
gtk.gdk.Visual(depth, visual_type)
|
depth : | a bit depth |
visual_type : | a visual type |
Returns : | the best gtk.gdk.Visual with
both depth and visual_type, or
None if none |
Creates a new gtk.gdk.Visual that
is the best choice for the specified depth and
visual_type. Color visuals and visuals with mutable
colormaps are preferred over grayscale or fixed-colormap visuals and visuals
with higher color depths are considered better. The value of
visual_type must be one of:
gtk.gdk.VISUAL_STATIC_GRAY | Each pixel value indexes a grayscale value
directly. |
gtk.gdk.VISUAL_GRAYSCALE | Each pixel is an index into a color map that maps pixel
values into grayscale values. The color map can be changed by an
application. |
gtk.gdk.VISUAL_STATIC_COLOR | Each pixel value is an index into a predefined,
unmodifiable color map that maps pixel values into RGB values. |
gtk.gdk.VISUAL_PSEUDO_COLOR | Each pixel is an index into a color map that maps pixel
values into rgb values. The color map can be changed by an
application. |
gtk.gdk.VISUAL_TRUE_COLOR | Each pixel value directly contains red, green, and blue
components. The red_mask, green_mask, and blue_mask fields of the gtk.gdk.Visual
structure describe how the components are assembled into a pixel
value. |
gtk.gdk.VISUAL_DIRECT_COLOR | Each pixel value contains red, green, and blue components
as for gtk.gdk.TRUE_COLOR, but the components are mapped
via a color table into the final output table instead of being converted
directly. |
Methods
gtk.gdk.Visual.get_screen
Returns : | the screen that this visual belongs
to. |
Note
This method is available in PyGTK 2.2 and above.
The get_screen() method returns the
gtk.gdk.Screen
that this visual belongs to.
Functions
gtk.gdk.list_visuals
def gtk.gdk.list_visuals()
|
The gtk.gdk.list_visuals() function returns
a list containing the available gtk.gdk.Visual
objects for the default screen.
gtk.gdk.visual_get_best
def gtk.gdk.visual_get_best()
|
The gtk.gdk.visual_get_best() function
returns the visual with the most available colors for the default
screen.
gtk.gdk.visual_get_best_depth
def gtk.gdk.visual_get_best_depth()
|
The gtk.gdk.visual_get_best_depth()
function returns the gtk.gdk.Visual with
the best depth for the default screen where "best" means the largest
gtk.gdk.visual_get_best_type
def gtk.gdk.visual_get_best_type()
|
The gtk.gdk.visual_get_best_type() function
returns the best available gtk.gdk.Visual type
for the default screen.
gtk.gdk.visual_get_best_with_depth
def gtk.gdk.visual_get_best_with_depth(depth)
|
depth : | the number of bits per
pixel |
Returns : | the best gtk.gdk.Visual for
the specified depth |
The gtk.gdk.visual_get_best_with_depth()
function returns the best gtk.gdk.Visual with
the specified depth.
gtk.gdk.visual_get_best_with_type
def gtk.gdk.visual_get_best_with_type(type)
|
type : | a visual type |
Returns : | the best gdkVisual for the visual type
specified by type |
The gtk.gdk.visual_get_best_with_type()
function returns the best gtk.gdk.Visual for
the visual type specified by type. The value of
visual_type must be one of:
gtk.gdk.VISUAL_STATIC_GRAY | Each pixel value indexes a grayscale value
directly. |
gtk.gdk.VISUAL_GRAYSCALE | Each pixel is an index into a color map that maps pixel
values into grayscale values. The color map can be changed by an
application. |
gtk.gdk.VISUAL_STATIC_COLOR | Each pixel value is an index into a predefined,
unmodifiable color map that maps pixel values into RGB values. |
gtk.gdk.VISUAL_PSEUDO_COLOR | Each pixel is an index into a color map that maps pixel
values into rgb values. The color map can be changed by an
application. |
gtk.gdk.VISUAL_TRUE_COLOR | Each pixel value directly contains red, green, and blue
components. The red_mask, green_mask, and blue_mask fields of the gtk.gdk.Visual
structure describe how the components are assembled into a pixel
value. |
gtk.gdk.VISUAL_DIRECT_COLOR | Each pixel value contains red, green, and blue
components as for gtk.gdk.TRUE_COLOR, but the components
are mapped via a color table into the final output table instead of being
converted directly. |
gtk.gdk.visual_get_system
def gtk.gdk.visual_get_system()
|
The gtk.gdk.visual_get_system() function
returns the default gtk.gdk.Visual for
the system's default screen.
gtk.gdk.query_depths
def gtk.gdk.query_depths()
|
Note
This function is available in PyGTK 2.4 and above.
The gtk.gdk.query_depths() function returns
a tuple containing the unique supported visual depths for the default
screen. It's equivalent to listing the visuals (see the gtk.gdk.list_visuals()
function) and then looking at the depth field in each visual, removing
duplicates.
gtk.gdk.query_visual_types
def gtk.gdk.query_visual_types()
|
The gtk.gdk.query_visual_types() function
returns a tuple containing the unique visual types supported by the default
screen.It's equivalent to listing the visuals (see the gtk.gdk.list_visuals()
function) and then looking at the type field in each visual, removing
duplicates.
The returned value will be one of:
gtk.gdk.VISUAL_STATIC_GRAY | Each pixel value indexes a grayscale value
directly. |
gtk.gdk.VISUAL_GRAYSCALE | Each pixel is an index into a color map that maps pixel
values into grayscale values. The color map can be changed by an
application. |
gtk.gdk.VISUAL_STATIC_COLOR | Each pixel value is an index into a predefined,
unmodifiable color map that maps pixel values into RGB
values. |
gtk.gdk.VISUAL_PSEUDO_COLOR | Each pixel is an index into a color map that maps pixel
values into rgb values. The color map can be changed by an
application. |
gtk.gdk.VISUAL_TRUE_COLOR | Each pixel value directly contains red, green, and blue
components. The red_mask, green_mask, and blue_mask fields of
the gtk.gdk.Visual
structure describe how the components are assembled into a pixel
value. |
gtk.gdk.VISUAL_DIRECT_COLOR | Each pixel value contains red, green, and blue
components as for gtk.gdk.VISUAL_TRUE_COLOR,
but the components are mapped via a color table into the final
output table instead of being converted directly. |