Returns a LayoutSlice pointing to fields with widgets of `widget_type`
766371
def filter_by_widget(self, widget_type):
        
        self._check_layout_and_form()
        layout_field_names = self.layout.get_field_names()

        # Let's filter all fields with widgets like widget_type
        filtered_fields = []
        for pointer in layout_field_names:
            if isinstance(self.form.fields[pointer[1]].widget, widget_type):
                filtered_fields.append(pointer)

        return LayoutSlice(self.layout, filtered_fields)
823762
def render_layout(self, form, context, template_pack=TEMPLATE_PACK):
        
        # Writing the label values into the field placeholders.
        # This is done at rendering time, so the Form.__init__() could update any labels before.
        # Django 1.11 no longer lets EmailInput or URLInput inherit from TextInput,
        # so checking for `Input` instead while excluding `HiddenInput`.
        for field in form.fields.values():
            if field.label and \
                    isinstance(field.widget, (Input, forms.Textarea)) and \
                    not isinstance(field.widget, forms.HiddenInput):
                field.widget.attrs['placeholder'] = u"{0}:".format(field.label)

        return super(CompactLabelsCommentFormHelper, self).render_layout(form, context, template_pack=template_pack)
807354
def editors(self):
        
        lay = self.layout()
        return [lay.itemAt(i).widget() for i in range(lay.count())]
198314
def _setup_param_widgets(self):
        """"""

        for parameter in self.csv_params:
            pname, ptype, plabel, phelp = parameter

            label = wx.StaticText(self.parent, -1, plabel)
            widget = self.type2widget[ptype](self.parent)

            # Append choicebox items and bind handler
            if pname in self.choices:
                widget.AppendItems(self.choices[pname])
                widget.SetValue = widget.Select
                widget.SetSelection(0)

            # Bind event handler to widget
            if ptype is types.StringType or ptype is types.UnicodeType:
                event_type = wx.EVT_TEXT
            elif ptype is types.BooleanType:
                event_type = wx.EVT_CHECKBOX
            else:
                event_type = wx.EVT_CHOICE

            handler = getattr(self, self.widget_handlers[pname])
            self.parent.Bind(event_type, handler, widget)

            # Tool tips
            label.SetToolTipString(phelp)
            widget.SetToolTipString(phelp)

            label.__name__ = wx.StaticText.__name__.lower()
            widget.__name__ = self.type2widget[ptype].__name__.lower()

            self.param_labels.append(label)
            self.param_widgets.append(widget)

            self.__setattr__("_".join([label.__name__, pname]), label)
            self.__setattr__("_".join([widget.__name__, pname]), widget)
759090
def _grid_widgets(self):
        
        self._family_dropdown.grid(row=0, column=0, sticky="nswe")
        self._size_dropdown.grid(row=0, column=1, sticky="nswe")
        self._properties_frame.grid(row=0, column=2, sticky="nswe")
104192
def grid_widgets(self):
        
        # Categories
        for index, label in enumerate(self._category_labels.values()):
            label.grid(column=0, row=index, padx=5, sticky="nw", pady=(1, 0) if index == 0 else 0)
        # Canvas widgets
        self._canvas_scroll.grid(column=1, row=0, padx=(0, 5), pady=5, sticky="nswe")
        self._canvas_ticks.grid(column=1, row=1, padx=(0, 5), pady=(0, 5), sticky="nswe")
        self._scrollbar_timeline.grid(column=1, row=2, padx=(0, 5), pady=(0, 5), sticky="we")
        # Zoom widgets
        self._button_zoom_in.grid(row=0, column=0, pady=5, sticky="nswe")
        self._button_zoom_out.grid(row=1, column=0, pady=(0, 5), sticky="nswe")
        self._button_zoom_reset.grid(row=2, column=0, pady=(0, 5), sticky="nswe")
        # Frames
        self._canvas_categories.grid(column=0, row=0, padx=5, pady=5, sticky="nswe")
        self._scrollbar_vertical.grid(column=2, row=0, pady=5, padx=(0, 5), sticky="ns")
        self._frame_zoom.grid(column=3, row=0, rowspan=2, padx=(0, 5), pady=5, sticky="nswe")
439470
def formfield(self, **kwargs):
        
        widget_kwargs = {
            'lat_field': self.latitude_field_name,
            'lon_field': self.longitude_field_name,
        }

        if self.data_field_name:
            widget_kwargs['data_field'] = self.data_field_name

        defaults = {
            'form_class': OSMFormField,
            'widget': OSMWidget(**widget_kwargs),
        }
        defaults.update(kwargs)

        return super(OSMField, self).formfield(**defaults)
1072597
def convert_widgets(self):
        
        warnings.warn("Will be removed after dropping support for Django-1.10", PendingDeprecationWarning)
        widgets_module = getattr(self, 'widgets_module', 'djng.widgets')
        for field in self.base_fields.values():
            if hasattr(field, 'get_converted_widget'):
                new_widget = field.get_converted_widget(widgets_module)
                if new_widget:
                    field.widget = new_widget
71148
def format_output(self, rendered_widgets):
        
        ret = [u'<ul class="formfield">']
        for i, field in enumerate(self.fields):
            label = self.format_label(field, i)
            help_text = self.format_help_text(field, i)
            ret.append(u'<li>%s %s %s</li>' % (
                label, rendered_widgets[i], field.help_text and help_text))

        ret.append(u'</ul>')
        return ''.join(ret)
458681
def get_input_widget(self, fieldname, arnum=0, **kw):
        

        # temporary AR Context
        context = self.get_ar()
        # request = self.request
        schema = context.Schema()

        # get original field in the schema from the base_fieldname
        base_fieldname = fieldname.split("-")[0]
        field = context.getField(base_fieldname)

        # fieldname with -<arnum> suffix
        new_fieldname = self.get_fieldname(field, arnum)
        new_field = field.copy(name=new_fieldname)

        # get the default value for this field
        fieldvalues = self.fieldvalues
        field_value = fieldvalues.get(new_fieldname)
        # request_value = request.form.get(new_fieldname)
        # value = request_value or field_value
        value = field_value

        def getAccessor(instance):
            def accessor(**kw):
                return value
            return accessor

        # inject the new context for the widget renderer
        # see: Products.Archetypes.Renderer.render
        kw["here"] = context
        kw["context"] = context
        kw["fieldName"] = new_fieldname

        # make the field available with this name
        # XXX: This is a hack to make the widget available in the template
        schema._fields[new_fieldname] = new_field
        new_field.getAccessor = getAccessor

        # set the default value
        form = dict()
        form[new_fieldname] = value
        self.request.form.update(form)
        logger.info("get_input_widget: fieldname={} arnum={} "
                    "-> new_fieldname={} value={}".format(
                        fieldname, arnum, new_fieldname, value))
        widget = context.widget(new_fieldname, **kw)
        return widget
511494
def _get_related_views_widgets(
        self, item, orders=None, pages=None, page_sizes=None, widgets=None, **args
    ):
        
        widgets = widgets or {}
        widgets["related_views"] = []
        for view in self._related_views:
            if orders.get(view.__class__.__name__):
                order_column, order_direction = orders.get(view.__class__.__name__)
            else:
                order_column, order_direction = "", ""
            widgets["related_views"].append(
                self._get_related_view_widget(
                    item,
                    view,
                    order_column,
                    order_direction,
                    page=pages.get(view.__class__.__name__),
                    page_size=page_sizes.get(view.__class__.__name__),
                )
            )
        return widgets
228406
def build_layout(self, dset_id: str):
        
        all_fields = list(self.get_data(dset_id=dset_id).keys())

        try:
            field_reference = self.skd[dset_id].attrs('target')
        except:
            field_reference = all_fields[0]

        fields_comparison = [all_fields[1]]

        # chart type widget
        self.register_widget(
            chart_type=widgets.RadioButtons(
                options=['individual', 'grouped'],
                value='individual',
                description='Chart Type:'
            )
        )

        # bins widget
        self.register_widget(
            bins=IntSlider(
                description='Bins:',
                min=2, max=10, value=2,
                continuous_update=False
            )
        )

        # fields comparison widget
        self.register_widget(
            xs=widgets.SelectMultiple(
                description='Xs:',
                options=[f for f in all_fields if not f == field_reference],
                value=fields_comparison
            )
        )

        # field reference widget
        self.register_widget(
            y=widgets.Dropdown(
                description='Y:',
                options=all_fields,
                value=field_reference
            )
        )
        # used to internal flow control
        y_changed = [False]

        self.register_widget(
            box_filter_panel=widgets.VBox([
                self._('y'), self._('xs'), self._('bins')
            ])
        )

        # layout widgets
        self.register_widget(
            table=widgets.HTML(),
            chart=widgets.HTML()
        )

        self.register_widget(vbox_chart=widgets.VBox([
            self._('chart_type'), self._('chart')
        ]))

        self.register_widget(
            tab=widgets.Tab(
                children=[
                    self._('box_filter_panel'),
                    self._('table'),
                    self._('vbox_chart')
                ]
            )
        )

        self.register_widget(dashboard=widgets.HBox([self._('tab')]))

        # observe hooks
        def w_y_change(change: dict):
            """
            When y field was changed xs field should be updated and data table
            and chart should be displayed/updated.

            :param change:
            :return:
            """
            # remove reference field from the comparison field list
            _xs = [
                f for f in all_fields
                if not f == change['new']
            ]

            y_changed[0] = True  # flow control variable
            _xs_value = list(self._('xs').value)

            if change['new'] in self._('xs').value:
                _xs_value.pop(_xs_value.index(change['new']))
                if not _xs_value:
                    _xs_value = [_xs[0]]

            self._('xs').options = _xs
            self._('xs').value = _xs_value

            self._display_result(y=change['new'], dset_id=dset_id)

            y_changed[0] = False  # flow control variable

        # widgets registration

        # change tab settings
        self._('tab').set_title(0, 'Filter')
        self._('tab').set_title(1, 'Data')
        self._('tab').set_title(2, 'Chart')

        # data panel
        self._('table').value = '...'

        # chart panel
        self._('chart').value = '...'

        # create observe callbacks
        self._('bins').observe(
            lambda change: (
                self._display_result(bins=change['new'], dset_id=dset_id)
            ), 'value'
        )
        self._('y').observe(w_y_change, 'value')
        # execute display result if 'y' was not changing.
        self._('xs').observe(
            lambda change: (
                self._display_result(xs=change['new'], dset_id=dset_id)
                if not y_changed[0] else None
            ), 'value'
        )
        self._('chart_type').observe(
            lambda change: (
                self._display_result(chart_type=change['new'], dset_id=dset_id)
            ), 'value'
        )
