gtk.Style

gtk.Style — an object that hold style information for widgets

Synopsis

class gtk.Style(gobject.GObject):
    gtk.Style()
def copy()
def attach(window)
def detach()
def set_background(window, state_type)
def apply_default_background(window, set_bg, state_type, area, x, y, width, height)
def lookup_icon_set(stock_id)
def render_icon(source, direction, state, size, widget, detail)
def paint_hline(window, state_type, area, widget, detail, x1, x2, y)
def paint_vline(window, state_type, area, widget, detail, y1, y2, x)
def paint_shadow(window, state_type, shadow_type, area, widget, detail, x, y, width, height)
def paint_polygon(window, state_type, shadow_type, area, widget, detail, points, fill)
def paint_arrow(window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height)
def paint_diamond(window, state_type, shadow_type, area, widget, detail, x, y, width, height)
def paint_box(window, state_type, shadow_type, area, widget, detail, x, y, width, height)
def paint_flat_box(window, state_type, shadow_type, area, widget, detail, x, y, width, height)
def paint_check(window, state_type, shadow_type, area, widget, detail, x, y, width, height)
def paint_option(window, state_type, shadow_type, area, widget, detail, x, y, width, height)
def paint_tab(window, state_type, shadow_type, area, widget, detail, x, y, width, height)
def paint_shadow_gap(window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width)
def paint_box_gap(window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width)
def paint_extension(window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side)
def paint_focus(window, state_type, area, widget, detail, x, y, width, height)
def paint_slider(window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation)
def paint_handle(window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation)
def paint_expander(window, state_type, area, widget, detail, x, y, expander_style)
def paint_layout(window, state_type, use_text, area, widget, detail, x, y, layout)
def paint_resize_grip(window, state_type, area, widget, detail, edge, x, y, width, height)

Ancestry

+-- gobject.GObject
  +-- gtk.Style

Attributes

Note

Even though the following attributes that are arrays of gtk.gdk.Color, gtk.gdk.GC or gtk.gdk.Pixmap objects are read-only, the individual array items are read-write.

"fg"ReadAn array of gtk.gdk.Colors to be used for the foreground colors in each widget state.
"bg"ReadAn array of gtk.gdk.Colors to be used for the background colors in each widget state.
"light"ReadAn array of gtk.gdk.Colors to be used for the light colors in each widget state. The light colors are slightly lighter than the bg colors and used for creating shadows.
"dark"ReadAn array of gtk.gdk.Colors to be used for the dark colors in each widget state. The dark colors are slightly darker than the bg colors and used for creating shadows.
"mid"ReadAn array of gtk.gdk.Colors to be used for the mid colors (between light and dark) in each widget state
"text"ReadAn array of gtk.gdk.Colors to be used for the text colors in each widget state.
"base"ReadAn array of gtk.gdk.Colors to be used for the base colors in each widget state.
"text_aa"ReadAn array of gtk.gdk.Colors to be used for the anti-aliased text colors in each widget state.
"black"Read-WriteA gtk.gdk.Color that is used for the black color.
"white"Read-WriteA gtk.gdk.Color that is used for the white color.
"font_desc"ReadA pango.FontDescription used as the default text font.
"xthickness"ReadThe thickness of lines drawn vertically.
"ythickness"ReadThe thickness of lines drawn horizontally.
"fg_gc"ReadAn array of graphics contexts (gtk.gdk.GC) for drawing using the fg colors.
"bg_gc"ReadAn array of graphics contexts (gtk.gdk.GC) for drawing using the bg colors.
"light_gc"ReadAn array of graphics contexts (gtk.gdk.GC) for drawing using the light colors.
"dark_gc"ReadAn array of graphics contexts (gtk.gdk.GC) for drawing using the dark colors.
"mid_gc"ReadAn array of graphics contexts (gtk.gdk.GC) for drawing using the mid colors.
"text_gc"ReadAn array of graphics contexts (gtk.gdk.GC) for drawing using the text colors.
"base_gc"ReadAn array of graphics contexts (gtk.gdk.GC) for drawing using the base colors.
"text_aa_gc"ReadAn array of graphics contexts (gtk.gdk.GC) for drawing using the anti-aliased text colors.
"black_gc"Read-WriteA graphics context (gtk.gdk.GC) for drawing using the black color.
"white_gc"Read-WriteA graphics context (gtk.gdk.GC) for drawing using the white color.
"bg_pixmap"ReadAn array of gtk.gdk.Pixmap to be used for the background stippling in each widget state.

