Repository: kivy/kivy

Issue:
RstDoc inconsistent with other widgets in certain aspects.
I believe we could still have a `background_color` property that users could adjust like in other widgets like TextInput.

Currently you have to use `colors`(which is also missing documentation) 

Furthermore, the background color internally is limited to `rgb`colors only with no way for the user to use a transluscent background. Having to Edit the internal kv of the RstDoc is not good. 

Q: Is there a good reason for having the kv for RstDoc not moved to style.kv?
Update: 
   I see now that RstDocs visual representation is independent of the theme used and as such doesn't make sense to put its kv in style.kv



Discussion:
:+1:

On Fri, Jun 07, 2013 at 05:44:03AM -0700, qua-non wrote:

> I believe we could still have a `background_color` property that users could adjust like in other widgets like TextInput.
> 
> Currently you have to use `colors`(which is also missing documentation) 
> 
> Furthermore, the background color internally is limited to `rgb`colors only with no way for the user to use a transluscent background. Having to Edit the internal kv of the RstDoc is not good. 
> 
> Is there a good reason for having the kv for RstDoc not moved to style.kv?
> 
> ---
> 
> Reply to this email directly or view it on GitHub:
> https://github.com/kivy/kivy/issues/1266


Resolving patch:
diff --git a/kivy/uix/rst.py b/kivy/uix/rst.py
--- a/kivy/uix/rst.py
+++ b/kivy/uix/rst.py
@@ -60,8 +60,9 @@
 from kivy.clock import Clock
 from kivy.properties import ObjectProperty, NumericProperty, \
         DictProperty, ListProperty, StringProperty, \
-        BooleanProperty
+        BooleanProperty, AliasProperty
 from kivy.lang import Builder
+from kivy.utils import get_hex_from_color, get_color_from_hex
 from kivy.uix.widget import Widget
 from kivy.uix.scrollview import ScrollView
 from kivy.uix.gridlayout import GridLayout
@@ -123,7 +124,7 @@ def run(self):
     do_scroll_x: False
     canvas:
         Color:
-            rgb: parse_color(root.colors['background'])
+            rgba: parse_color(root.colors['background'])
         Rectangle:
             pos: self.pos
             size: self.size
@@ -410,12 +411,27 @@ class RstDocument(ScrollView):
     to False
     '''
 
+    def _get_bgc(self):
+        return get_color_from_hex(self.colors.background)
+
+    def _set_bgc(self, value):
+        self.colors.background = get_hex_from_color(value)[1:]
+
+    background_color = AliasProperty(_get_bgc, _set_bgc, bind=('colors',))
+    '''Indicates the background_color to be used for the RstDocument
+
+    .. versionadded:: 1.8.0
+
+    :data:`background_color` is a :class:`~kivy.properties.AliasProeprty`.
+    This is a alias for colors['background']
+    '''
+
     colors = DictProperty({
-        'background': 'e5e6e9',
-        'link': 'ce5c00',
-        'paragraph': '202020',
-        'title': '204a87',
-        'bullet': '000000'})
+        'background': 'e5e6e9ff',
+        'link': 'ce5c00ff',
+        'paragraph': '202020ff',
+        'title': '204a87ff',
+        'bullet': '000000ff'})
     '''Dictionary of all the colors used in the RST rendering.
 
     .. warning::


Test patch: