def get_display(self):
        outer_div = DivWdg()
        outer_div.add_class('new-order-title-entry-form')

        self.get_order_code_select_widget(outer_div)
        self.get_order_entry_widget(outer_div)
        self.get_title_select_widget(outer_div)
        self.get_title_entry_wdg(outer_div)
        self.get_platform_select_widget(outer_div)

        self.get_languages_widget(outer_div)
        self.get_territory_widget(outer_div)
        self.get_description_input_widget(outer_div)
        self.get_total_program_runtime_widget(outer_div)
        self.get_checkboxes_section(outer_div)

        submit_button = SubmitWdg('Submit')
        submit_button.add_behavior(self.submit_button_behavior())

        popup_button = ButtonWdg('Popup')
        popup_button.add_behavior({'css_class': 'popup_click', 'type': 'click_up', 'cbjs_action': 'spt.panel.load_popup("Test", "order_builder.OrderTitleEntryWdg", {});'})
        outer_div.add(popup_button)

        outer_div.add(submit_button)

        return outer_div
Esempio n. 2
0
    def get_js_popup(my):

        # Add in javascript logger console pop-up ...
        # This is particularly useful for being able to print out debug info in javascript when testing
        # and debugging in IE or in FF without Firebug (where console.log is not defined)
        #
        js_popup_id = "WebClientOutputLogPopupWdg"
        js_popup = PopupWdg(id=js_popup_id, allow_page_activity=True, width="630px")

        js_popup.add("TACTIC™ Web Client Output Log", "title")

        js_content_div = DivWdg()

        button = ButtonWdg("Clear")
        button.add_style("margin: 5 10")
        button.add_event("onclick", "$('spt_js_log_output_div').innerHTML = ''")
        js_content_div.add(button)
        js_content_div.add( HtmlElement.hr() )

        js_div = DivWdg(id="spt_js_log_output_div")
        js_div.add_style("background: #000000")
        js_div.add_style("font-family: Courier, Fixed, serif")
        js_div.add_style("font-size: 11px")
        js_div.add_style("padding: 3px")
        js_div.add_style("color: #929292")
        js_div.add_style("width: 600px")
        js_div.add_style("height: 400px")
        js_div.add_style("overflow: auto")

        # Get user preference for the Web Client Output Console logging level ...
        log_level = PrefSetting.get_value_by_key("js_logging_level")
        if not log_level:
            log_level = "WARNING"  # set js logging level to 'WARNING' as a default!
            PrefSetting.create("js_logging_level",log_level)

        js_div.set_attr("spt_log_level", log_level)
        js_content_div.add( js_div )

        js_popup.add( js_content_div, 'content' )

        return js_popup
Esempio n. 3
0
    def get_save_wdg(my):

        # add the popup
        popup = PopupWdg(id="save_search_wdg")
        popup.add("Save Search", "title")

        div = DivWdg()
        div.add("Save current search as: ")

        text = TextWdg("save_search_text")
        text.set_id("save_search_text")
        div.add(text)

        save_button = ButtonWdg("Save Search")
        behavior = {"type": "click", "mouse_btn": "LMB", "cbjs_action": "spt.dg_table.save_search_cbk(evt, bvr);"}
        save_button.add_behavior(behavior)

        cancel_button = ButtonWdg("Cancel")
        cancel_button.add_event("onclick", "$('save_search_wdg').style.display = 'none'")

        div.add(HtmlElement.hr())
        button_div = DivWdg()
        button_div.add_style("text-align: center")
        button_div.add(save_button)
        button_div.add("  ")
        button_div.add(cancel_button)
        div.add(button_div)

        popup.add(div, "content")

        return popup
Esempio n. 4
0
    def get_save_wdg(self):

        div = DivWdg()
        div.add("Save current search as: ")

        text = TextWdg("save_search_text")
        text.set_id("save_search_text")
        div.add(text)



        save_button = ButtonWdg("Save Search")
        behavior = {
            'cbjs_action':  'spt.table.save_search();'
        }
        save_button.add_behavior( behavior )


        cancel_button = ButtonWdg("Cancel")
        cancel_button.add_event("onclick", "$('save_search_wdg').style.display = 'none'")

        div.add(HtmlElement.hr())
        button_div = DivWdg()
        button_div.add_style("text-align: center")
        button_div.add(save_button)
        button_div.add("  ")
        button_div.add(cancel_button)
        div.add(button_div)

        return div