gtk.Style Signal Prototypes

gobject.GObject Signal Prototypes

"realize def callback(style, user_param1, ...)
"unrealize def callback(style, user_param1, ...)

Description

A gtk.Style object encapsulates the information that provides the look and feel for a widget. Each gtk.Widget has an associated gtk.Style object that is used when rendering that widget. Usually the gtk.Style for a widget is the same as the default style that is set by GTK and modified the theme engine. A gtk.Style holds information for the five possible widget states though not every widget supports all five states:

gtk.STATE_NORMALThe state of a sensitive widget that is not active and does not have the focus
gtk.STATE_ACTIVEThe state of a sensitive widget when it is active e.g. a button that is pressed but not yet released
gtk.STATE_PRELIGHTThe state of a sensitive widget that has the focus e.g. a button that has the mouse pointer over it.
gtk.STATE_SELECTEDThe state of a widget that is selected e.g. selected text in a gtk.Entry widget
gtk.STATE_INSENSITIVEThe state of a widget that is insensitive and will not respond to any events e.g. cannot be activated, selected or prelit.

A gtk.Style contains the read-only attributes described in the above section.

Usually applications should not need to use or modify the gtk.Style of their widgets.

Constructor

    gtk.Style()
Returns :a new gtk.Style object

Creates a new gtk.Style object.

Methods

gtk.Style.copy

    def copy()
Returns :a copy of the gtk.Style object

The copy() method returns a copy of the style object.

gtk.Style.attach

    def attach(window)
window :a gtk.Window.
Returns :a gtk.Style object

The attach() method adapts a style to the specified window. This process allocates the colors and creates the graphics contexts for the style specializing them to a particular visual and colormap. A new gtk.Style may be created if the style has already been adapted to a window with a different style and colormap.

gtk.Style.detach

    def detach()

The detach() method detaches the style and frees its resources if it is no longer attached.

gtk.Style.set_background

    def set_background(window, state_type)
window :a gtk.gdk.Window
state_type :a widget state

The set_background() method sets the background of window to the background color or pixmap of the style for the widget state specified by state_type.

gtk.Style.apply_default_background

    def apply_default_background(window, set_bg, state_type, area, x, y, width, height)
window :a gtk.gdk.Window
set_bg :if TRUE use the bg_pixmap for the widget state
state_type :the widget state
area :the clipping area
x :the x location
y :the y location
width :the width
height :the height

The apply_default_background() method sets the background of the specified window in the area specified by x, y, width and height. The background color is derived from the bg_gc of the style with the state specified by state_type. If area is not None it specifies a clipping area for the application of the background.

gtk.Style.lookup_icon_set

    def lookup_icon_set(stock_id)
stock_id :a stock ID
Returns :a gtk.IconSet

The lookup_icon_set() method looks in the gtk.IconFactory list associated with the style and the default icon factory for the stock icon specified by stock_id. If the stock icon iconset is found it is returned.

gtk.Style.render_icon

    def render_icon(source, direction, state, size, widget=None, detail=None)
source :the gtk.IconSource specifying the icon to render
direction :a text direction
state :a widget state
size :the size to render the icon at. A size of -1 means render at the size of the source and don't scale.
widget :a widget
detail :a style detail
Returns :a gtk.gdk.Pixbuf

The render_icon() method renders the icon specified by source at the specified size for the specified widget state according to the given parameters and returns the result in a gtk.gdk.Pixbuf.

gtk.Style.paint_hline

    def paint_hline(window, state_type, area, widget, detail, x1, x2, y)
window :a gtk.gdk.Window
state_type :a widget state
area :the rectangle that clips the output
widget :a widget
detail :a detail string
x1 :the starting x coordinate
x2 :the ending x coordinate
y :the y coordinate

The paint_hline() method draws a horizontal line from (x1, y) to (x2, y) in window using the specified state_type of the style. If area is not None the line is clipped by the rectangle specified by area.

gtk.Style.paint_vline

    def paint_vline(window, state_type, area, widget, detail, y1, y2, x)
window :a gtk.gdk.Window
state_type :a widget state
area :the rectangle to which the output is clipped
widget :a widget
detail :a detail string
y1 :the starting y coordinate
y2 :the ending y coordinate
x :the x coordinate

The paint_vline() method draws a vertical line from (x, y1) to (x, y2) in window using the specified state_type of the style. If area is not None the line is clipped by the rectangle specified by area.

gtk.Style.paint_shadow

    def paint_shadow(window, state_type, shadow_type, area, widget, detail, x, y, width, height)
window :a gtk.gdk.Window*
state_type :a widget state
shadow_type :a type of shadow - one of: gtk.SHADOW_NONE, gtk.SHADOW_IN, gtk.SHADOW_OUT, gtk.SHADOW_ETCHED_IN, gtk.SHADOW_ETCHED_OUT
area :the rectangle to which the output is clipped
widget :a widget
detail :a detail string
x :the x location
y :the y location
width :the width
height :the height

The paint_shadow() method draws a shadow of the specified shadow_type on the specified window with the size specified by x, y, width and height. If area is not None the shadow is clipped to the rectangle' area. state_type specifies the style state to use for drawing.

gtk.Style.paint_polygon

    def paint_polygon(window, state_type, shadow_type, area, widget, detail, points, fill)
window :a gtk.gdk.Window
state_type :a widget state
shadow_type :a shadow type - one of: gtk.SHADOW_NONE, gtk.SHADOW_IN, gtk.SHADOW_OUT, gtk.SHADOW_ETCHED_IN, gtk.SHADOW_ETCHED_OUT
area :a clipping rectangle
widget :a widget
detail :a detail string
points :a list or tuple containing point (x, y) tuples
fill :if TRUE the polygon should be filled

The paint_polygon() method draws a polygon on the specified window with the shadow type specified by shadow_type connecting the points specified by points. If area is not None it specifies a clipping rectangle. The style state specified by state_type determines the graphics context to use while drawing.

gtk.Style.paint_arrow

    def paint_arrow(window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height)
window :a gtk.gdk.Window
state_type :the widget state
shadow_type :a shadow type - one of: gtk.SHADOW_NONE, gtk.SHADOW_IN, gtk.SHADOW_OUT, gtk.SHADOW_ETCHED_IN, gtk.SHADOW_ETCHED_OUT
area :a clipping rectangle
widget :a widget
detail :a detail string
arrow_type :an arrow type - one of: gtk.ARROW_UP, gtk.ARROW_DOWN, gtk.ARROW_LEFT, gtk.ARROW_RIGHT
fill :if TRUE the arrow should be filled
x :the x location
y :the y location
width :the width
height :the height

The paint_arrow() method draws an arrow of the type specified by arrow_type on the specified window with the shadow type specified by shadow_type with the location and size specified by x, y, width and height. If area is not None it specifies a clipping rectangle. The widget state specified by state_type determines the graphics context to use while drawing.

gtk.Style.paint_diamond

    def paint_diamond(window, state_type, shadow_type, area, widget, detail, x, y, width, height)
window :a gtk.gdk.Window
state_type :a widget state
shadow_type :a shadow type - one of: gtk.SHADOW_NONE, gtk.SHADOW_IN, gtk.SHADOW_OUT, gtk.SHADOW_ETCHED_IN, gtk.SHADOW_ETCHED_OUT
area :a clipping rectangle
widget :a widget
detail :a detail string
x :the x location
y :the y location
width :the width
height :the height

The paint_diamond() method draws a diamond on the specified window with the shadow type specified by shadow_type and the location and size specified by x, y, width and height. If area is not None it specifies a clipping rectangle. The widget state specified by state_type determines the graphics context to use while drawing.

