phoenix_title wx.GraphicsRenderer

A wx.GraphicsRenderer is the instance corresponding to the rendering engine used.

There may be multiple instances on a system, if there are different rendering engines present, but there is always only one instance per engine. This instance is pointed back to by all objects created by it ( wx.GraphicsContext, wx.GraphicsPath etc.) and can be retrieved through their wx.GraphicsObject.GetRenderer method. Therefore you can create an additional instance of a path etc. by calling wx.GraphicsObject.GetRenderer and then using the appropriate CreateXXX() function of that renderer.

path = wx.GraphicsPath() # from somewhere
brush = path.GetRenderer().CreateBrush(wx.BLACK_BRUSH)

class_hierarchy Class Hierarchy

Inheritance diagram for class GraphicsRenderer:

method_summary Methods Summary

CreateBitmap

Creates wx.GraphicsBitmap from an existing wx.Bitmap.

CreateBitmapFromImage

Creates wx.GraphicsBitmap from an existing wx.Image.

CreateBitmapFromNativeBitmap

Creates wx.GraphicsBitmap from a native bitmap handle.

CreateBrush

Creates a native brush from a wx.Brush.

CreateContext

Creates a wx.GraphicsContext from a wx.Window.

CreateContextFromImage

Creates a wx.GraphicsContext associated with a wx.Image.

CreateContextFromNativeContext

Creates a wx.GraphicsContext from a native context.

CreateContextFromNativeWindow

Creates a wx.GraphicsContext from a native window.

CreateContextFromUnknownDC

Creates a wx.GraphicsContext from a DC of unknown specific type.

CreateFont

Creates a native graphics font from a wx.Font and a text colour.

CreateFontAtDPI

Creates a native graphics font from a wx.Font and a text colour.

CreateImageFromBitmap

Creates a wx.Image from a wx.GraphicsBitmap.

CreateLinearGradientBrush

Creates a native brush with a linear gradient.

CreateMatrix

Creates a native affine transformation matrix from the passed in values.

CreateMeasuringContext

Creates a wx.GraphicsContext that can be used for measuring texts only.

CreatePath

Creates a native graphics path which is initially empty.

CreatePen

Creates a native pen from its description.

CreateRadialGradientBrush

Creates a native brush with a radial gradient.

CreateSubBitmap

Extracts a sub-bitmap from an existing bitmap.

GetCairoRenderer

Returns Cairo renderer.

GetDefaultRenderer

Returns the default renderer on this platform.

GetDirect2DRenderer

Returns Direct2D renderer (MSW and Python3 only).

GetGDIPlusRenderer

Returns GDI+ renderer (MSW only).

GetName

Returns the name of the technology used by the renderer.

GetType

Returns the name of the GraphicsRenderer class.

GetVersion

Returns the version major, minor and micro/build of the technology used by the renderer.


property_summary Properties Summary

Name

See GetName

Type

See GetType


api Class API

class wx.GraphicsRenderer(Object)

A GraphicsRenderer is the instance corresponding to the rendering engine used.


Methods

CreateBitmap(self, bitmap)

Creates wx.GraphicsBitmap from an existing wx.Bitmap.

Returns an invalid NullGraphicsBitmap on failure.

Parameters

bitmap (wx.Bitmap) –

Return type

wx.GraphicsBitmap



CreateBitmapFromImage(self, image)

Creates wx.GraphicsBitmap from an existing wx.Image.

This method is more efficient than converting wx.Image to wx.Bitmap first and then calling CreateBitmap but otherwise has the same effect.

Returns an invalid NullGraphicsBitmap on failure.

Parameters

image (wx.Image) –

Return type

wx.GraphicsBitmap

New in version 2.9.3.



CreateBitmapFromNativeBitmap(self, bitmap)

Creates wx.GraphicsBitmap from a native bitmap handle.

bitmap meaning is platform-dependent. Currently it’s a GDI+ Bitmap pointer under MSW, CGImage pointer under macOS or a cairo_surface_t pointer when using Cairo under any platform.