Esempio n. 5
0
    def get_display(self):
        if self.redirect:
            return self.redirect.get_display()


        self.add_class("spt_button_top")
        # no need to define top
        #self.add(top)

        self.add_style("margin: 0px 3px", override=False)

        opacity = self.kwargs.get("opacity")
        if not opacity:
            opacity = 1.0 
        self.add_style("opacity: %s" % opacity)

        base = "%s/%s" % (BASE, self.get_theme() )

        self.add(self.table)
        td = self.td
        td.add_style("text-align: center")

        size = self.kwargs.get("size")
        if not size:
            size = 'medium'
        size = size[:1]


        width = self.kwargs.get("width")
        if width:
            top_width = int(width)
            self.add_style("width: %s"%top_width)
        else:
            top_width = 40
            if size == 'm':
                top_width = 83
                self.add_style("width: %spx"%top_width)
            if size == 'l':
                top_width = 127
                self.add_style("width: %spx"%top_width)
            if size == 'b':
                top_width = "100%"
                self.add_style("width: %spx"%top_width)
                self.table.add_style("width: 100%")


        



        #request_top_wdg = Container.get("request_top_wdg")
        #if not request_top_wdg:
        #    request_top_wdg = self.table
        request_top_wdg = self.table

        try:
            button_bvr = request_top_wdg.has_class("spt_button_behaviors")
            if not button_bvr:
                self.add_top_behaviors(request_top_wdg)
                request_top_wdg.add_class("spt_button_behaviors")
        except Exception as e:
            print "WARNING: ", e


        title = self.kwargs.get("title")
        if not title:
            title = "No Title"

        # stretch it wider in case the text is longer, 
        # don't make it too long though
        if len(title) > 10:
            width = len(title)/8.0 * 60
            if width < top_width:
                width = top_width
            td.add_style('width', width)
            td.add_style('height', '28px')
        if not title:
            title = "(No title)"

        #title = "Search"
        tip = self.kwargs.get("tip")
        if not tip:
            tip = title
        self.add_attr("title", tip)

        
        title2 = self.kwargs.get("title2")
        if title2:
            td.add_behavior( {
            'type': 'click_up',
            'title1': title,
            'title2': title2,
            'cbjs_action': '''
            var label_el = bvr.src_el.getElement(".spt_label");
            var label1 = bvr.title1;
            var label2 = bvr.title2;
            if (label_el.value == label1) {
                label_el.value = label2;
            }
            else {
                label_el.value = label1;
            }
            '''
            } )


        from pyasm.widget import ButtonWdg
        button = ButtonWdg()
        button.add_style("width: %s" % top_width)
        button.add_class('spt_label')

        icon = self.kwargs.get("icon")
        if icon:
            icon_div = DivWdg() 
            icon = IconWdg(title, icon, width=16 )
            icon_div.add(icon)
            button.add(icon_div)
            self.table.add_style("position: relative")
            icon_div.add_style("position: absolute")
            icon_div.add_style("left: 5px")
            icon_div.add_style("top: 6px")
            title = " &nbsp; &nbsp; %s" % title
            button.add_style("padding: 2px")

        button.set_name(title)

        td.add(button)
        #button.add_border()
        #button.set_box_shadow("0px 0px 1px", color=button.get_color("shadow"))



        if self.browser == 'Qt' and os.name != 'nt':
            button.add_style("top: 8px")
        else:
            button.add_style("top: 6px")

        # BOOTSTRAP
        color = self.kwargs.get("color")
        button.add_class('btn')
        if color:
            if color.startswith("#"):
                button.add_style("background", color)
            else:
                button.add_class('btn-%s' % color)
        else:
            button.add_class('btn-default')

        if size == 'b':
            button.add_class('btn-block')
        else:
            button.add_class('btn-sm')
        button.add_style("top: 0px")


        button.add_attr('spt_text_label', title)
        td.add_class("spt_action_button_hit")
        button.add_class("hand")

        return super(ActionButtonWdg,self).get_display()
