Also set PATH in the GraphicsContext sample for Cairo

This commit is contained in:
Robin Dunn
2016-08-17 14:49:37 -07:00
parent 35731aa913
commit 17b5d65413

View File

@@ -3,6 +3,7 @@
import wx import wx
g = wx g = wx
import os
import colorsys import colorsys
from math import cos, sin, radians from math import cos, sin, radians
@@ -68,13 +69,22 @@ class TestPanel(wx.Panel):
def MakeGC(self, dc): def MakeGC(self, dc):
try: try:
if False: if False:
# If you want to force the use of Cairo instead of the # If you want to force the use of Cairo instead of the native
# native GraphicsContext backend then create the # GraphicsContext backend then create the context like this.
# context like this. It works on Windows so far, (on # It works on Windows so far, (on wxGTK the Cairo context is
# wxGTK the Cairo context is already being used as the # already being used as the native default.)
# native default.) #
# On Windows we also need to ensure that the cairo DLLs are
# found on the PATH, so let's add the wx package dir to the
# PATH here. In a real application you will probably want to
# be smarter about this.
wxdir = os.path.dirname(wx.__file__) + os.pathsep
if not wxdir in os.environ.get('PATH', ""):
os.environ['PATH'] = wxdir + os.environ.get('PATH', "")
gcr = wx.GraphicsRenderer.GetCairoRenderer gcr = wx.GraphicsRenderer.GetCairoRenderer
gc = gcr() and gcr().CreateContext(dc) gc = gcr() and gcr().CreateContext(dc)
if gc is None: if gc is None:
wx.MessageBox("Unable to create Cairo Context this way.", "Oops") wx.MessageBox("Unable to create Cairo Context this way.", "Oops")
gc = g.GraphicsContext.Create(dc) gc = g.GraphicsContext.Create(dc)