File: style.py

package info (click to toggle)
python-box2d 2.3.2~dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,596 kB
  • ctags: 5,116
  • sloc: python: 14,384; cpp: 13,393; makefile: 9
file content (31 lines) | stat: -rw-r--r-- 991 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
"""

from . import pguglobals

class Style:
    """The class used by widget for the widget.style
    
    This object is used mainly as a dictionary, accessed via widget.style.attr, 
    as opposed to widget.style['attr'].  It automatically grabs information 
    from the theme via value = theme.get(widget.cls,widget.pcls,attr)

    """
    def __init__(self, obj, dict):
        self.obj = obj
        for k,v in dict.items(): self.__dict__[k]=v

    def __getattr__(self, attr):
        value = pguglobals.app.theme.get(self.obj.cls, self.obj.pcls, attr)

        if attr in (
            'border_top','border_right','border_bottom','border_left',
            'padding_top','padding_right','padding_bottom','padding_left',
            'margin_top','margin_right','margin_bottom','margin_left',
            'align','valign','width','height',
            ): self.__dict__[attr] = value
        return value

    def __setattr__(self, attr, value):
        self.__dict__[attr] = value