gtk.Style.paint_box

    def paint_box(window, state_type, shadow_type, area, widget, detail, x, y, width, height)
window :a gtk.gdk.Window
state_type :a widget state
shadow_type :a shadow type - one of: gtk.SHADOW_NONE, gtk.SHADOW_IN, gtk.SHADOW_OUT, gtk.SHADOW_ETCHED_IN, gtk.SHADOW_ETCHED_OUT
area :a clipping rectangle
widget :a widget
detail :a detail string
x :the x location
y :the y location
width :the width
height :the height

The paint_box() method draws a box on the specified window with the shadow type specified by shadow_type and the location and size specified by x, y, width and height. If area is not None it specifies a clipping rectangle. The widget state specified by state_type determines the graphics context to use while drawing.

gtk.Style.paint_flat_box

    def paint_flat_box(window, state_type, shadow_type, area, widget, detail, x, y, width, height)
window :a gtk.gdk.Window
state_type :a widget state
shadow_type :a shadow type - one of: gtk.SHADOW_NONE, gtk.SHADOW_IN, gtk.SHADOW_OUT, gtk.SHADOW_ETCHED_IN, gtk.SHADOW_ETCHED_OUT
area :a clipping rectangle
widget :a widget
detail :a detail string
x :the x location
y :the y location
width :the width
height :the height

The paint_flat_box() method draws a flat box (no shadow) on the specified window with the location and size specified by x, y, width and height. If area is not None it specifies a clipping rectangle. The style state specified by state_type determines the graphics context to use while drawing.

gtk.Style.paint_check

    def paint_check(window, state_type, shadow_type, area, widget, detail, x, y, width, height)
window :a gtk.gdk.Window
state_type :a widget state
shadow_type :a shadow type - one of: gtk.SHADOW_NONE, gtk.SHADOW_IN, gtk.SHADOW_OUT, gtk.SHADOW_ETCHED_IN, gtk.SHADOW_ETCHED_OUT
area :a clipping rectangle
widget :a widget
detail :a detail string
x :the x location
y :the y location
width :the width
height :the height

The paint_check() method draws a check on the specified window with the shadow type specified by shadow_type and the location and size specified by x, y, width and height. If area is not None it specifies a clipping rectangle. The widget state specified by state_type determines the graphics context to use while drawing.

gtk.Style.paint_option

    def paint_option(window, state_type, shadow_type, area, widget, detail, x, y, width, height)
window :a gtk.gdk.Window
state_type :a widget state
shadow_type :a shadow type - one of: gtk.SHADOW_NONE, gtk.SHADOW_IN, gtk.SHADOW_OUT, gtk.SHADOW_ETCHED_IN, gtk.SHADOW_ETCHED_OUT
area :a clipping rectangle
widget :a widget
detail :a detail string
x :the x location
y :the y location
width :the width
height :the height

The paint_option() method draws an option menu item on the specified window with the shadow type specified by shadow_type and the location and size specified by x, y, width and height. If area is not None it specifies a clipping rectangle. The widget state specified by state_type determines the graphics context to use while drawing.

gtk.Style.paint_tab

    def paint_tab(window, state_type, shadow_type, area, widget, detail, x, y, width, height)
window :a gtk.gdk.Window
state_type :a widget state
shadow_type :a shadow type - one of: gtk.SHADOW_NONE, gtk.SHADOW_IN, gtk.SHADOW_OUT, gtk.SHADOW_ETCHED_IN, gtk.SHADOW_ETCHED_OUT
area :a clipping rectangle
widget :a widget
detail :a detail string
x :the x location
y :the y location
width :the width
height :the height

The paint_tab() method draws a tab on the specified window with the shadow type specified by shadow_type and the location and size specified by x, y, width and height. If area is not None it specifies a clipping rectangle. The widget state specified by state_type determines the graphics context to use while drawing.

gtk.Style.paint_shadow_gap

    def paint_shadow_gap(window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width)
window :a gtk.gdk.Window
state_type :a widget state
shadow_type :a shadow type - one of: gtk.SHADOW_NONE, gtk.SHADOW_IN, gtk.SHADOW_OUT, gtk.SHADOW_ETCHED_IN, gtk.SHADOW_ETCHED_OUT
area :a clipping rectangle
widget :a widget
detail :a detail string
x :the x location
y :the y location
width :the width
height :the height
gap_side :a position - one of: gtk.POS_LEFT, gtk.POS_RIGHT, gtk.POS_TOP, gtk.POS_BOTTOM
gap_x :the x position of the gap
gap_width :the gap width

The paint_shadow_gap() method draws a shadow with a gap on the specified window with the shadow type specified by shadow_type and the location and size specified by x, y, width and height. The gap position and width is specified by gap_side, gap_x and gap_width. If area is not None it specifies a clipping rectangle. The widget state specified by state_type determines the graphics context to use while drawing.

gtk.Style.paint_box_gap

    def paint_box_gap(window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width)
window :a gtk.gdk.Window
state_type :a widget state
shadow_type :a shadow type - one of: gtk.SHADOW_NONE, gtk.SHADOW_IN, gtk.SHADOW_OUT, gtk.SHADOW_ETCHED_IN, gtk.SHADOW_ETCHED_OUT
area :a clipping rectangle
widget :a widget
detail :a detail string
x :the x location
y :the y location
width :the width
height :the height
gap_side :a position - one of: gtk.POS_LEFT, gtk.POS_RIGHT, gtk.POS_TOP, gtk.POS_BOTTOM
gap_x :the x position of the gap
gap_width :the gap width

The paint_box_gap() method draws a box with a gap on the specified window with the shadow type specified by shadow_type and the location and size specified by x, y, width and height. The gap position and width is specified by gap_side, gap_x and gap_width. If area is not None it specifies a clipping rectangle. The widget state specified by state_type determines the graphics context to use while drawing.

gtk.Style.paint_extension

    def paint_extension(window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side)
window :a gtk.gdk.Window
state_type :a widget state
shadow_type :a shadow type - one of: gtk.SHADOW_NONE, gtk.SHADOW_IN, gtk.SHADOW_OUT, gtk.SHADOW_ETCHED_IN, gtk.SHADOW_ETCHED_OUT
area :a clipping rectangle
widget :a widget
detail :a detail string
x :the x location
y :the y location
width :the width
height :the height
gap_side :a position - one of: gtk.POS_LEFT, gtk.POS_RIGHT, gtk.POS_TOP, gtk.POS_BOTTOM

The paint_extension() method draws an extension on the specified window with the shadow type specified by shadow_type and the location and size specified by x, y, width and height. The extension position is specified by gap_side. If area is not None it specifies a clipping rectangle. The widget state specified by state_type determines the graphics context to use while drawing.

gtk.Style.paint_focus

    def paint_focus(window, state_type, area, widget, detail, x, y, width, height)
window :a gtk.gdk.Window
state_type :a widget state
area :a clipping rectangle
widget :a widget
detail :a detail string
x :the x location
y :the y location
width :the width
height :the height

The paint_focus() method draws a focus indicator on the specified window with the location and size specified by x, y, width and height. If area is not None it specifies a clipping rectangle. The widget state specified by state_type determines the graphics context to use while drawing.

gtk.Style.paint_slider

    def paint_slider(window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation)
window :a gtk.gdk.Window
state_type :a widget state
shadow_type :a shadow type - one of: gtk.SHADOW_NONE, gtk.SHADOW_IN, gtk.SHADOW_OUT, gtk.SHADOW_ETCHED_IN, gtk.SHADOW_ETCHED_OUT
area :a clipping rectangle
widget :a widget
detail :a detail string
x :the x location
y :the y location
width :the width
height :the height
orientation :a position - one of: gtk.ORIENTATION_HORIZONTAL or gtk.ORIENTATION_VERTICAL

The paint_slider() method draws a slider with the specified orientation on the specified window with the shadow type specified by shadow_type and the location and size specified by x, y, width and height. If area is not None it specifies a clipping rectangle. The widget state specified by state_type determines the graphics context to use while drawing.

