File: staticline.py

package info (click to toggle)
pythoncard 0.8.2-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 8,452 kB
  • sloc: python: 56,787; makefile: 56; sh: 22
file content (68 lines) | stat: -rw-r--r-- 2,017 bytes parent folder | download | duplicates (4)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

"""
__version__ = "$Revision: 1.13 $"
__date__ = "$Date: 2004/05/13 02:40:24 $"
"""

import wx
from PythonCard import event, widget


class StaticLineSpec(widget.WidgetSpec):
    def __init__(self):
        attributes = {
            'layout' : { 'presence' : 'optional', 'default' : 'horizontal', 'values' : [ 'horizontal', 'vertical' ]  },
            'size' : { 'presence' : 'optional', 'default' : [ 50, -1 ] },
        }
        widget.WidgetSpec.__init__( self, 'StaticLine', 'Widget', [], attributes )

class StaticLine(widget.Widget, wx.StaticLine):
    """
    A static line is just a line which may be used to separate
    a groups of controls. The line may be only vertical or horizontal.
    """

    _spec = StaticLineSpec()

    def __init__( self, aParent, aResource ) :
        wx.StaticLine.__init__(
            self,
            aParent, 
            widget.makeNewId(aResource.id), 
            aResource.position, 
            aResource.size,
            style = self.__getLayout( aResource.layout ) | 
                wx.NO_FULL_REPAINT_ON_RESIZE | wx.CLIP_SIBLINGS,
            name = aResource.name 
        )
        
        widget.Widget.__init__( self, aParent, aResource )

        # set attributes directly that can only be set at initialization
        self._layout = aResource.layout
        
        self._bindEvents(event.WIDGET_EVENTS)

    def __getLayout( self, aString  ) :
        if aString == 'horizontal' :
            return wx.LI_HORIZONTAL
        elif aString == 'vertical' :
            return wx.LI_VERTICAL
        else :
            raise 'invalid StaticLine.layout value: ', aString

    #def _setHelpText( self, aString ) :
    #    pass

    def _setLayout( self, aString ) :
        raise AttributeError, "layout attribute is read-only"

    def _getLayout( self ) :
        return self._layout

    layout = property(_getLayout, _setLayout)


import sys
from PythonCard import registry
registry.Registry.getInstance().register(sys.modules[__name__].StaticLine)