示例#1
0
def ReconstructionAndRetrofitFooter(**kwargs):
    return Text(**kwargs,
                text='{} {}'.format(boil('recon_&_retrofit_panel_footer'),
                                    kwargs['data']),
                font_family="Roboto Light",
                font_size=6,
                color=Color.DARK_GRAY,
                padding=Rect([0, 5, 2, 0]))
示例#2
0
def sand():
    t = Text(
        width='100%',
        height='50%',
        text='x',
        color=Color.DARK_GREEN,
        font_family="Roboto Condensed",
        font_size=5,
        auto_scale=True,
    ),
    b = Text(
        width='100%',
        height='50%',
        text='' * 300,
        color=Color.DARK_GREEN,
        font_family="Roboto Condensed",
        font_size=5,
        auto_scale=True,
    ),
示例#3
0
def Numeral(
        value=None,
        prefix='',
        separator=True,
        suffix='',
        **kwargs
):
    text = '{}{}{}'.format(prefix, value, suffix)

    return Text(
        markup=text,
        **kwargs,
    )
示例#4
0
def BottomBox(data):
    return Row(
        width='100%',
        margin=Rect([8, 0, 6, 0]),
        border=Border(
            width=0.5,
            color=Color.BLACK,
        ),
        padding=Rect([2, 8, 4, 8]),
    ).add(
        Column(width='50%').add(
            Text(
                text=boil('status_of_cm_types_of_workers'),
                font_family='Roboto Condensed',
                font_size=8,
                font_weight=Pango.Weight.BOLD,
            ),
            Text(text='{} {}'.format(
                boil('status_of_cm_list_1'),
                boil('status_of_cm_skilled_mason'),
            ),
                 font_family='Roboto Condensed',
                 font_size=8,
                 padding=Rect([2, 0, 2, 0])),
            Text(
                text='{} {}'.format(
                    boil('status_of_cm_list_2'),
                    boil('status_of_cm_labourer'),
                ),
                font_family='Roboto Condensed',
                font_size=8,
            ),
        ),
        Column(width='60%').add(
            Text(
                text=boil('status_of_cm_avg._daily_wage_(nrs.)'),
                width='100%',
                alignment=Text.CENTER,
                font_family='Roboto Condensed',
                font_size=8,
                font_weight=Pango.Weight.BOLD,
            ),
            Text(
                text='%s %s' % (fmt_num(data['avg_wage_1']), '/-'),
                width='65%',
                alignment=Text.RIGHT,
                font_family='Roboto Condensed',
                font_size=8,
                padding=Rect([2, 0, 2, 0]),
            ),
            Text(
                text='%s %s' % (fmt_num(data['avg_wage_2']), '/-'),
                width='65%',
                alignment=Text.RIGHT,
                font_family='Roboto Condensed',
                font_size=8,
                padding=Rect([0, 0, 1, 0]),
            )),
    )
示例#5
0
def Footer(data):
    faq_blocks = []
    for it, item in enumerate(data):
        question = Text(
            width='100%',
            text='{}: {}'.format(boil('faq_q'), item['q']),
            font_family='Roboto Condensed',
            font_size=8.5,
            font_weight=Pango.Weight.BOLD,
        )
        answer = Text(
            width='100%',
            text='{}: {}'.format(boil('faq_a'), item['a']),
            font_family='Roboto Condensed',
            font_size=8,
            padding=Rect([0, 0, 8, 0]) if it == 0 else Rect(0),
        )
        faq_blocks.append(question)
        faq_blocks.append(answer)

    return Column(
        width='100%',
        padding=Rect([10, 16, 6, 16]),
    ).add(*faq_blocks, )
示例#6
0
def Label(label, color):
    return Row(
        margin=Rect([8, 0, 0, 0]),
    ).add(
        Node(
            width=10,
            height=10,
            bg_color=color,
            margin=Rect([2, 4, 0, 0]),
        ),
        Text(
            text=label,
            font='Roboto Light',
            font_size=8,
            padding=Rect([2.5, 0, 0, 0])
        )
    )