998312
def get_matplotlib_layout(widget, flag_toolbar=True):
    
    fig = plt.figure()
    canvas = FigureCanvas(fig)
    #        self.canvas.mpl_connect('button_press_event', self.on_plot_click)
    layout = QVBoxLayout(widget)
    if flag_toolbar:
        toolbar = NavigationToolbar2QT(canvas, widget)
        layout.addWidget(toolbar)
    layout.addWidget(canvas)
    a99.set_margin(layout, 0)

    return fig, canvas, layout
1052503
def get_layout_settings(self):
        """"""
        splitsettings = self.editorwidget.editorsplitter.get_layout_settings()
        return dict(size=(self.window_size.width(), self.window_size.height()),
                    pos=(self.pos().x(), self.pos().y()),
                    is_maximized=self.isMaximized(),
                    is_fullscreen=self.isFullScreen(),
                    hexstate=qbytearray_to_str(self.saveState()),
                    splitsettings=splitsettings)
707738
def get_widgets(self):
        
        widgets = OrderedDict()
        mappings = {}
        for dim in self.mock_obj.kdims:
            holomap = None if self.plot.dynamic else self.mock_obj
            widget, label, mapping = self.create_widget(dim, holomap, self.editable)
            if label is not None and not isinstance(label, Div):
                label.on_change('value', partial(self.on_change, dim, 'label'))
            widget.on_change('value', partial(self.on_change, dim, 'widget'))
            widgets[dim.pprint_label] = (label, widget)
            if mapping:
                mappings[dim.pprint_label] = OrderedDict(mapping)
        return widgets, mappings
850542
def get_custom_layouts_active_label(self):
        

        layout_active_label = Active_QLabel(self,
                                            QPixmap(umbra.ui.common.get_resource_path(UiConstants.custom_layouts_icon)),
                                            QPixmap(
                                                umbra.ui.common.get_resource_path(
                                                    UiConstants.custom_layouts_hover_icon)),
                                            QPixmap(umbra.ui.common.get_resource_path(
                                                UiConstants.custom_layouts_active_icon)))
        layout_active_label.setObjectName("Custom_Layouts_active_label")

        self.__custom_layouts_menu = QMenu("Layouts", layout_active_label)

        for layout in self.__user_layouts:
            self.__container.layouts_manager.register_layout(layout.identity, layout)
            self.__custom_layouts_menu.addAction(self.__container.actions_manager.register_action(
                "Actions|Umbra|ToolBar|Layouts|Restore layout {0}".format(layout.name),
                shortcut=layout.shortcut,
                slot=functools.partial(self.__container.layouts_manager.restore_layout, layout.identity)))

        self.__custom_layouts_menu.addSeparator()

        for layout in self.__user_layouts:
            self.__custom_layouts_menu.addAction(self.__container.actions_manager.register_action(
                "Actions|Umbra|ToolBar|Layouts|Store layout {0}".format(layout.name),
                shortcut=Qt.CTRL + layout.shortcut,
                slot=functools.partial(self.__container.layouts_manager.store_layout, layout.identity)))

        self.__custom_layouts_menu.addSeparator()

        self.__custom_layouts_menu.addAction(self.__container.actions_manager.register_action(
            "Actions|Umbra|ToolBar|Layouts|Toggle FullScreen",
            shortcut=Qt.ControlModifier + Qt.SHIFT + Qt.Key_F,
            slot=self.__container.toggle_full_screen))

        layout_active_label.set_menu(self.__custom_layouts_menu)
        return layout_active_label
1180739
def as_crispy_field(field, template_pack=TEMPLATE_PACK, label_class="", field_class=""):
    
    if not isinstance(field, forms.BoundField) and settings.DEBUG:
        raise CrispyError('|as_crispy_field got passed an invalid or inexistent field')

    attributes = {
        'field': field,
        'form_show_errors': True,
        'form_show_labels': True,
        'label_class': label_class,
        'field_class': field_class,
    }
    helper = getattr(field.form, 'helper', None)

    template_path = None
    if helper is not None:
        attributes.update(helper.get_attributes(template_pack))
        template_path = helper.field_template
    if not template_path:
        template_path = '%s/field.html' % template_pack
    template = get_template(template_path)

    c = Context(attributes).flatten()
    return template.render(c)