Predefined colours in wxPython

60 views
Skip to first unread message

Jérôme Laheurte

unread,
Apr 10, 2021, 10:20:03 AM4/10/21
to wxpytho...@googlegroups.com
I’m in the process of porting an application to python3/wx4 and just found why a bunch of my tests fail:

Python 3.8.5 (default, Jan 27 2021, 15:41:15)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> wx.RED
wx.Colour(-1, -1, -1, 255)
>>> wx.BLACK
wx.Colour(-1, -1, -1, 255)
>>> wx.BLUE
wx.Colour(-1, -1, -1, 255)
>>> wx.RED == None
True
>>> wx.RED == wx.BLACK
True
>>>

It seems like all predefined colours have the same « null colour » value ?

Ubuntu 20.04, wxPython 4.1.1 (installed through pip in a venv)

Best regards
Jérôme Laheurte

Tim Roberts

unread,
Apr 11, 2021, 1:30:37 AM4/11/21
to wxPython-users
This has pretty much always been true.  The constants don't get initialized until you instantiate a wx.App() object.  You don't even have to use it.

Jérôme Laheurte

unread,
Apr 11, 2021, 5:24:02 AM4/11/21
to wxpytho...@googlegroups.com


Le 11 avr. 2021 à 07:30, Tim Roberts <ti...@probo.com> a écrit :

This has pretty much always been true.  The constants don't get initialized until you instantiate a wx.App() object.  You don't even have to use it.

Aaaah I’m missing the wx.App :) Thanks.

Best regards
Jérôme Laheurte

Reply all
Reply to author
Forward
0 new messages