Commit bfe98b52 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

RF: Better default colours in elistbox, widgetlist and notebook

parent fbdc8a9e
......@@ -80,20 +80,29 @@ class EditableListBox(wx.Panel):
functionality. This implementation supports single selection only.
"""
_selectedFG = '#000000'
"""Default foreground colour for the currently selected item."""
_selectedFG = None
"""Default foreground colour for the currently selected item. Initialised
in :meth:`__init__` to a default based on the system appearance.
"""
_defaultFG = '#000000'
"""Default foreground colour for unselected items."""
_defaultFG = None
"""Default foreground colour for unselected items. Initialised
in :meth:`__init__` to a default based on the system appearance.
"""
_selectedBG = '#cdcdff'
"""Background colour for the currently selected item."""
_selectedBG = None
"""Background colour for the currently selected item. Initialised
in :meth:`__init__` to a default based on the system appearance.
"""
_defaultBG = '#FFFFFF'
"""Background colour for the unselected items."""
_defaultBG = None
"""Background colour for the unselected items. Initialised
in :meth:`__init__` to a default based on the system appearance.
"""
def __init__(
......@@ -128,6 +137,21 @@ class EditableListBox(wx.Panel):
wx.Panel.__init__(self, parent, style=wx.WANTS_CHARS)
defaultfg = wx.SystemSettings.GetColour(wx.SYS_COLOUR_LISTBOXTEXT)
defaultbg = wx.SystemSettings.GetColour(wx.SYS_COLOUR_LISTBOX)
selectfg = wx.SystemSettings.GetColour(
wx.SYS_COLOUR_LISTBOXHIGHLIGHTTEXT)
selectbg = wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT)
if EditableListBox._selectedFG is None:
EditableListBox._selectedFG = selectfg
if EditableListBox._selectedBG is None:
EditableListBox._selectedBG = selectbg
if EditableListBox._defaultFG is None:
EditableListBox._defaultFG = defaultfg
if EditableListBox._defaultBG is None:
EditableListBox._defaultBG = defaultbg
reverseOrder = style & ELB_REVERSE
addScrollbar = not (style & ELB_NO_SCROLL)
addSupport = not (style & ELB_NO_ADD)
......@@ -242,9 +266,6 @@ class EditableListBox(wx.Panel):
self.__scrollUp .Enable(False)
self.__scrollDown.Enable(False)
self.__scrollUp .SetBackgroundColour('#e0e0e0')
self.__scrollDown.SetBackgroundColour('#e0e0e0')
self.__scrollUp .Bind(wx.EVT_LEFT_UP, self.__onScrollButton)
self.__scrollDown.Bind(wx.EVT_LEFT_UP, self.__onScrollButton)
......@@ -1309,7 +1330,7 @@ class EditableListBox(wx.Panel):
(self.__selection != self.GetCount() - 1))
class _ListItem(object):
class _ListItem:
"""Internal class used to represent items in the list."""
def __init__(self,
......
......@@ -77,7 +77,7 @@ class Notebook(wx.Panel):
self.__textColour = None
self.__defaultColour = None
self.__disabledTextColour = None
self.__selectColour = '#ffffff'
self.__selectColour = None
self.__buttonPanel = wx.Panel(self)
self.__sizer = wx.BoxSizer(invbtnorient)
self.__buttonSizer = wx.BoxSizer(btnorient)
......@@ -113,6 +113,9 @@ class Notebook(wx.Panel):
self.__buttons = []
self.__selected = None
# initialise default values for colours
self.SetButtonColours()
@property
def pages(self):
......@@ -181,10 +184,15 @@ class Notebook(wx.Panel):
:arg selected: Selected background colour.
"""
text = kwargs.pop('text', None)
disabledText = kwargs.pop('disabledText', None)
default = kwargs.pop('default', None)
selected = kwargs.pop('selected', '#ffffff')
defaultbg = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)
selectbg = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNHIGHLIGHT)
defaultfg = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNTEXT)
selectfg = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNTEXT)
text = kwargs.pop('text', selectfg)
disabledText = kwargs.pop('disabledText', defaultfg)
default = kwargs.pop('default', defaultbg)
selected = kwargs.pop('selected', selectbg)
self.__textColour = text
self.__disabledTextColour = disabledText
......
......@@ -11,16 +11,10 @@ some text, oriented either horizontally or vertically.
import wx
import fsleyes_widgets as fw
if fw.wxFlavour() == fw.WX_PHOENIX: TextPanelBase = wx.Panel
else: TextPanelBase = wx.PyPanel
class TextPanel(TextPanelBase):
class TextPanel(wx.Panel):
"""A :class:`wx.PyPanel` which may be used to display a string of
text, oriented either horizotnally or vertically.
text, oriented either horizontally or vertically.
"""
def __init__(self, parent, text=None, orient=wx.HORIZONTAL, **kwargs):
......@@ -37,7 +31,7 @@ class TextPanel(TextPanelBase):
All other arguments are passed through to ``wx.Panel.__init__`` .
"""
TextPanelBase.__init__(self, parent, **kwargs)
super().__init__(parent, **kwargs)
self.Bind(wx.EVT_PAINT, self.Draw)
self.Bind(wx.EVT_SIZE, self.__onSize)
......
......@@ -15,7 +15,7 @@ import wx
import wx.lib.newevent as wxevent
import wx.lib.scrolledpanel as scrolledpanel
from . import togglepanel
import fsleyes_widgets.togglepanel as togglepanel
class WidgetList(scrolledpanel.ScrolledPanel):
......@@ -50,16 +50,22 @@ class WidgetList(scrolledpanel.ScrolledPanel):
"""
_defaultOddColour = '#eaeaea'
"""Background colour for widgets on odd rows. """
_defaultOddColour = None
"""Background colour for widgets on odd rows.
Iniitalised in :meth:`__init__`.
"""
_defaultEvenColour = '#ffffff'
"""Background colour for widgets on even rows. """
_defaultEvenColour = None
"""Background colour for widgets on even rows.
Iniitalised in :meth:`__init__`.
"""
_defaultGroupColour = '#cdcdff'
"""Border and title background colour for widget groups. """
_defaultGroupColour = None
"""Border and title background colour for widget groups.
Iniitalised in :meth:`__init__`.
"""
def __init__(self, parent, style=0, minHeight=-1):
......@@ -69,6 +75,19 @@ class WidgetList(scrolledpanel.ScrolledPanel):
:arg style: Passed through to ``wx.ScrolledPanel.__init__``
:arg minHeight: Minimum height of each row
"""
odd = wx.SystemSettings.GetColour(wx.SYS_COLOUR_LISTBOX)
even = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW)\
.ChangeLightness(75)
group = odd
if WidgetList._defaultOddColour is None:
WidgetList._defaultOddColour = odd
if WidgetList._defaultEvenColour is None:
WidgetList._defaultEvenColour = even
if WidgetList._defaultGroupColour is None:
WidgetList._defaultGroupColour = group
self.__minHeight = minHeight
self.__widgSizer = wx.BoxSizer(wx.VERTICAL)
self.__sizer = wx.BoxSizer(wx.VERTICAL)
......@@ -95,7 +114,6 @@ class WidgetList(scrolledpanel.ScrolledPanel):
scrolledpanel.ScrolledPanel.__init__(self, parent)
self.SetSizer(self.__sizer)
self.SetBackgroundColour((255, 255, 255))
self.SetupScrolling()
self.SetAutoLayout(1)
......@@ -524,7 +542,7 @@ class WidgetList(scrolledpanel.ScrolledPanel):
self.__refresh()
class _Widget(object):
class _Widget:
"""The ``_Widget`` class is used internally by the :class:`WidgetList`
to organise references to each widget in the list.
"""
......@@ -584,7 +602,7 @@ class _Widget(object):
self.widget.Destroy()
class _Group(object):
class _Group:
"""The ``_Group`` class is used internally by :class:`WidgetList`
instances to represent groups of widgets that are in the list.
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment