Fix taking screenshots with wxPython on Linux and Python 2.7
Fixes
@@ -31,6 +31,7 @@ elif sys.platform == 'cli':
else:
try:
import wx
+ wx_app = wx.App(False) # Linux Python 2.7 must exist on global scope
except ImportError:
wx = None
try:
@@ -255,7 +256,6 @@ class ScreenshotTaker(object):
def __init__(self, module_name=None):
self._screenshot = self._get_screenshot_taker(module_name)
self.module = self._screenshot.__name__.split('_')[1]
- self._wx_app_reference = None
def __call__(self, path):
self._screenshot(path)
@@ -353,8 +353,7 @@ class ScreenshotTaker(object):
raise RuntimeError("Using 'scrot' failed.")
def _wx_screenshot(self, path):
- if not self._wx_app_reference:
- self._wx_app_reference = wx.App(False)
+ # depends on wx_app been created
context = wx.ScreenDC()
width, height = context.GetSize()
if wx.__version__ >= '4':
