Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
App crash 0xC0000005 with wxVisualAttributes #1198
System: Windows 6.1.7601 x64
Description of the problem:
I know this is a trivial issue. But it is worth mentioning because the underlying issue could be more widespread.
When I get the ClassDefaultAttributes of a class if the returned wxVisualAttributes if not placed into a python variable when trying to print out say the bgCol property an application crash takes place.
here is the exit code
The script will cause the issue when running on python 2.7.15 and using wxPython 4.0.4. I have not tried this with any other versions of python. if you would like me to I can.
I am using Stackless Python and I do know that there is an issue with Stackless python and Cython. I do not know if the issue spreads over to swig as well. The problem with Stackless and Cython has been resolved and is in a new release of Stackless which I will also test to see if the problem occurs.
Again this is something that is really strange because everything works fine so long as I create a reference to the returned object before printing it.
NOTE: This script was run inside of the PyCharm IDE, and the IDE does manipulate sys.stdout. I will try this again without the IDE and report back.
sample code to try.
from __future__ import print_function import wx import platform print('System:', platform.system(), platform.version()) print('Python:', platform.python_version()) print('Python Compiler:', platform.python_compiler()) print('wxPython version:', wx.version()) print() print('You will see a python appcrash 0xC0000005 when running this script') visual_attributes = wx.Window.GetClassDefaultAttributes() print('wxVisualAttributes set into a python variable (visual_attributes) using wx.Window.GetClassDefaultAttributes()') print('visual_attributes:', visual_attributes) print('visual_attributes.colBg:', visual_attributes.colBg) print('not creating variable and printing directly from the call to wx.Window.GetClassDefaultAttributes()') print('wx.Window.GetClassDefaultAttributes():', wx.Window.GetClassDefaultAttributes()) print('wx.Window.GetClassDefaultAttributes().colBg:', wx.Window.GetClassDefaultAttributes().colBg)
output from script
referenced this issue
Apr 13, 2019
I would also like to know if there is a way to define the default class attributes?. In the world of GUI controls it seems to be a pretty popular thing to be able to "skin" the GUI. I have not seen anything that jumps right out as far as setting global colors/fonts/sizes. There is the ArtManager that is available for artwork and that works well. As far as fonts, colors and GUI element sizes like scroll bar widths and things of that nature I have not managed to locate a simple way to make the changes globally and I have not be able to locate a way to force all visible GUI items to be refreshed or redrawn. From what I have found is that I have to iterate over all of the children of the base application frame and set them specifically. Maybe I am missing something about how to go about doing this. That is the reason why i discovered the issue with the wx.VisualAttributes. Also are there any other properties that can get set to the wx.VisualAttributes instance that are not documented?. The documentation suggests that there is but does not specifically reference any additional properties.
I know this would be more of a support question. I thought since this does have to do with the wx.VisualAttributes object I might get away with asking here.
No, since wxWidgets is all about using the native widgets and having a true native LnF on all platforms as much as possible, then there really isn't support for things like skinning or custom theming. The themes, if any, are handled by the platform. So the wx.VisualAttributes are more-or-less read-only, there is no SetVisualAttributes or similar.
That said, there is a bit of attribute inheritance that has been there for a long time. For example if a font or color is set on a panel before creating child widgets, then those widgets may inherit and use that font or color. Unfortunately it's not entirely consistent, and is getting worse as the native platforms impose more control over the LnF. A decade or so ago it worked for most widgets on Windows or GTK, but now not so much.
OK so the easiest solution would be to subclass all of the wxWindow based classes override the init to Bind to EVT_WINDOW_DESTROY and place that instance into a container that holds active controls and if it gets destroyed it would be able to be removed from that container. and then override the existing classes with the subclassed ones.