gtk.Style.paint_handle

    def paint_handle(window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation)
window :a gtk.gdk.Window
state_type :a widget state
shadow_type :a shadow type - one of: gtk.SHADOW_NONE, gtk.SHADOW_IN, gtk.SHADOW_OUT, gtk.SHADOW_ETCHED_IN, gtk.SHADOW_ETCHED_OUT
area :a clipping rectangle
widget :a widget
detail :a detail string
x :the x location
y :the y location
width :the width
height :the height
orientation :a position - one of: gtk.ORIENTATION_HORIZONTAL or gtk.ORIENTATION_VERTICAL

The paint_handle() method draws a handle with the specified orientation on the specified window with the shadow type specified by shadow_type and the location and size specified by x, y, width and height. If area is not None it specifies a clipping rectangle. The widget state specified by state_type determines the graphics context to use while drawing.

gtk.Style.paint_expander

    def paint_expander(window, state_type, area, widget, detail, x, y, expander_style)
window :a gtk.gdk.Window
state_type :a widget state
area :a clipping rectangle
widget :a widget
detail :a detail string
x :the x location
y :the y location
expander_style :an expander style - one of: gtk.EXPANDER_COLLAPSED, gtk.EXPANDER_SEMI_COLLAPSED, gtk.EXPANDER_SEMI_EXPANDED or gtk.EXPANDER_EXPANDED

The paint_expander() method draws an expander with the specified expander_style on the specified window at the location specified by x, y. If area is not None it specifies a clipping rectangle. The widget state specified by state_type determines the graphics context to use while drawing.

gtk.Style.paint_layout

    def paint_layout(window, state_type, use_text, area, widget, detail, x, y, layout)
window :a gtk.gdk.Window
state_type :a widget state
use_text :if TRUE use the text graphics context for drawing
area :a clipping rectangle
widget :a widget
detail :a detail string
x :the x location
y :the y location
layout :a Pango.Layout object containing the text to display

The paint_layout() method draws the text in a pango.Layout specified by layout on the specified window at the location specified by x and y. If text is TRUE use the text graphics context of the style for drawing, otherwise use the fg graphics context. If area is not None it specifies a clipping rectangle. The widget state specified by state_type determines the graphics context to use while drawing.

gtk.Style.paint_resize_grip

    def paint_resize_grip(window, state_type, area, widget, detail, edge, x, y, width, height)
window :a gtk.gdk.Window
state_type :a widget state
area :a clipping rectangle
widget :a widget
detail :a detail string
edge :the edge in which to draw the resize grip, currently only gtk.WINDOW_EDGE_SOUTH_EAST is implemented
x :the x location
y :the y location
width :the width
height :the height

The paint_resize_grip() method draws a resize grip at the specified edge on the specified window with the location and size specified by x, y, width and height. If area is not None it specifies a clipping rectangle. The widget state specified by state_type determines the graphics context to use while drawing. Currently the grip can only be drawn at the gtk.WINDOW_EDGE_SOUTH_EAST (lower right) edge.

Signals

The "realize" gtk.Style Signal

    def callback(style, user_param1, ...)
style :the object which received the signal.
user_param1 :the first user parameter (if any) specified with the connect() method
... :additional user parameters (if any)

Note

This signal is available in GTK+ 2.4 and above.

Emitted when the style has been initialized for a particular colormap and depth. Connecting to this signal is probably seldom useful since most of the time applications and widgets only deal with styles that have been already realized.

The "unrealize" gtk.Style Signal

    def callback(style, user_param1, ...)
style :the object which received the signal.
user_param1 :the first user parameter (if any) specified with the connect() method
... :additional user parameters (if any)

Note

This signal is available in GTK+ 2.4 and above.

Emitted when the aspects of the style specific to a particular colormap and depth are being cleaned up. A connection to this signal can be useful if a widget wants to cache objects like a gtk.gdk.GC as object data on gtk.Style. This signal provides a convenient place to free such cached objects.