Esempio n. 6
0
            print "WARNING: ", e
            configs = []
        except:
            my.clear_search_data(my.search_type)
            raise
        views = SObject.get_values(configs, "view")

        select = SelectWdg("saved_search")
        select.set_id("saved_search")
        select.add_empty_option("-- Select --")
        #select.set_option("query", "config/widget_config|view|view")
        select.set_option("values", views)
        #select.set_option("query_filter", "\"view\" like 'saved_search:%'")
        div.add(select)

        retrieve_button = ButtonWdg("Retrieve Search")
        behavior = {
            'type':         'click',
            'cbjs_action':  'spt.dg_table.retrieve_search_cbk(evt, bvr);'
        }
        retrieve_button.add_behavior( behavior )



        cancel_button = ButtonWdg("Cancel")
        cancel_button.add_event("onclick", "$('retrieve_search_wdg').style.display = 'none'")

        div.add(HtmlElement.hr())
        button_div = DivWdg()
        button_div.add_style("text-align: center")
        button_div.add(retrieve_button)
    def get_title_entry_wdg(outer_div):
        add_order_button = ButtonWdg('New Title')
        add_order_button.set_behavior({'css_class': 'popup_click', 'type': 'click_up', 'cbjs_action': 'spt.panel.load_popup("New Title", "order_builder.TitleEntryPopupWdg", {});'})

        outer_div.add(add_order_button)
    def get_order_entry_widget(outer_div):
        add_order_button = ButtonWdg('New Order')
        add_order_button.set_behavior({'css_class': 'popup_click', 'type': 'click_up', 'cbjs_action': 'spt.panel.load_popup("New Order", "order_builder.OrderEntryWdg", {});'})

        outer_div.add(add_order_button)
    def get_display(my):
        div = DivWdg()

        table = Table()
        div.add(table)
        table.add_row()

        if my.title:
            title_div = DivWdg()

            table.add_cell(title_div)

            name = "Ym"

            title = my.title
            if not title:
                title = name
            title = Common.get_display_title(title)
            title_div.add("%s:" % title )
            title_div.add_style("width: 80px")
            title_div.add_style("font-weight: bold")
            title_div.add_style("margin-left: 15px")
            title_div.add_style("padding-top: 2px")

        td = table.add_cell()
        start_date = DivWdg("Start Date")
        td.add(start_date)
        start_date.add_style("margin-left: 5px")
        #td = table.add_cell()
        #op = DivWdg(" between&nbsp;&nbsp;&nbsp;")
        #op.add_style("margin-left: 5px")
        #td.add(op)

        from tactic.ui.widget import CalendarInputWdg
        td = table.add_cell()
        cal1 = CalendarInputWdg("start_date")
        td.add(cal1)

        table.add_row()
        end_date = DivWdg("End Date")
        end_date.add_style("margin-left: 5px")
        td = table.add_cell()
        td.add(end_date)
        #td.add(spacing)

        td = table.add_cell()
        cal2 = CalendarInputWdg("end_date")
        td.add(cal2)

        table.add_row()
        td = table.add_cell()

        from pyasm.widget import ButtonWdg
        button = ButtonWdg()
        #button.add_style("width: %s" % top_width)
        button.add_class('spt_label')

        icon = my.kwargs.get("icon")
        if icon:
            icon_div = DivWdg()
            icon = IconWdg(title, icon, width=16 )
            icon_div.add(icon)
            button.add(icon_div)
            my.table.add_style("position: relative")
            icon_div.add_style("position: absolute")
            icon_div.add_style("left: 5px")
            icon_div.add_style("top: 6px")
            title = " &nbsp; &nbsp; %s" % title
            button.add_style("padding: 2px")

        button.set_name("Reload")

        td.add(button)

        return div
    def get_display(my):

        top = my.top

        #top.add_gradient("background", "background", 5, -20)
        top.add_color("background", "background", -5)
        #top.add_style("padding-top: 10px")

        #title = "Sample Chart"
        title = my.kwargs.get("title")
        if title:
            date = "@FORMAT(@STRING($TODAY),'Dec 31, 1999')"
            date = Search.eval(date, single=True)

            title_wdg = DivWdg()
            top.add(title_wdg)
            title_wdg.add(title)
            title_wdg.add(" [%s]" % date)
            title_wdg.add_style("font-size: 1.1em")
            title_wdg.add_color("background", "background3")
            title_wdg.add_color("color", "color3")
            title_wdg.add_style("padding: 10px")
            title_wdg.add_style("font-weight: bold")
            title_wdg.add_style("text-align: center")

        colors = [
            'rgba(255,0,0,0.5)',
            'rgba(0,255,0,0.5)',
            'rgba(0,0,255,0.5)',
            'rgba(128,0,255,0.5)',
            'rgba(0,128,255,0.5)',
            'rgba(255,0,255,0.5)',
        ]

        # draw a legend
        legend = None
        from chart2_wdg import ChartLegend

        #import pdb; pdb.set_trace();

        labels = my.kwargs.get("labels")
        my.user = my.kwargs.get("user")

        if labels:
            legend = ChartLegend()
            labels = labels.split("|")
            legend.set_labels(labels)
            top.add(legend)
            legend.add_style("width: %s" % str(len(labels)*200))
            legend.add_style("margin-left: auto")
            legend.add_style("margin-right: auto")

            #legend.add_style("width: 200px")
            #legend.add_style("position: absolute")
            #legend.add_style("top: 40px")
            #legend.add_style("left: 300px")


        if legend:
            legend.set_colors(colors)


        #############
        # table for start-end date
        search_table = Table()
        search_table.add_style("margin-left: auto")
        search_table.add_style("margin-right: auto")
        search_table.add_style("margin-top: 35px")
        search_table.add_style("margin-bottom: 45px")
        top.add(search_table)
 
        search_table.add_row()

        td = search_table.add_cell()
        start_date = DivWdg("Start Date")
        td.add(start_date)
        start_date.add_style("margin-left: 5px")
        #td = table.add_cell()
        #op = DivWdg(" between&nbsp;&nbsp;&nbsp;")
        #op.add_style("margin-left: 5px")
        #td.add(op)

        from tactic.ui.widget import CalendarInputWdg
        td = search_table.add_cell()
        cal1 = CalendarInputWdg("start_date")
        td.add(cal1)

        search_table.add_row()
        end_date = DivWdg("End Date")
        end_date.add_style("margin-left: 5px")
        td = search_table.add_cell()
        td.add(end_date)
        #td.add(spacing)

        td = search_table.add_cell()
        cal2 = CalendarInputWdg("end_date")
        td.add(cal2)

        search_table.add_row()
        td = search_table.add_cell()

        from pyasm.widget import ButtonWdg
        button = ButtonWdg()
        #button.add_style("width: %s" % top_width)
        button.add_class('spt_label')

        icon = my.kwargs.get("icon")
        if icon:
            icon_div = DivWdg()
            icon = IconWdg(title, icon, width=16 )
            icon_div.add(icon)
            button.add(icon_div)
            my.table.add_style("position: relative")
            icon_div.add_style("position: absolute")
            icon_div.add_style("left: 5px")
            icon_div.add_style("top: 6px")
            title = " &nbsp; &nbsp; %s" % title
            button.add_style("padding: 2px")

        button.set_name("Reload")

        td.add(button)
        #############


        task_data = my.get_task_data()
        
        labels = [label[0] for label in task_data.get(task_data.keys()[0])]

        #labels = ['chr001', 'chr002', 'chr003', 'chr004', 'prop001', 'prop002', 'cow001']
        #labels = ['week 1', 'week 2', 'week 3', 'week 4', 'week 5', 'week 6', 'week 7', 'week 8']
        #values = [1,2,4,5,6,7,8]
        values = [i+1 for i in range(len(labels))]

        width = my.kwargs.get("width")
        if not width:
            width = '1600px'
        height = my.kwargs.get("height")
        if not height:
            height = '1000px'


        chart_div = DivWdg()
        top.add(chart_div)
        chart_div.add_style("text-align: center")

        chart = ChartWdg(
            height=height,
            width=width,
            chart_type='bar',
            labels=labels
        )
        chart_div.add(chart)

        data = ChartData(
            color=colors[0], #"rgba(255, 0, 0, 1.0)",
            #data=[task_data['Pending'], 5.5, 7.5, 14.3, 10.2, 1.1, 3.3],
            data = [data[1] for data in task_data.get('Pending')]
        )
        chart.add(data)

        data = ChartData(
            color=colors[1], #"rgba(0, 255, 0, 1.0)",
            #data=[task_data['Assignment'], 4.3, 8.4, 6.2, 8.4, 2.2],
            data = [data[1] for data in task_data.get('Assignment')]
        )
        chart.add(data)


        data = ChartData(
            color=colors[2], #"rgba(0, 0, 255, 1.0)",
            #data=[task_data['In Progress'], 3.5, 2.2, 6.6, 1.3, 9.4],
            data = [data[1] for data in task_data.get('In Progress')]
        )
        chart.add(data)


        #data = [task_data['Approved'], 17, 15.5, -3, 17, 16.8, 11.4]
        data = [data[1] for data in task_data.get('Approved')]
        data = ChartData(data=data, color=colors[3]) #"rgba(128, 0, 255, 1.0)")
        chart.add(data)


        data = [data[1] for data in task_data.get('Review')] 
        data = ChartData(data=data, color=colors[4]) #"rgba(0, 128, 255, 1.0)")
        chart.add(data)

        table = Table()
        table.add_color("color", "color")
        top.add(table)
        table.add_row()
        table.center()
        table.add_style("width: 1%")


        x_title = my.kwargs.get("x_title")
        y_title = my.kwargs.get("y_title")

        if y_title:
            y_title = y_title.replace(" ", "&nbsp;")

            y_axis_div = DivWdg()
            td = table.add_cell(y_axis_div)
            td.add_style("vertical-align: middle")
            td.add_style("width: 1%")
            y_axis_div.add(y_title)
            y_axis_div.add_style("-moz-transform: rotate(-90deg)")
            y_axis_div.add_style("-webkit-transform: rotate(-90deg)")
            y_axis_div.add_style("font-size: 1.33em")
            y_axis_div.add_style("height: 100%")
            y_axis_div.add_style("width: 30px")

        table.add_row()

        # add the x-axis title
        if x_title:
            x_title = x_title.replace(" ", "&nbsp;")

            x_axis_div = DivWdg()
            td = table.add_cell(x_axis_div)
            td.add_style("text-align: center")
            td.add_style("width: 1%")
            x_axis_div.add(x_title)
            x_axis_div.add_style("font-size: 1.33em")
            x_axis_div.add_style("width: 100%")
            x_axis_div.add_style("height: 30px")

        return top
