src/reportlab/graphics/widgets/signsandsymbols.py
author robin <robin@reportlab.com>
Tue, 07 Mar 2017 10:00:34 +0000
changeset 4330 617ffa6bbdc8
parent 4252 fe660f227cac
child 4370 823a8c33ce43
permissions -rw-r--r--
changes for release 3.4.0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4330
617ffa6bbdc8 changes for release 3.4.0
robin <robin@reportlab.com>
parents: 4252
diff changeset
     1
#Copyright ReportLab Europe Ltd. 2000-2017
817
8c3a399effda License text changes
rgbecker
parents: 664
diff changeset
     2
#see license.txt for license details
2332
2a7ab4405e18 Remove $Header:, fix CopyRight & history
rgbecker
parents: 1683
diff changeset
     3
#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/graphics/widgets/signsandsymbols.py
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
     4
# signsandsymbols.py
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
     5
# A collection of new widgets
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
     6
# author: John Precedo (johnp@reportlab.com)
3032
22224b1b4d24 New docstrings mainly for module titles
damian
parents: 2964
diff changeset
     7
4252
fe660f227cac changes for release 3.3.0
robin
parents: 3721
diff changeset
     8
__version__='3.3.0'
3032
22224b1b4d24 New docstrings mainly for module titles
damian
parents: 2964
diff changeset
     9
__doc__="""This file is a collection of widgets to produce some common signs and symbols.
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
    10
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
    11
Widgets include:
3032
22224b1b4d24 New docstrings mainly for module titles
damian
parents: 2964
diff changeset
    12
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
    13
- ETriangle (an equilateral triangle),
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
    14
- RTriangle (a right angled triangle),
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
    15
- Octagon,
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
    16
- Crossbox,
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
    17
- Tickbox,
1223
6f9bee82e5a9 Changes for new Marker Class
rgbecker
parents: 1164
diff changeset
    18
- SmileyFace,
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
    19
- StopSign,
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
    20
- NoEntry,
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
    21
- NotAllowed (the red roundel from 'no smoking' signs),
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
    22
- NoSmoking,
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
    23
- DangerSign (a black exclamation point in a yellow triangle),
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
    24
- YesNo (returns a tickbox or a crossbox depending on a testvalue),
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
    25
- FloppyDisk,
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
    26
- ArrowOne, and
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
    27
- ArrowTwo
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
    28
"""
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
    29
611
8b5e9a4acd3e Corrected mistake in the doctsring for flags0.py and signsandsymbols.py.
johnprecedo
parents: 602
diff changeset
    30
from reportlab.lib import colors
927
ad7eb78babb4 Switched to using lib.validators module.
dinu_gherman
parents: 890
diff changeset
    31
from reportlab.lib.validators import *
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 934
diff changeset
    32
from reportlab.lib.attrmap import *
611
8b5e9a4acd3e Corrected mistake in the doctsring for flags0.py and signsandsymbols.py.
johnprecedo
parents: 602
diff changeset
    33
from reportlab.graphics import shapes
8b5e9a4acd3e Corrected mistake in the doctsring for flags0.py and signsandsymbols.py.
johnprecedo
parents: 602
diff changeset
    34
from reportlab.graphics.widgetbase import Widget
8b5e9a4acd3e Corrected mistake in the doctsring for flags0.py and signsandsymbols.py.
johnprecedo
parents: 602
diff changeset
    35
from reportlab.graphics import renderPDF
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
    36
927
ad7eb78babb4 Switched to using lib.validators module.
dinu_gherman
parents: 890
diff changeset
    37
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
    38