示例#7
0
def Label(label, color):
    return Row(
        margin=Rect([0, 10, 0, 10]),
        padding=Rect([8, 10, 5, 10]),
    ).add(
        Node(
            width=7,
            height=7,
            bg_color=color,
            margin=Rect([0, 4, 0, 0]),
        ),
        Text(
            text=label,
            font='Roboto Light',
            font_size=6,
        )
    )
示例#8
0
def Panel(**kwargs):
    title = kwargs.pop('title', None)
    left_footer = kwargs.pop('left_footer', empty)
    right_footer = kwargs.pop('right_footer', empty)
    footer_data = kwargs.pop('footer_data', empty)

    return Row(
        border=Border(
            color=Color.BLUE,
            radius=16,
            width=1,
        ),
        relative=True,
        margin=Rect([10, 5, 10, 5]),
        **kwargs,
    ).add(
        Text(
            text=title,
            absolute=True,
            font_family='Roboto Condensed',
            font_size=13,
            font_weight=Pango.Weight.BOLD,
            color=Color.BLUE,
            top=-6,
            left=10,
            bg_color=Color.WHITE,
            padding=Rect([0, 6, 0, 6]),
        ),
        left_footer(
            absolute=True,
            bottom=-12,
            left=0,
            data=footer_data,
        ),
        right_footer(
            absolute=True,
            bottom=-12,
            right=2,
            data=footer_data,
        ),
    )
示例#9
0
def TR_Text(widths, items):
    return Row(width='100%').add(*[
        Row(
            width=widths[i],
            height='100%',
            border=Border(
                width=0.5,
                color=Color.BLACK,
            ),
            padding=Rect(5),
        ).add(
            Text(
                markup=xstr(item),
                font_family='Roboto Condensed',
                font_size=7,
                width=("100%" if i != 0 else None),
                height="100%",
                alignment=Text.CENTER,
                vertical_alignment=Text.MIDDLE,
            )) for i, item in enumerate(items)
    ])
示例#10
0
def HH(data):
    """for showing the HH bar. logic:
            if 0 values: show message that there are no reported issues
            if 1 value: do something #TODO
            else: show bar
            """

    # info f.e type
    items = [
        {
            'key': 'landless',
            'label': boil('land_issues_landless'),
            'color': hx('#ff6117'),
        },
        {
            'key': 'no_land_certificates',
            'label': boil('land_issues_no_land_certificates'),
            'color': hx('#bf053d'),
        },
        {
            'key': 'right_of_way',
            'label': boil('land_issues_right_of_way'),
            'color': hx('#7d0547'),
        },
        {
            'key': 'affected_by_hep',
            'label': boil('land_issues_affected_by_hep'),
            'color': hx('#1e7a8c'),
        },
        {
            'key': 'smallplots',
            'label': boil('land_issues_small_plots'),
            'color': hx('#abd1b5'),
        },
        {
            'key': 'guthi_land',
            'label': boil('land_issues_guthi_land'),
            'color': hx('#ffc202'),
        },
    ]

    # add val and drop item if it's zero or invalid
    items = _filter_items(items, data)

    wdz = _get_widths(items)

    bars = []
    labels = []
    if wdz:
        for item in wdz:
            color = item['color']

            bar = Text(
                bg_color=color,
                height=20,
                width='{}%'.format(item['w']),
                alignment=Text.CENTER,
                vertical_alignment=Text.MIDDLE,
                text=fmt_num(item['val']),
                color=Color.WHITE,
                font_family='Roboto Condensed',
                font_size=11,
                font_weight=Pango.Weight.BOLD,
            )
            bars.append(bar)

            label = Label(
                label=item['label'],
                color=color,
            )
            labels.append(label)

        return Column(
            width='100%',
            padding=Rect([16, 16, 8, 16]),
        ).add(
            Row(width='100%').add(*bars),
            Row(
                width='100%',
                justify='space-between' if len(labels) > 1 else None,
            ).add(*labels)
        )

    else:
        return Column(width='100%', height='100%').add(
            Text(
                height='100%',
                width='100%',
                alignment=Text.CENTER,
                vertical_alignment=Text.MIDDLE,
                text=boil('land_issues_no_information'),
                color=Color.GRAY,
                font_family='Roboto Condensed',
                font_size=18,
                font_weight=Pango.Weight.BOLD,
                margin=Rect([0, 0, 43, 0]),
            )
        )
示例#11
0
def TechnicalStaff(tech_data, mason_data):
    widths = ['35%', '30%', '35%']
    headers = [
        boil('tech_staff_staff_title'),
        boil('tech_staff_available_title'),
        boil('tech_staff_addl_req_title')
    ]

    tech_data = [[
        boil(item['lookup']),
        fmt_num(item['available']),
        fmt_num(item['additional'])
    ] for item in tech_data]

    mason_data = [
        boil(mason_data['lookup']), mason_data['available'],
        mason_data['additional']
    ]

    # mason_data = [mason_data['label'], 100, 300]

    header_row = Row(width='100%').add(*[
        Text(
            border=Border(width=0.5, color=Color.BLACK),
            text=item,
            width=widths[i],
            font_family='Roboto Condensed',
            font_size=7,
            font_weight=Pango.Weight.BOLD,
            padding=Rect(4),
            alignment=(Text.LEFT if i == 0 else Text.CENTER),
        ) for i, item in enumerate(headers)
    ])

    # add non masons
    data_rows = [
        Row(width='100%').add(
            *[
                Text(
                    border=Border(width=0.5, color=Color.BLACK),
                    text=item,
                    width=widths[i],
                    height='15',
                    font_family='Roboto Condensed',
                    font_size=7 if i == 0 else 9,
                    font_weight=Pango.Weight.BOLD if i == 0 else None,
                    padding=Rect([3, 0, 0, 4]),
                    alignment=(Text.LEFT if i == 0 else Text.CENTER),
                ) for i, item in enumerate(row)
            ], ) for row in tech_data
    ]

    # add masons
    data_rows.append(
        Row(width='100%').add(*[
            Text(
                border=Border(width=0.5, color=Color.BLACK),
                text=mason_data[0],
                width=widths[0],
                font_family='Roboto Condensed',
                font_weight=Pango.Weight.BOLD,
                font_size=7,
                padding=Rect(4),
                alignment=Text.LEFT,
            ),
            Column(
                border=Border(width=0.5, color=Color.BLACK),
                height='100%',
                width=widths[1],
            ).add(
                Text(
                    text='{} ({} {})'.format(fmt_num(mason_data[1][0]),
                                             fmt_num(7), boil(
                                                 'tech_staff_days')),
                    font_family='Roboto Condensed',
                    font_size=6,
                    width='100%',
                    alignment=Text.CENTER,
                    padding=Rect([2, 0, 0, 0]),
                )).add(
                    Text(
                        text='{} ({} {})'.format(fmt_num(mason_data[1][1]),
                                                 fmt_num(50),
                                                 boil('tech_staff_days')),
                        font_family='Roboto Condensed',
                        font_size=6,
                        width='100%',
                        alignment=Text.CENTER,
                    )),
            Column(border=Border(width=0.5, color=Color.BLACK),
                   height='100%',
                   width=widths[2]).add(
                       Text(
                           text='{} ({} {})'.format(fmt_num(mason_data[2][0]),
                                                    fmt_num(7),
                                                    boil('tech_staff_days')),
                           font_family='Roboto Condensed',
                           font_size=6,
                           width='100%',
                           alignment=Text.CENTER,
                           padding=Rect([2, 0, 0, 0]),
                       )).add(
                           Text(
                               text='{} ({} {})'.format(
                                   fmt_num(mason_data[2][1]), fmt_num(50),
                                   boil('tech_staff_days')),
                               font_family='Roboto Condensed',
                               font_size=6,
                               width='100%',
                               alignment=Text.CENTER,
                           )),
        ]))
    #
    # Row(width=widths[1],
    #     border=Border(width=0.5, color=Color.BLACK),
    #     height='100%').add(
    #     Row(border=Border(width=0.5, color=Color.BLACK)).add(
    #         Text(
    #             text='xx22',
    #             font='RobotoCondensed bold 6',
    #             font_size='RobotoCondensed bold',
    #             alignment=Text.CENTER,
    #         ),
    #     ).add(Row(border=Border(width=0.5, color=Color.BLACK)).add(
    #         Text(
    #             text='yy',
    #             font='RobotoCondensed 6',
    #         ),
    #     ),
    #     ),

    return Column(
        width='100%',
        padding=Rect(16),
    ).add(
        header_row,
        *data_rows,
    )
示例#12
0
def Typologies(data):
    widths = ['60%', '20%', '20%']
    headers = [
        boil('typologies_typology'),
        boil('typologies_municipal'),
        boil('typologies_district')
    ]

    if get_lang() == 'np':
        row_seperator_padding = [3.5, 0, 4.5, 0]
    else:
        row_seperator_padding = [4.5, 0, 4.5, 0]

    # flatten and add dict
    # TODO: assert that we don't have duplicate keys? (exclude blanks))
    rows = get_list_typo(OrderedDict((boil(k), v) for k, v in data.items()), 5)

    return Column(
        width='100%',
        padding=Rect(12),
    ).add(
        Row(width='100%').add(*[
            Text(
                width=widths[i],
                text=header,
                font_family="Roboto Condensed",
                font_size=9,
                font_weight=Text.BOLD,
                color=Color.ACCENT,
                alignment=Text.LEFT if i == 0 else Text.RIGHT,
            ) for i, header in enumerate(headers)
        ]),
        Hr(
            width='100%',
            height=1,
            color=Color.PRIMARY,
            dash=[3],
            margin=Rect([3, 0, 3, 0]),
        ),
        *[
            Row(width='100%').add(*[
                Item(
                    width=widths[i],
                    text=k if i == 0 else fmt_pct(
                        list(d_v.items())[i - 1][1],
                        pts=2,
                    ),
                    index=i,
                    padding=Rect(row_seperator_padding),
                ) for i in range(NUM_COLS)
            ]) for k, d_v in rows.items()
        ],
        *[
            Row(width='100%').add(*[
                Item(
                    width=widths[i],
                    text=' ',
                    index=i,
                    padding=Rect(row_seperator_padding),
                ) for i in range(NUM_COLS)
            ]) for v in range(NUM_ROWS - len(rows))
        ],
        Text(width='100%',
             text=boil('typologies_cbs_footer'),
             font_family="Roboto Light",
             font_size=6,
             alignment=Text.RIGHT,
             color=Color.DARK_GRAY,
             padding=Rect([0, 0, 10, 0])),
    )
示例#13
0
def Trainings(data):
    short = data['short']
    vocational = data['vocational']

    short_training = [
        {'value': short['reached'], 'color': Color.ACCENT},
        {'value': _calc_reached(short['reqd'], short['reached']), 'color': Color.GRAY},
    ]
    vocational_training = [
        {'value': vocational['reached'], 'color': Color.ACCENT},
        {'value': _calc_reached(vocational['reqd'], vocational['reached']), 'color': Color.GRAY},
    ]

    items = [
        {'label': boil('training_reached'), 'color': Color.ACCENT},
        {'label': boil('training_remaining'), 'color': Color.GRAY},
    ]

    return Column(
        width='100%',
        height='100%',
        padding=Rect([10, 10, 4, 10]),
    ).add(
        Text(
            height=13,
            text=boil('training_sub_title'),
            color=Color.PRIMARY,
            font_family='Roboto Condensed',
            font_size=8,
            font_weight=Pango.Weight.BOLD,
        ),
        Row(width='100%', height='100% - 32', padding=Rect(4)).add(
            Canvas(
                width='50%',
                height='100%',
                renderer=PieChart(
                    items=short_training,
                    label=boil('training_short_training'),
                )
            ),
            Canvas(
                width='50%',
                height='100%',
                renderer=PieChart(
                    items=vocational_training,
                    label=boil('training_vocational_training'),
                )
            ),
        ),
        Row(
            width='100%',
            height=16,
            justify='center',
            align='center',
        ).add(
            *[
                Label(
                    label=item['label'],
                    color=item['color'],
                ) for item in items
            ]
        ),
    )