Esempio n. 11
0
            print "WARNING: ", e
            configs = []
        except:
            my.clear_search_data(my.search_type)
            raise
        views = SObject.get_values(configs, "view")

        select = SelectWdg("saved_search")
        select.set_id("saved_search")
        select.add_empty_option("-- Select --")
        #select.set_option("query", "config/widget_config|view|view")
        select.set_option("values", views)
        #select.set_option("query_filter", "\"view\" like 'saved_search:%'")
        div.add(select)

        retrieve_button = ButtonWdg("Retrieve Search")
        behavior = {
            'type': 'click',
            'cbjs_action': 'spt.dg_table.retrieve_search_cbk(evt, bvr);'
        }
        retrieve_button.add_behavior(behavior)

        cancel_button = ButtonWdg("Cancel")
        cancel_button.add_event(
            "onclick", "$('retrieve_search_wdg').style.display = 'none'")

        div.add(HtmlElement.hr())
        button_div = DivWdg()
        button_div.add_style("text-align: center")
        button_div.add(retrieve_button)
        button_div.add("&nbsp;&nbsp;")
Esempio n. 12
0
class ActionButtonWdg(DivWdg):

    ARGS_KEYS = {
        'title': {
            'description': 'Value to show on actual button',
            'type': 'TextWdg',
            'order': 0,
            'category': 'Options'
        },
        'title2': {
            'description':
            'Alt Value to show on actual button when clicked on',
            'type': 'TextWdg',
            'order': 0,
            'category': 'Options'
        },
        'tip': {
            'description':
            'Tool tip info to show when mouse hovers over button',
            'type': 'TextWdg',
            'order': 1,
            'category': 'Options'
        },
        'action': {
            'description': 'Javascript callback',
            'type': 'TextAreaWdg',
            'order': 1,
            'category': 'Options'
        }
    }

    def __init__(my, **kwargs):
        web = WebContainer.get_web()
        is_Qt_OSX = web.is_Qt_OSX()
        my.browser = web.get_browser()

        #is_Qt_OSX = False
        if is_Qt_OSX:
            my.redirect = ActionButtonWdgOld(**kwargs)
        else:
            my.redirect = None

        #my.top = DivWdg()
        my.kwargs = kwargs
        my.text_wdg = DivWdg()
        my.table = Table()
        my.table.add_row()
        my.table.add_style("color", "#333")
        my.td = my.table.add_cell()
        my.td.add_class("spt_action_button")
        super(ActionButtonWdg, my).__init__()

    def add_behavior(my, behavior):
        if my.redirect:
            return my.redirect.add_behavior(behavior)

        my.td.add_behavior(behavior)

    def add_style(my, name, value=None, override=True):
        if my.redirect:
            return my.redirect.add_style(name, value, override=override)

        super(ActionButtonWdg, my).add_style(name, value, override=override)

    def add_class(my, value):
        if my.redirect:
            return my.redirect.add_class(value)

        super(ActionButtonWdg, my).add_class(value)

    def add_top_behaviors(my, top):
        if my.redirect:
            return my.redirect.add_top_behavior(top)

    def get_display(my):
        if my.redirect:
            return my.redirect.get_display()

        my.add_class("spt_button_top")
        # no need to define top
        #my.add(top)

        my.add_style("margin: 0px 3px", override=False)

        opacity = my.kwargs.get("opacity")
        if not opacity:
            opacity = 1.0
        my.add_style("opacity: %s" % opacity)

        base = "%s/%s" % (BASE, my.get_theme())

        my.add(my.table)
        td = my.td
        td.add_style("text-align: center")

        size = my.kwargs.get("size")
        if not size:
            size = 'medium'
        size = size[:1]

        width = my.kwargs.get("width")
        if width:
            top_width = int(width)
            my.add_style("width: %s" % top_width)
        else:
            top_width = 40
            if size == 'm':
                top_width = 83
                my.add_style("width: %spx" % top_width)
            if size == 'l':
                top_width = 127
                my.add_style("width: %spx" % top_width)

        #request_top_wdg = Container.get("request_top_wdg")
        #if not request_top_wdg:
        #    request_top_wdg = my.table
        request_top_wdg = my.table

        try:
            button_bvr = request_top_wdg.has_class("spt_button_behaviors")
            if not button_bvr:
                my.add_top_behaviors(request_top_wdg)
                request_top_wdg.add_class("spt_button_behaviors")
        except Exception, e:
            print "WARNING: ", e

        title = my.kwargs.get("title")
        if not title:
            title = "No Title"

        # stretch it wider in case the text is longer,
        # don't make it too long though
        if len(title) > 10:
            width = len(title) / 8.0 * 60
            if width < top_width:
                width = top_width
            td.add_style('width', width)
            td.add_style('height', '28px')
        if not title:
            title = "(No title)"

        #title = "Search"
        tip = my.kwargs.get("tip")
        if not tip:
            tip = title
        my.add_attr("title", tip)

        title2 = my.kwargs.get("title2")
        if title2:
            td.add_behavior({
                'type':
                'click_up',
                'title1':
                title,
                'title2':
                title2,
                'cbjs_action':
                '''
            var label_el = bvr.src_el.getElement(".spt_label");
            var label1 = "<b>" + bvr.title1 + "</b>";
            var label2 = "<b>" + bvr.title2 + "</b>";
            if (label_el.innerHTML == label1) {
                label_el.innerHTML = label2;
            }
            else {
                label_el.innerHTML = label1;
            }
            '''
            })

        from pyasm.widget import ButtonWdg
        button = ButtonWdg()
        button.add_style("width: %s" % top_width)
        button.add_class('spt_label')

        icon = my.kwargs.get("icon")
        if icon:
            icon_div = DivWdg()
            icon = IconWdg(title, icon, width=16)
            icon_div.add(icon)
            button.add(icon_div)
            my.table.add_style("position: relative")
            icon_div.add_style("position: absolute")
            icon_div.add_style("left: 5px")
            icon_div.add_style("top: 6px")
            title = " &nbsp; &nbsp; %s" % title
            button.add_style("padding: 2px")

        button.set_name(title)

        td.add(button)
        #button.add_border()
        #button.set_box_shadow("0px 0px 1px", color=button.get_color("shadow"))

        if my.browser == 'Qt' and os.name != 'nt':
            button.add_style("top: 8px")
        else:
            button.add_style("top: 6px")

        # BOOTSTRAP
        color = my.kwargs.get("color")
        button.add_class('btn')
        if color:
            if color.startswith("#"):
                button.add_style("background", color)
            else:
                button.add_class('btn-%s' % color)
        else:
            button.add_class('btn-default')
        button.add_class('btn-sm')
        button.add_style("top: 0px")

        button.add_attr('spt_text_label', title)
        td.add_class("spt_action_button_hit")
        button.add_class("hand")

        return super(ActionButtonWdg, my).get_display()
Esempio n. 13
0
    def get_display(self):
        if self.redirect:
            return self.redirect.get_display()

        self.add_class("spt_button_top")
        # no need to define top
        #self.add(top)

        self.add_style("margin: 0px 3px", override=False)

        opacity = self.kwargs.get("opacity")
        if not opacity:
            opacity = 1.0
        self.add_style("opacity: %s" % opacity)

        base = "%s/%s" % (BASE, self.get_theme())

        self.add(self.table)
        td = self.td
        td.add_style("text-align: center")

        size = self.kwargs.get("size")
        if not size:
            size = 'medium'
        size = size[:1]

        width = self.kwargs.get("width")
        if width:
            top_width = int(width)
            self.add_style("width: %s" % top_width)
        else:
            top_width = 40
            if size == 'm':
                top_width = 83
                self.add_style("width: %spx" % top_width)
            if size == 'l':
                top_width = 127
                self.add_style("width: %spx" % top_width)
            if size == 'b':
                top_width = "100%"
                self.add_style("width: %spx" % top_width)
                self.table.add_style("width: 100%")

        #request_top_wdg = Container.get("request_top_wdg")
        #if not request_top_wdg:
        #    request_top_wdg = self.table
        request_top_wdg = self.table

        try:
            button_bvr = request_top_wdg.has_class("spt_button_behaviors")
            if not button_bvr:
                self.add_top_behaviors(request_top_wdg)
                request_top_wdg.add_class("spt_button_behaviors")
        except Exception as e:
            print "WARNING: ", e

        title = self.kwargs.get("title")
        if not title:
            title = "No Title"

        # stretch it wider in case the text is longer,
        # don't make it too long though
        if len(title) > 10:
            width = len(title) / 8.0 * 60
            if width < top_width:
                width = top_width
            td.add_style('width', width)
            td.add_style('height', '28px')
        if not title:
            title = "(No title)"

        #title = "Search"
        tip = self.kwargs.get("tip")
        if not tip:
            tip = title
        self.add_attr("title", tip)

        title2 = self.kwargs.get("title2")
        if title2:
            td.add_behavior({
                'type':
                'click_up',
                'title1':
                title,
                'title2':
                title2,
                'cbjs_action':
                '''
            var label_el = bvr.src_el.getElement(".spt_label");
            var label1 = bvr.title1;
            var label2 = bvr.title2;
            if (label_el.value == label1) {
                label_el.value = label2;
            }
            else {
                label_el.value = label1;
            }
            '''
            })

        from pyasm.widget import ButtonWdg
        button = ButtonWdg()
        button.add_style("width: %s" % top_width)
        button.add_class('spt_label')

        icon = self.kwargs.get("icon")
        if icon:
            icon_div = DivWdg()
            icon = IconWdg(title, icon, width=16)
            icon_div.add(icon)
            button.add(icon_div)
            self.table.add_style("position: relative")
            icon_div.add_style("position: absolute")
            icon_div.add_style("left: 5px")
            icon_div.add_style("top: 6px")
            title = " &nbsp; &nbsp; %s" % title
            button.add_style("padding: 2px")

        button.set_name(title)

        td.add(button)
        #button.add_border()
        #button.set_box_shadow("0px 0px 1px", color=button.get_color("shadow"))

        if self.browser == 'Qt' and os.name != 'nt':
            button.add_style("top: 8px")
        else:
            button.add_style("top: 6px")

        # BOOTSTRAP
        color = self.kwargs.get("color")
        button.add_class('btn')
        if color:
            if color.startswith("#"):
                button.add_style("background", color)
            else:
                button.add_class('btn-%s' % color)
        else:
            button.add_class('btn-default')

        if size == 'b':
            button.add_class('btn-block')
        else:
            button.add_class('btn-sm')
        button.add_style("top: 0px")

        button.add_attr('spt_text_label', title)
        td.add_class("spt_action_button_hit")
        button.add_class("hand")

        return super(ActionButtonWdg, self).get_display()