changeset 6ed6142e134e in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset;node=6ed6142e134e
description:
Allow configuration of default colors for graph and calendar
issue9435
review300011002
diffstat:
CHANGELOG | 1 +
tryton/config.py | 2 ++
tryton/gui/window/view_form/view/calendar_gtk/calendar_.py | 10 ++++++++--
tryton/gui/window/view_form/view/graph_gtk/graph.py | 3 ++-
4 files changed, 13 insertions(+), 3 deletions(-)
diffs (76 lines):
diff -r a6638d750161 -r 6ed6142e134e CHANGELOG
--- a/CHANGELOG Thu Jul 09 00:21:48 2020 +0200
+++ b/CHANGELOG Thu Jul 09 00:34:01 2020 +0200
@@ -1,3 +1,4 @@
+* Allow configuration of default colors for graph and calendar
* Use existing context for get_preferences
* Add context to export URL
diff -r a6638d750161 -r 6ed6142e134e tryton/config.py
--- a/tryton/config.py Thu Jul 09 00:21:48 2020 +0200
+++ b/tryton/config.py Thu Jul 09 00:34:01 2020 +0200
@@ -57,6 +57,8 @@
'client.bus_timeout': 10 * 60,
'icon.colors': '#3465a4,#555753,#cc0000',
'tree.colors': '#777,#dff0d8,#fcf8e3,#f2dede',
+ 'calendar.colors': '#fff,#3465a4',
+ 'graph.color': '#3465a4',
'image.max_size': 10 ** 6,
'bug.url': 'https://bugs.tryton.org/',
'download.url': 'https://downloads-cdn.tryton.org/',
diff -r a6638d750161 -r 6ed6142e134e
tryton/gui/window/view_form/view/calendar_gtk/calendar_.py
--- a/tryton/gui/window/view_form/view/calendar_gtk/calendar_.py Thu Jul
09 00:21:48 2020 +0200
+++ b/tryton/gui/window/view_form/view/calendar_gtk/calendar_.py Thu Jul
09 00:34:01 2020 +0200
@@ -6,6 +6,9 @@
from .dates_period import DatesPeriod
from tryton.common import MODELACCESS
+from tryton.config import CONFIG
+
+_colors = CONFIG['calendar.colors'].split(',')
class Calendar_(goocalendar.Calendar):
@@ -14,6 +17,9 @@
def __init__(self, attrs, view, fields, event_store=None):
super(Calendar_, self).__init__(
event_store, attrs.get('mode', 'month'))
+ self.props.selected_border_color = _colors[1]
+ if hasattr(self.props, 'selected_text_color'):
+ self.props.selected_text_color = _colors[0]
self.attrs = attrs
self.view_calendar = view
self.fields = fields
@@ -69,10 +75,10 @@
return domain
def get_colors(self, record):
- text_color = None
+ text_color = _colors[0]
if self.attrs.get('color'):
text_color = record[self.attrs['color']].get(record)
- bg_color = 'lightblue'
+ bg_color = _colors[1]
if self.attrs.get('background_color'):
bg_color = record[self.attrs['background_color']].get(
record)
diff -r a6638d750161 -r 6ed6142e134e
tryton/gui/window/view_form/view/graph_gtk/graph.py
--- a/tryton/gui/window/view_form/view/graph_gtk/graph.py Thu Jul 09
00:21:48 2020 +0200
+++ b/tryton/gui/window/view_form/view/graph_gtk/graph.py Thu Jul 09
00:34:01 2020 +0200
@@ -14,6 +14,7 @@
import tryton.rpc as rpc
from tryton.action import Action
from tryton.common import hex2rgb, generateColorscheme, COLOR_SCHEMES
+from tryton.config import CONFIG
from tryton.gui.window import Window
from tryton.pyson import PYSONDecoder
@@ -460,7 +461,7 @@
def setColorScheme(self):
keys = self._getDatasKeys()
- color = self.attrs.get('color', 'blue')
+ color = self.attrs.get('color', CONFIG['graph.color'])
r, g, b = hex2rgb(COLOR_SCHEMES.get(color, color))
maxcolor = max(max(r, g), b)
self.colorScheme = generateColorscheme(color, keys,