I’m new to wxPython, and am building an app for deployment on both Mac OS X and Windows. I have got most of it all working, but am having a problem with the Mac OS X build.
I have an HtmlListBox with a custom background colour, which is working fine across platforms. However, whilst on Windows the text colour goes white when an item is selected (so the text is still readable), on OS X the text stays black and is thus difficult to read.
The Phoenix documentations for HtmlListBox (http://wxpython.org/Phoenix/docs/html/html.HtmlListBox.html) suggests thatI should be able to override GetSelectedTextColour() in order to correct this issue. However, whatever I try I cannot make this work and a dir(wx.HtmlListBox) suggests that that function is never there for HtmlListBox.
I had a dig about in the wxPython source. I noticed that in ‘wxPython/src/_vscroll.i’ that there is a comment at the top of the file:
// Base classes. I don’t expect that these will ever be used directly from
// Python, (especially being derived from) so I own’t worry about making their
// virutals overridable. They’re just defined here for their public methods.
Then further down (line 907 for me) in the same file I find a ‘TODO’ block about the GetSelectedTextColour() function, with a commented out line:
// virtual wxColour GetSelectedTextColour(const wxColour& colFg) const;
Unfortunately, I’m not much of a C programmer, and have never previously heard of SWIG so I have been unable to manage to build and patch swig 1.3.29 and get the --reswig flag for the build script working. It has been an intensely frustrating few hours, as I’d like to know whether the fix is as simple as uncommenting that line!
Questions:
-
Is GetSelectedTextColour() meant to be implemented? If so - am I doing something wrong when I just try adding it to my sub-class of HtmlListBox?
-
If I did work out SWIG - is commenting out that line really all there is to it?
Asides:
-
Should OS X not be changing the text colour by default anyway? In native widgets the text does invert (to white) for the same background colour.
-
I tried using HTML tags to alter the text colour on select, but it always just goes to black whatever (unselected cells I can colour as I want).
-
I can/have hacked around this problem by just patching the white text directly into the wxPython source as I’ll be packaging the app with py2app on OS X so can include my patched version with it. I just didn’t want to give up on getting the correct solution!
Many thanks in advance!