Notice that this method takes ownership of bitmap, i.e. it will be destroyed when the returned wx.GraphicsBitmap is.

Parameters

bitmap

Return type

wx.GraphicsBitmap



CreateBrush(self, brush)

Creates a native brush from a wx.Brush.

Parameters

brush (wx.Brush) –

Return type

wx.GraphicsBrush



CreateContext(self, *args, **kw)

overload Overloaded Implementations:



CreateContext (self, window)

Creates a wx.GraphicsContext from a wx.Window.

Parameters

window (wx.Window) –

Return type

wx.GraphicsContext



CreateContext (self, windowDC)

Creates a wx.GraphicsContext from a wx.WindowDC.

Parameters

windowDC (wx.WindowDC) –

Return type

wx.GraphicsContext



CreateContext (self, memoryDC)

Creates a wx.GraphicsContext from a wx.MemoryDC.

Parameters

memoryDC (wx.MemoryDC) –

Return type

wx.GraphicsContext



CreateContext (self, printerDC)

Creates a wx.GraphicsContext from a wx.PrinterDC.

Parameters

printerDC (wx.PrinterDC) –

Return type

wx.GraphicsContext

Note

Not implemented for Direct2D renderer (on MSW).





CreateContextFromImage(self, image)

Creates a wx.GraphicsContext associated with a wx.Image.

This function is used by Context.CreateFromImage() and is not normally called directly.

Parameters

image (wx.Image) –

Return type

wx.GraphicsContext

New in version 2.9.3.



CreateContextFromNativeContext(self, context)

Creates a wx.GraphicsContext from a native context.

This native context must be a CGContextRef for Core Graphics, a Graphics pointer for GDIPlus, an ID2D1RenderTarget pointer for Direct2D, a cairo_t pointer or HDC for Cairo on MSW, or a cairo_t pointer for Cairo on any other platform.

Parameters

context

Return type

wx.GraphicsContext



CreateContextFromNativeWindow(self, window)

Creates a wx.GraphicsContext from a native window.

Parameters

window

Return type

wx.GraphicsContext



CreateContextFromUnknownDC(self, dc)

Creates a wx.GraphicsContext from a DC of unknown specific type.

Creates a wx.GraphicsContext if dc is a supported type (i.e. has a corresponding CreateContext method, e.g. wx.WindowDC or wx.MemoryDC). Returns None if the DC is unsupported.

This method is only useful as a helper in generic code that operates with wx.DC and doesn’t known its exact type. Use the appropriate CreateContext overload instead if you know that the DC is e.g. wx.WindowDC.

Parameters

dc (wx.DC) –

Return type

wx.GraphicsContext

New in version 4.1/wxWidgets-3.1.3.



CreateFont(self, *args, **kw)

overload Overloaded Implementations:



CreateFont (self, font, col=BLACK)

Creates a native graphics font from a wx.Font and a text colour.

Parameters
Return type

wx.GraphicsFont



CreateFont (self, sizeInPixels, facename, flags=FONTFLAG_DEFAULT, col=BLACK)

Creates a graphics font with the given characteristics.

If possible, the CreateFont overload taking wx.Font should be used instead. The main advantage of this overload is that it can be used without X server connection under Unix when using Cairo.

Parameters
  • sizeInPixels (float) – Height of the font in user space units, i.e. normally pixels. Notice that this is different from the overload taking wx.Font as wx.Font size is specified in points.

  • facename (string) – The name of the font. The same font name might not be available under all platforms so the font name can also be empty to use the default platform font.

  • flags (int) – Combination of FontFlag enum elements. Currently only FONTFLAG_ITALIC and FONTFLAG_BOLD are supported. By default the normal font version is used.

  • col (wx.Colour) – The font colour, black by default.

Return type

wx.GraphicsFont

New in version 2.9.3.





CreateFontAtDPI(self, font, dpi, col=BLACK)

Creates a native graphics font from a wx.Font and a text colour.

The specified DPI is used to convert the (fractional) wx.Font point-size to a fractional pixel-size.

Parameters
Return type