class _Symbol(Widget):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    39
    """Abstract base widget
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    40
    possible attributes:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    41
    'x', 'y', 'size', 'fillColor', 'strokeColor'
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    42
    """
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    43
    _nodoc = 1
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    44
    _attrMap = AttrMap(
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    45
        x = AttrMapValue(isNumber,desc='symbol x coordinate'),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    46
        y = AttrMapValue(isNumber,desc='symbol y coordinate'),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    47
        dx = AttrMapValue(isNumber,desc='symbol x coordinate adjustment'),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    48
        dy = AttrMapValue(isNumber,desc='symbol x coordinate adjustment'),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    49
        size = AttrMapValue(isNumber),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    50
        fillColor = AttrMapValue(isColorOrNone),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    51
        strokeColor = AttrMapValue(isColorOrNone),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    52
        strokeWidth = AttrMapValue(isNumber),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    53
        )
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    54
    def __init__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    55
        assert self.__class__.__name__!='_Symbol', 'Abstract class _Symbol instantiated'
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    56
        self.x = self.y = self.dx = self.dy = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    57
        self.size = 100
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    58
        self.fillColor = colors.red
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    59
        self.strokeColor = None
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    60
        self.strokeWidth = 0.1
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
    61
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    62
    def demo(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    63
        D = shapes.Drawing(200, 100)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    64
        s = float(self.size)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    65
        ob = self.__class__()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    66
        ob.x=50
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    67
        ob.y=0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    68
        ob.draw()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    69
        D.add(ob)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    70
        D.add(shapes.String(ob.x+(s/2),(ob.y-12),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    71
                            ob.__class__.__name__, fillColor=colors.black, textAnchor='middle',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    72
                            fontSize=10))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    73
        return D
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
    74
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
    75
class ETriangle(_Symbol):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    76
    """This draws an equilateral triangle."""
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
    77
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    78
    def __init__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    79
        pass #AbstractSymbol
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
    80
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    81
    def draw(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    82
        # general widget bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    83
        s = float(self.size)  # abbreviate as we will use this a lot
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    84
        g = shapes.Group()
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
    85
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    86
        # Triangle specific bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    87
        ae = s*0.125            #(ae = 'an eighth')
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    88
        triangle = shapes.Polygon(points = [
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    89
            self.x, self.y,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    90
            self.x+s, self.y,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    91
            self.x+(s/2),self.y+s],
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    92
               fillColor = self.fillColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    93
               strokeColor = self.strokeColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    94
               strokeWidth=s/50.)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    95
        g.add(triangle)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    96
        return g
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
    97
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
    98
class RTriangle(_Symbol):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
    99
    """This draws a right-angled triangle.
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   100
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   101
        possible attributes:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   102
        'x', 'y', 'size', 'fillColor', 'strokeColor'
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   103
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   104
        """
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   105
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   106
    def __init__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   107
        self.x = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   108
        self.y = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   109
        self.size = 100
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   110
        self.fillColor = colors.green
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   111
        self.strokeColor = None
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   112
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   113
    def draw(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   114
        # general widget bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   115
        s = float(self.size)  # abbreviate as we will use this a lot
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   116
        g = shapes.Group()
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   117
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   118
        # Triangle specific bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   119
        ae = s*0.125            #(ae = 'an eighth')
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   120
        triangle = shapes.Polygon(points = [
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   121
            self.x, self.y,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   122
            self.x+s, self.y,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   123
            self.x,self.y+s],
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   124
               fillColor = self.fillColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   125
               strokeColor = self.strokeColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   126
               strokeWidth=s/50.)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   127
        g.add(triangle)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   128
        return g
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   129
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
   130
class Octagon(_Symbol):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   131
    """This widget draws an Octagon.
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   132
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   133
        possible attributes:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   134
        'x', 'y', 'size', 'fillColor', 'strokeColor'
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   135
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   136
    """
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   137
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   138
    def __init__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   139
        self.x = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   140
        self.y = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   141
        self.size = 100
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   142
        self.fillColor = colors.yellow
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   143
        self.strokeColor = None
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   144
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   145
    def draw(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   146
        # general widget bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   147
        s = float(self.size)  # abbreviate as we will use this a lot
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   148
        g = shapes.Group()
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   149
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   150
        # Octagon specific bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   151
        athird=s/3
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   152
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   153
        octagon = shapes.Polygon(points=[self.x+athird, self.y,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   154
                                              self.x, self.y+athird,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   155
                                              self.x, self.y+(athird*2),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   156
                                              self.x+athird, self.y+s,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   157
                                              self.x+(athird*2), self.y+s,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   158
                                              self.x+s, self.y+(athird*2),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   159
                                              self.x+s, self.y+athird,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   160
                                              self.x+(athird*2), self.y],
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   161
                                      strokeColor = self.strokeColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   162
                                      fillColor = self.fillColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   163
                                      strokeWidth=10)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   164
        g.add(octagon)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   165
        return g
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   166
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
   167
class Crossbox(_Symbol):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   168
    """This draws a black box with a red cross in it - a 'checkbox'.
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   169
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   170
        possible attributes:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   171
        'x', 'y', 'size', 'crossColor', 'strokeColor', 'crosswidth'
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   172
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   173
    """
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   174
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   175
    _attrMap = AttrMap(BASE=_Symbol,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   176
        crossColor = AttrMapValue(isColorOrNone),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   177
        crosswidth = AttrMapValue(isNumber),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   178
        )
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   179
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   180
    def __init__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   181
        self.x = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   182
        self.y = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   183
        self.size = 100
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   184
        self.fillColor = colors.white
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   185
        self.crossColor = colors.red
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   186
        self.strokeColor = colors.black
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   187
        self.crosswidth = 10
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   188
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   189
    def draw(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   190
        # general widget bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   191
        s = float(self.size)  # abbreviate as we will use this a lot
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   192
        g = shapes.Group()
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   193
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   194
        # crossbox specific bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   195
        box = shapes.Rect(self.x+1, self.y+1, s-2, s-2,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   196
               fillColor = self.fillColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   197
               strokeColor = self.strokeColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   198
               strokeWidth=2)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   199
        g.add(box)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   200
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   201
        crossLine1 = shapes.Line(self.x+(s*0.15), self.y+(s*0.15), self.x+(s*0.85), self.y+(s*0.85),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   202
               fillColor = self.crossColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   203
               strokeColor = self.crossColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   204
               strokeWidth = self.crosswidth)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   205
        g.add(crossLine1)
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   206
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   207
        crossLine2 = shapes.Line(self.x+(s*0.15), self.y+(s*0.85), self.x+(s*0.85) ,self.y+(s*0.15),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   208
               fillColor = self.crossColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   209
               strokeColor = self.crossColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   210
               strokeWidth = self.crosswidth)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   211
        g.add(crossLine2)
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   212
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   213
        return g
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   214
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   215
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
   216
class Tickbox(_Symbol):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   217
    """This draws a black box with a red tick in it - another 'checkbox'.
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   218
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   219
        possible attributes:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   220
        'x', 'y', 'size', 'tickColor', 'strokeColor', 'tickwidth'
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   221
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   222
"""
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   223
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   224
    _attrMap = AttrMap(BASE=_Symbol,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   225
        tickColor = AttrMapValue(isColorOrNone),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   226
        tickwidth = AttrMapValue(isNumber),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   227
        )
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   228
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   229
    def __init__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   230
        self.x = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   231
        self.y = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   232
        self.size = 100
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   233
        self.tickColor = colors.red
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   234
        self.strokeColor = colors.black
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   235
        self.fillColor = colors.white
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   236
        self.tickwidth = 10
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   237
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   238
    def draw(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   239
        # general widget bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   240
        s = float(self.size)  # abbreviate as we will use this a lot
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   241
        g = shapes.Group()
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   242
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   243
        # tickbox specific bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   244
        box = shapes.Rect(self.x+1, self.y+1, s-2, s-2,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   245
               fillColor = self.fillColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   246
               strokeColor = self.strokeColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   247
               strokeWidth=2)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   248
        g.add(box)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   249
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   250
        tickLine = shapes.PolyLine(points = [self.x+(s*0.15), self.y+(s*0.35), self.x+(s*0.35), self.y+(s*0.15),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   251
                                             self.x+(s*0.35), self.y+(s*0.15), self.x+(s*0.85) ,self.y+(s*0.85)],
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   252
               fillColor = self.tickColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   253
               strokeColor = self.tickColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   254
               strokeWidth = self.tickwidth)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   255
        g.add(tickLine)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   256
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   257
        return g
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   258
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
   259
class SmileyFace(_Symbol):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   260
    """This draws a classic smiley face.
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   261
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   262
        possible attributes:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   263
        'x', 'y', 'size', 'fillColor'
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   264
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   265
    """
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   266
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   267
    def __init__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   268
        _Symbol.__init__(self)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   269
        self.x = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   270
        self.y = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   271
        self.size = 100
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   272
        self.fillColor = colors.yellow
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   273
        self.strokeColor = colors.black
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   274
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   275
    def draw(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   276
        # general widget bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   277
        s = float(self.size)  # abbreviate as we will use this a lot
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   278
        g = shapes.Group()
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   279
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   280
        # SmileyFace specific bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   281
        g.add(shapes.Circle(cx=self.x+(s/2), cy=self.y+(s/2), r=s/2,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   282
                fillColor=self.fillColor, strokeColor=self.strokeColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   283
                strokeWidth=max(s/38.,self.strokeWidth)))
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   284
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   285
        for i in (1,2):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   286
            g.add(shapes.Ellipse(self.x+(s/3)*i,self.y+(s/3)*2, s/30, s/10,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   287
                    fillColor=self.strokeColor, strokeColor = self.strokeColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   288
                    strokeWidth=max(s/38.,self.strokeWidth)))
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   289
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   290
        # calculate a pointslist for the mouth
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   291
        # THIS IS A HACK! - don't use if there is a 'shapes.Arc'
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   292
        centerx=self.x+(s/2)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   293
        centery=self.y+(s/2)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   294
        radius=s/3
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   295
        yradius = radius
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   296
        xradius = radius
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   297
        startangledegrees=200
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   298
        endangledegrees=340
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   299
        degreedelta = 1
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   300
        pointslist = []
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   301
        a = pointslist.append
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   302
        from math import sin, cos, pi
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   303
        degreestoradians = pi/180.0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   304
        radiansdelta = degreedelta*degreestoradians
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   305
        startangle = startangledegrees*degreestoradians
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   306
        endangle = endangledegrees*degreestoradians
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   307
        while endangle<startangle:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   308
              endangle = endangle+2*pi
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   309
        angle = startangle
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   310
        while angle<endangle:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   311
            x = centerx + cos(angle)*radius
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   312
            y = centery + sin(angle)*yradius
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   313
            a(x); a(y)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   314
            angle = angle+radiansdelta
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   315
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   316
        # make the mouth
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   317
        smile = shapes.PolyLine(pointslist,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   318
               fillColor = self.strokeColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   319
               strokeColor = self.strokeColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   320
               strokeWidth = max(s/38.,self.strokeWidth))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   321
        g.add(smile)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   322
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   323
        return g
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   324
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
   325
class StopSign(_Symbol):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   326
    """This draws a (British) stop sign.
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   327
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   328
        possible attributes:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   329
        'x', 'y', 'size'
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   330
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   331
        """
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   332
    _attrMap = AttrMap(BASE=_Symbol,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   333
        stopColor = AttrMapValue(isColorOrNone,desc='color of the word stop'),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   334
        )
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   335
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   336
    def __init__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   337
        self.x = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   338
        self.y = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   339
        self.size = 100
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   340
        self.strokeColor = colors.black
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   341
        self.fillColor = colors.orangered
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   342
        self.stopColor = colors.ghostwhite
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   343
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   344
    def draw(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   345
        # general widget bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   346
        s = float(self.size)  # abbreviate as we will use this a lot
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   347
        g = shapes.Group()
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   348
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   349
        # stop-sign specific bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   350
        athird=s/3
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   351
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   352
        outerOctagon = shapes.Polygon(points=[self.x+athird, self.y,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   353
                                              self.x, self.y+athird,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   354
                                              self.x, self.y+(athird*2),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   355
                                              self.x+athird, self.y+s,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   356
                                              self.x+(athird*2), self.y+s,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   357
                                              self.x+s, self.y+(athird*2),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   358
                                              self.x+s, self.y+athird,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   359
                                              self.x+(athird*2), self.y],
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   360
                                      strokeColor = self.strokeColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   361
                                      fillColor = None,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   362
                                      strokeWidth=1)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   363
        g.add(outerOctagon)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   364
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   365
        innerOctagon = shapes.Polygon(points=[self.x+athird+(s/75), self.y+(s/75),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   366
                                              self.x+(s/75), self.y+athird+(s/75),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   367
                                              self.x+(s/75), self.y+(athird*2)-(s/75),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   368
                                              self.x+athird+(s/75), self.y+s-(s/75),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   369
                                              self.x+(athird*2)-(s/75), (self.y+s)-(s/75),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   370
                                              (self.x+s)-(s/75), self.y+(athird*2)-(s/75),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   371
                                              (self.x+s)-(s/75), self.y+athird+(s/75),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   372
                                              self.x+(athird*2)-(s/75), self.y+(s/75)],
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   373
                                      strokeColor = None,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   374
                                      fillColor = self.fillColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   375
                                      strokeWidth=0)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   376
        g.add(innerOctagon)
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   377
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   378
        if self.stopColor:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   379
            g.add(shapes.String(self.x+(s*0.5),self.y+(s*0.4),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   380
                            'STOP', fillColor=self.stopColor, textAnchor='middle',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   381
                            fontSize=s/3, fontName="Helvetica-Bold"))
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   382
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   383
        return g
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   384
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   385
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
   386
class NoEntry(_Symbol):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   387
    """This draws a (British) No Entry sign - a red circle with a white line on it.
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   388
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   389
        possible attributes:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   390
        'x', 'y', 'size'
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   391
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   392
        """
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   393
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   394
    _attrMap = AttrMap(BASE=_Symbol,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   395
        innerBarColor = AttrMapValue(isColorOrNone,desc='color of the inner bar'),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   396
        )
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   397
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   398
    def __init__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   399
        self.x = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   400
        self.y = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   401
        self.size = 100
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   402
        self.strokeColor = colors.black
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   403
        self.fillColor = colors.orangered
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   404
        self.innerBarColor = colors.ghostwhite
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   405
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   406
    def draw(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   407
        # general widget bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   408
        s = float(self.size)  # abbreviate as we will use this a lot
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   409
        g = shapes.Group()
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   410
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   411
        # no-entry-sign specific bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   412
        if self.strokeColor:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   413
            g.add(shapes.Circle(cx = (self.x+(s/2)), cy = (self.y+(s/2)), r = s/2, fillColor = None, strokeColor = self.strokeColor, strokeWidth=1))
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   414
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   415
        if self.fillColor:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   416
            g.add(shapes.Circle(cx = (self.x+(s/2)), cy =(self.y+(s/2)), r = ((s/2)-(s/50)), fillColor = self.fillColor, strokeColor = None, strokeWidth=0))
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   417
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   418
        innerBarColor = self.innerBarColor
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   419
        if innerBarColor:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   420
            g.add(shapes.Rect(self.x+(s*0.1), self.y+(s*0.4), width=s*0.8, height=s*0.2, fillColor = innerBarColor, strokeColor = innerBarColor, strokeLineCap = 1, strokeWidth = 0))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   421
        return g
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   422
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
   423
class NotAllowed(_Symbol):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   424
    """This draws a 'forbidden' roundel (as used in the no-smoking sign).
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   425
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   426
        possible attributes:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   427
        'x', 'y', 'size'
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   428
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   429
        """
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   430
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   431
    _attrMap = AttrMap(BASE=_Symbol,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   432
        )
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   433
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   434
    def __init__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   435
        self.x = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   436
        self.y = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   437
        self.size = 100
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   438
        self.strokeColor = colors.red
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   439
        self.fillColor = colors.white
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   440
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   441
    def draw(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   442
        # general widget bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   443
        s = float(self.size)  # abbreviate as we will use this a lot
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   444
        g = shapes.Group()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   445
        strokeColor = self.strokeColor
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   446
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   447
        # not=allowed specific bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   448
        outerCircle = shapes.Circle(cx = (self.x+(s/2)), cy = (self.y+(s/2)), r = (s/2)-(s/10), fillColor = self.fillColor, strokeColor = strokeColor, strokeWidth=s/10.)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   449
        g.add(outerCircle)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   450
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   451
        centerx=self.x+s
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   452
        centery=self.y+(s/2)-(s/6)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   453
        radius=s-(s/6)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   454
        yradius = radius/2
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   455
        xradius = radius/2
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   456
        startangledegrees=100
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   457
        endangledegrees=-80
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   458
        degreedelta = 90
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   459
        pointslist = []
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   460
        a = pointslist.append
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   461
        from math import sin, cos, pi
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   462
        degreestoradians = pi/180.0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   463
        radiansdelta = degreedelta*degreestoradians
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   464
        startangle = startangledegrees*degreestoradians
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   465
        endangle = endangledegrees*degreestoradians
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   466
        while endangle<startangle:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   467
            endangle = endangle+2*pi
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   468
        angle = startangle
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   469
        while angle<endangle:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   470
            x = centerx + cos(angle)*radius
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   471
            y = centery + sin(angle)*yradius
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   472
            a(x); a(y)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   473
            angle = angle+radiansdelta
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   474
        crossbar = shapes.PolyLine(pointslist, fillColor = strokeColor, strokeColor = strokeColor, strokeWidth = s/10.)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   475
        g.add(crossbar)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   476
        return g
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   477
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   478
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
   479
class NoSmoking(NotAllowed):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   480
    """This draws a no-smoking sign.
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   481
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   482
        possible attributes:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   483
        'x', 'y', 'size'
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   484
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   485
        """
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   486
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   487
    def __init__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   488
        NotAllowed.__init__(self)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   489
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   490
    def draw(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   491
        # general widget bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   492
        s = float(self.size)  # abbreviate as we will use this a lot
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   493
        g = NotAllowed.draw(self)
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   494
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   495
        # no-smoking-sign specific bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   496
        newx = self.x+(s/2)-(s/3.5)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   497
        newy = self.y+(s/2)-(s/32)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   498
        cigarrette1 = shapes.Rect(x = newx, y = newy, width = (s/2), height =(s/16),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   499
                fillColor = colors.ghostwhite, strokeColor = colors.gray, strokeWidth=0)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   500
        newx=newx+(s/2)+(s/64)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   501
        g.insert(-1,cigarrette1)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   502
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   503
        cigarrette2 = shapes.Rect(x = newx, y = newy, width = (s/80), height =(s/16),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   504
                fillColor = colors.orangered, strokeColor = None, strokeWidth=0)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   505
        newx= newx+(s/35)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   506
        g.insert(-1,cigarrette2)
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   507
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   508
        cigarrette3 = shapes.Rect(x = newx, y = newy, width = (s/80), height =(s/16),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   509
                fillColor = colors.orangered, strokeColor = None, strokeWidth=0)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   510
        newx= newx+(s/35)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   511
        g.insert(-1,cigarrette3)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   512
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   513
        cigarrette4 = shapes.Rect(x = newx, y = newy, width = (s/80), height =(s/16),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   514
                fillColor = colors.orangered, strokeColor = None, strokeWidth=0)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   515
        newx= newx+(s/35)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   516
        g.insert(-1,cigarrette4)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   517
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   518
        return g
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   519
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   520
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
   521
class DangerSign(_Symbol):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   522
    """This draws a 'danger' sign: a yellow box with a black exclamation point.
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   523
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   524
        possible attributes:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   525
        'x', 'y', 'size', 'strokeColor', 'fillColor', 'strokeWidth'
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   526
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   527
        """
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   528
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   529
    def __init__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   530
        self.x = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   531
        self.y = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   532
        self.size = 100
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   533
        self.strokeColor = colors.black
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   534
        self.fillColor = colors.gold
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   535
        self.strokeWidth = self.size*0.125
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   536
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   537
    def draw(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   538
        # general widget bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   539
        s = float(self.size)  # abbreviate as we will use this a lot
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   540
        g = shapes.Group()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   541
        ew = self.strokeWidth
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   542
        ae = s*0.125            #(ae = 'an eighth')
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   543
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   544
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   545
        # danger sign specific bits
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   546
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   547
        ew = self.strokeWidth
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   548
        ae = s*0.125            #(ae = 'an eighth')
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   549
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   550
        outerTriangle = shapes.Polygon(points = [
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   551
            self.x, self.y,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   552
            self.x+s, self.y,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   553
            self.x+(s/2),self.y+s],
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   554
               fillColor = None,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   555
               strokeColor = self.strokeColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   556
               strokeWidth=0)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   557
        g.add(outerTriangle)
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   558
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   559
        innerTriangle = shapes.Polygon(points = [
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   560
            self.x+(s/50), self.y+(s/75),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   561
            (self.x+s)-(s/50), self.y+(s/75),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   562
            self.x+(s/2),(self.y+s)-(s/50)],
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   563
               fillColor = self.fillColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   564
               strokeColor = None,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   565
               strokeWidth=0)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   566
        g.add(innerTriangle)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   567
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   568
        exmark = shapes.Polygon(points=[
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   569
            ((self.x+s/2)-ew/2), self.y+ae*2.5,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   570
            ((self.x+s/2)+ew/2), self.y+ae*2.5,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   571
            ((self.x+s/2)+((ew/2))+(ew/6)), self.y+ae*5.5,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   572
            ((self.x+s/2)-((ew/2))-(ew/6)), self.y+ae*5.5],
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   573
               fillColor = self.strokeColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   574
               strokeColor = None)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   575
        g.add(exmark)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   576
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   577
        exdot = shapes.Polygon(points=[
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   578
            ((self.x+s/2)-ew/2), self.y+ae,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   579
            ((self.x+s/2)+ew/2), self.y+ae,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   580
            ((self.x+s/2)+ew/2), self.y+ae*2,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   581
            ((self.x+s/2)-ew/2), self.y+ae*2],
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   582
               fillColor = self.strokeColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   583
               strokeColor = None)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   584
        g.add(exdot)
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   585
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   586
        return g
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   587
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   588
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
   589
class YesNo(_Symbol):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   590
    """This widget draw a tickbox or crossbox depending on 'testValue'.
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   591
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   592
        If this widget is supplied with a 'True' or 1 as a value for
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   593
        testValue, it will use the tickbox widget. Otherwise, it will
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   594
        produce a crossbox.
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   595
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   596
        possible attributes:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   597
        'x', 'y', 'size', 'tickcolor', 'crosscolor', 'testValue'
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   598
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   599
"""
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   600
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   601
    _attrMap = AttrMap(BASE=_Symbol,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   602
        tickcolor = AttrMapValue(isColor),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   603
        crosscolor = AttrMapValue(isColor),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   604
        testValue = AttrMapValue(isBoolean),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   605
        )
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   606
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   607
    def __init__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   608
        self.x = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   609
        self.y = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   610
        self.size = 100
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   611
        self.tickcolor = colors.green
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   612
        self.crosscolor = colors.red
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   613
        self.testValue = 1
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   614
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   615
    def draw(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   616
        if self.testValue:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   617
            yn=Tickbox()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   618
            yn.tickColor=self.tickcolor
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   619
        else:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   620
            yn=Crossbox()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   621
            yn.crossColor=self.crosscolor
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   622
        yn.x=self.x
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   623
        yn.y=self.y
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   624
        yn.size=self.size
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   625
        yn.draw()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   626
        return yn
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   627
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   628
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   629
    def demo(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   630
        D = shapes.Drawing(200, 100)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   631
        yn = YesNo()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   632
        yn.x = 15
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   633
        yn.y = 25
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   634
        yn.size = 70
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   635
        yn.testValue = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   636
        yn.draw()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   637
        D.add(yn)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   638
        yn2 = YesNo()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   639
        yn2.x = 120
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   640
        yn2.y = 25
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   641
        yn2.size = 70
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   642
        yn2.testValue = 1
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   643
        yn2.draw()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   644
        D.add(yn2)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   645
        labelFontSize = 8
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   646
        D.add(shapes.String(yn.x+(yn.size/2),(yn.y-(1.2*labelFontSize)),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   647
                            'testValue=0', fillColor=colors.black, textAnchor='middle',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   648
                            fontSize=labelFontSize))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   649
        D.add(shapes.String(yn2.x+(yn2.size/2),(yn2.y-(1.2*labelFontSize)),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   650
                            'testValue=1', fillColor=colors.black, textAnchor='middle',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   651
                            fontSize=labelFontSize))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   652
        labelFontSize = 10
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   653
        D.add(shapes.String(yn.x+85,(yn.y-20),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   654
                            self.__class__.__name__, fillColor=colors.black, textAnchor='middle',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   655
                            fontSize=labelFontSize))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   656
        return D
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   657
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
   658
class FloppyDisk(_Symbol):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   659
    """This widget draws an icon of a floppy disk.
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   660
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   661
        possible attributes:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   662
        'x', 'y', 'size', 'diskcolor'
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   663
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   664
        """
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   665
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   666
    _attrMap = AttrMap(BASE=_Symbol,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   667
        diskColor = AttrMapValue(isColor),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   668
        )
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   669
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   670
    def __init__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   671
        self.x = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   672
        self.y = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   673
        self.size = 100
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   674
        self.diskColor = colors.black
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   675
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   676
    def draw(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   677
        # general widget bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   678
        s = float(self.size)  # abbreviate as we will use this a lot
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   679
        g = shapes.Group()
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   680
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   681
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   682
        # floppy disk specific bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   683
        diskBody = shapes.Rect(x=self.x, y=self.y+(s/100), width=s, height=s-(s/100),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   684
               fillColor = self.diskColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   685
               strokeColor = None,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   686
               strokeWidth=0)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   687
        g.add(diskBody)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   688
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   689
        label = shapes.Rect(x=self.x+(s*0.1), y=(self.y+s)-(s*0.5), width=s*0.8, height=s*0.48,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   690
               fillColor = colors.whitesmoke,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   691
               strokeColor = None,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   692
               strokeWidth=0)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   693
        g.add(label)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   694
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   695
        labelsplash = shapes.Rect(x=self.x+(s*0.1), y=(self.y+s)-(s*0.1), width=s*0.8, height=s*0.08,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   696
               fillColor = colors.royalblue,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   697
               strokeColor = None,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   698
               strokeWidth=0)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   699
        g.add(labelsplash)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   700
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   701
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   702
        line1 = shapes.Line(x1=self.x+(s*0.15), y1=self.y+(0.6*s), x2=self.x+(s*0.85), y2=self.y+(0.6*s),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   703
               fillColor = colors.black,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   704
               strokeColor = colors.black,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   705
               strokeWidth=0)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   706
        g.add(line1)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   707
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   708
        line2 = shapes.Line(x1=self.x+(s*0.15), y1=self.y+(0.7*s), x2=self.x+(s*0.85), y2=self.y+(0.7*s),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   709
               fillColor = colors.black,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   710
               strokeColor = colors.black,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   711
               strokeWidth=0)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   712
        g.add(line2)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   713
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   714
        line3 = shapes.Line(x1=self.x+(s*0.15), y1=self.y+(0.8*s), x2=self.x+(s*0.85), y2=self.y+(0.8*s),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   715
               fillColor = colors.black,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   716
               strokeColor = colors.black,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   717
               strokeWidth=0)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   718
        g.add(line3)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   719
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   720
        metalcover = shapes.Rect(x=self.x+(s*0.2), y=(self.y), width=s*0.5, height=s*0.35,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   721
               fillColor = colors.silver,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   722
               strokeColor = None,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   723
               strokeWidth=0)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   724
        g.add(metalcover)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   725
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   726
        coverslot = shapes.Rect(x=self.x+(s*0.28), y=(self.y)+(s*0.035), width=s*0.12, height=s*0.28,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   727
               fillColor = self.diskColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   728
               strokeColor = None,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   729
               strokeWidth=0)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   730
        g.add(coverslot)
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   731
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   732
        return g
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   733
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
   734
class ArrowOne(_Symbol):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   735
    """This widget draws an arrow (style one).
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   736
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   737
        possible attributes:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   738
        'x', 'y', 'size', 'fillColor'
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   739
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   740
        """
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   741
    def __init__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   742
        self.x = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   743
        self.y = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   744
        self.size = 100
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   745
        self.fillColor = colors.red
3299
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   746
        self.strokeWidth = 0
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   747
        self.strokeColor = None
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   748
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   749
    def draw(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   750
        # general widget bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   751
        s = float(self.size)  # abbreviate as we will use this a lot
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   752
        g = shapes.Group()
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   753
3299
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   754
        x = self.x
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   755
        y = self.y
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   756
        s2 = s/2
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   757
        s3 = s/3
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   758
        s5 = s/5
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   759
        g.add(shapes.Polygon(points = [
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   760
                                        x,y+s3,
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   761
                                        x,y+2*s3,
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   762
                                        x+s2,y+2*s3,
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   763
                                        x+s2,y+4*s5,
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   764
                                        x+s,y+s2,
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   765
                                        x+s2,y+s5,
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   766
                                        x+s2,y+s3,
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   767
                                       ],
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   768
                fillColor = self.fillColor,
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   769
                strokeColor = self.strokeColor,
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   770
                strokeWidth = self.strokeWidth,
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   771
                )
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   772
            )
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   773
        return g
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   774
1237
04650f921d93 Changes related to symbols coming of age
rgbecker
parents: 1224
diff changeset
   775
class ArrowTwo(ArrowOne):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   776
    """This widget draws an arrow (style two).
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   777
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   778
        possible attributes:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   779
        'x', 'y', 'size', 'fillColor'
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   780
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   781
        """
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   782
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   783
    def __init__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   784
        self.x = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   785
        self.y = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   786
        self.size = 100
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   787
        self.fillColor = colors.blue
3299
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   788
        self.strokeWidth = 0
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   789
        self.strokeColor = None
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   790
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   791
    def draw(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   792
        # general widget bits
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   793
        s = float(self.size)  # abbreviate as we will use this a lot
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   794
        g = shapes.Group()
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   795
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   796
        # arrow specific bits
3299
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   797
        x = self.x
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   798
        y = self.y
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   799
        s2 = s/2
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   800
        s3 = s/3
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   801
        s5 = s/5
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   802
        s24 = s/24
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   803
3299
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   804
        g.add(shapes.Polygon(
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   805
            points = [
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   806
                    x,y+11*s24,
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   807
                    x,y+13*s24,
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   808
                    x+18.75*s24, y+13*s24,
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   809
                    x+2*s3, y+2*s3,
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   810
                    x+s, y+s2,
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   811
                    x+2*s3, y+s3,
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   812
                    x+18.75*s24, y+11*s24,
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   813
                    ],
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   814
            fillColor = self.fillColor,
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   815
            strokeColor = self.strokeColor,
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   816
            strokeWidth = self.strokeWidth)
c597eadd32c8 signsandsymbols.py: imporve ArrowOne & ArrowTwo
rgbecker
parents: 3032
diff changeset
   817
            )
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   818
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   819
        return g
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   820
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   821
586
06bec1d89dca Changed classnames to use the '0' convention for experimental.
johnprecedo
parents: 582
diff changeset
   822
def test():
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   823
    """This function produces a pdf with examples of all the signs and symbols from this file.
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   824
    """
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   825
    labelFontSize = 10
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   826
    D = shapes.Drawing(450,650)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   827
    cb = Crossbox()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   828
    cb.x = 20
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   829
    cb.y = 530
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   830
    D.add(cb)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   831
    D.add(shapes.String(cb.x+(cb.size/2),(cb.y-(1.2*labelFontSize)),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   832
                           cb.__class__.__name__, fillColor=colors.black, textAnchor='middle',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   833
                           fontSize=labelFontSize))
586
06bec1d89dca Changed classnames to use the '0' convention for experimental.
johnprecedo
parents: 582
diff changeset
   834
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   835
    tb = Tickbox()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   836
    tb.x = 170
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   837
    tb.y = 530
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   838
    D.add(tb)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   839
    D.add(shapes.String(tb.x+(tb.size/2),(tb.y-(1.2*labelFontSize)),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   840
                            tb.__class__.__name__, fillColor=colors.black, textAnchor='middle',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   841
                            fontSize=labelFontSize))
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   842
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   843
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   844
    yn = YesNo()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   845
    yn.x = 320
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   846
    yn.y = 530
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   847
    D.add(yn)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   848
    tempstring = yn.__class__.__name__ + '*'
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   849
    D.add(shapes.String(yn.x+(tb.size/2),(yn.y-(1.2*labelFontSize)),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   850
                            tempstring, fillColor=colors.black, textAnchor='middle',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   851
                            fontSize=labelFontSize))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   852
    D.add(shapes.String(130,6,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   853
                            "(The 'YesNo' widget returns a tickbox if testvalue=1, and a crossbox if testvalue=0)", fillColor=colors.black, textAnchor='middle',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   854
                            fontSize=labelFontSize*0.75))
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   855
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   856
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   857
    ss = StopSign()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   858
    ss.x = 20
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   859
    ss.y = 400
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   860
    D.add(ss)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   861
    D.add(shapes.String(ss.x+(ss.size/2), ss.y-(1.2*labelFontSize),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   862
                            ss.__class__.__name__, fillColor=colors.black, textAnchor='middle',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   863
                            fontSize=labelFontSize))
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   864
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   865
    ne = NoEntry()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   866
    ne.x = 170
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   867
    ne.y = 400
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   868
    D.add(ne)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   869
    D.add(shapes.String(ne.x+(ne.size/2),(ne.y-(1.2*labelFontSize)),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   870
                            ne.__class__.__name__, fillColor=colors.black, textAnchor='middle',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   871
                            fontSize=labelFontSize))
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   872
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   873
    sf = SmileyFace()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   874
    sf.x = 320
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   875
    sf.y = 400
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   876
    D.add(sf)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   877
    D.add(shapes.String(sf.x+(sf.size/2),(sf.y-(1.2*labelFontSize)),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   878
                            sf.__class__.__name__, fillColor=colors.black, textAnchor='middle',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   879
                            fontSize=labelFontSize))
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   880
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   881
    ds = DangerSign()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   882
    ds.x = 20
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   883
    ds.y = 270
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   884
    D.add(ds)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   885
    D.add(shapes.String(ds.x+(ds.size/2),(ds.y-(1.2*labelFontSize)),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   886
                            ds.__class__.__name__, fillColor=colors.black, textAnchor='middle',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   887
                            fontSize=labelFontSize))
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   888
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   889
    na = NotAllowed()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   890
    na.x = 170
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   891
    na.y = 270
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   892
    D.add(na)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   893
    D.add(shapes.String(na.x+(na.size/2),(na.y-(1.2*labelFontSize)),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   894
                            na.__class__.__name__, fillColor=colors.black, textAnchor='middle',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   895
                            fontSize=labelFontSize))
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   896
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   897
    ns = NoSmoking()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   898
    ns.x = 320
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   899
    ns.y = 270
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   900
    D.add(ns)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   901
    D.add(shapes.String(ns.x+(ns.size/2),(ns.y-(1.2*labelFontSize)),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   902
                            ns.__class__.__name__, fillColor=colors.black, textAnchor='middle',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   903
                            fontSize=labelFontSize))
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   904
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   905
    a1 = ArrowOne()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   906
    a1.x = 20
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   907
    a1.y = 140
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   908
    D.add(a1)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   909
    D.add(shapes.String(a1.x+(a1.size/2),(a1.y-(1.2*labelFontSize)),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   910
                            a1.__class__.__name__, fillColor=colors.black, textAnchor='middle',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   911
                            fontSize=labelFontSize))
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   912
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   913
    a2 = ArrowTwo()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   914
    a2.x = 170
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   915
    a2.y = 140
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   916
    D.add(a2)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   917
    D.add(shapes.String(a2.x+(a2.size/2),(a2.y-(1.2*labelFontSize)),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   918
                            a2.__class__.__name__, fillColor=colors.black, textAnchor='middle',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   919
                            fontSize=labelFontSize))
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   920
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   921
    fd = FloppyDisk()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   922
    fd.x = 320
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   923
    fd.y = 140
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   924
    D.add(fd)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   925
    D.add(shapes.String(fd.x+(fd.size/2),(fd.y-(1.2*labelFontSize)),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   926
                            fd.__class__.__name__, fillColor=colors.black, textAnchor='middle',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   927
                            fontSize=labelFontSize))
582
139b9a27e5da First checkin of file that used to be users/john/jwidgets.py.
johnprecedo
parents:
diff changeset
   928
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1558
diff changeset
   929
    renderPDF.drawToFile(D, 'signsandsymbols.pdf', 'signsandsymbols.py')
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   930
    print('wrote file: signsandsymbols.pdf')
1164
2e6656c5d353 Fixed some truncating division problems, removed excess demo methods
rgbecker
parents: 1043
diff changeset
   931
586
06bec1d89dca Changed classnames to use the '0' convention for experimental.
johnprecedo
parents: 582
diff changeset
   932
if __name__=='__main__':
3032
22224b1b4d24 New docstrings mainly for module titles
damian
parents: 2964
diff changeset
   933
    test()