wx.GraphicsFont

New in version 4.1/wxWidgets-3.1.3.



CreateImageFromBitmap(self, bmp)

Creates a wx.Image from a wx.GraphicsBitmap.

This method is used by the more convenient wx.GraphicsBitmap.ConvertToImage .

Parameters

bmp (wx.GraphicsBitmap) –

Return type

wx.Image



CreateLinearGradientBrush(self, x1, y1, x2, y2, stops, matrix=NullGraphicsMatrix)

Creates a native brush with a linear gradient.

Stops support is new since wxWidgets 2.9.1, previously only the start and end colours could be specified.

The ability to apply a transformation matrix to the gradient was added in 3.1.3

Parameters
Return type

wx.GraphicsBrush



CreateMatrix(self, a=1.0, b=0.0, c=0.0, d=1.0, tx=0.0, ty=0.0)

Creates a native affine transformation matrix from the passed in values.

The defaults result in an identity matrix.

Parameters
  • a (wx.Double) –

  • b (wx.Double) –

  • c (wx.Double) –

  • d (wx.Double) –

  • tx (wx.Double) –

  • ty (wx.Double) –

Return type

wx.GraphicsMatrix



CreateMeasuringContext(self)

Creates a wx.GraphicsContext that can be used for measuring texts only.

No drawing commands are allowed.

Return type

wx.GraphicsContext



CreatePath(self)

Creates a native graphics path which is initially empty.

Return type

wx.GraphicsPath



CreatePen(self, info)

Creates a native pen from its description.

Parameters

info (wx.GraphicsPenInfo) –

Return type

wx.GraphicsPen

New in version 4.1/wxWidgets-3.1.1.



CreateRadialGradientBrush(self, startX, startY, endX, endY, radius, stops, matrix=NullGraphicsMatrix)

Creates a native brush with a radial gradient.

Stops support is new since wxWidgets 2.9.1, previously only the start and end colours could be specified.

The ability to apply a transformation matrix to the gradient was added in 3.1.3

Parameters
Return type

wx.GraphicsBrush



CreateSubBitmap(self, bitmap, x, y, w, h)

Extracts a sub-bitmap from an existing bitmap.

Parameters
  • bitmap (wx.GraphicsBitmap) –

  • x (wx.Double) –

  • y (wx.Double) –

  • w (wx.Double) –

  • h (wx.Double) –

Return type

wx.GraphicsBitmap



static GetCairoRenderer()

Returns Cairo renderer.

Return type

wx.GraphicsRenderer



static GetDefaultRenderer()

Returns the default renderer on this platform.

On macOS this is the Core Graphics (a.k.a. Quartz 2D) renderer, on MSW the GDIPlus renderer, and on GTK we currently default to the Cairo renderer.

Return type

wx.GraphicsRenderer



static GetDirect2DRenderer()

Returns Direct2D renderer (MSW and Python3 only).

Return type

wx.GraphicsRenderer



static GetGDIPlusRenderer()

Returns GDI+ renderer (MSW only).

Return type

wx.GraphicsRenderer



GetName(self)

Returns the name of the technology used by the renderer.

Currently this function returns “gdiplus” for Windows GDI+ implementation, “direct2d” for Windows Direct2D implementation, “cairo” for Cairo implementation and “cg” for macOS CoreGraphics implementation.

Return type

string

New in version 4.1/wxWidgets-3.1.0.

Note

The string returned by this method is not user-readable and is expected to be used internally by the program only.



GetType(self)

Returns the name of the GraphicsRenderer class.



GetVersion(self, major, minor=None, micro=None)

Returns the version major, minor and micro/build of the technology used by the renderer.

Currently this function returns the OS major and minor versions in the parameters with the matching names and sets micro to 0 for the GDI+ and CoreGraphics engines which are considered to be parts of their respective OS.

For Cairo, this is the major,minor,micro version of the Cairo library which is returned.

Parameters
  • major (int) –

  • minor (int) –

  • micro (int) –


Properties

Name

See GetName



Type

See GetType