Save current widget as.
558261
def save_current_as(self):
        
        if not self.current_widget():
            return
        mem = self.current_widget().file.path
        self.current_widget().file._path = None
        self.current_widget().file._old_path = mem
        CodeEditTabWidget.default_directory = os.path.dirname(mem)
        widget = self.current_widget()
        try:
            success = self.main_tab_widget.save_widget(widget)
        except Exception as e:
            QtWidgets.QMessageBox.warning(
                self, _('Failed to save file as'),
                _('Failed to save file as %s\nError=%s') % (
                    widget.file.path, str(e)))
            widget.file._path = mem
        else:
            if not success:
                widget.file._path = mem
            else:
                CodeEditTabWidget.default_directory = os.path.expanduser('~')
                self.document_saved.emit(widget.file.path, '')

                # rename tab
                tw = widget.parent_tab_widget
                tw.setTabText(tw.indexOf(widget),
                              os.path.split(widget.file.path)[1])

        return self.current_widget().file.path
753164
def _update_widgets(self):
        ''

        self._time_sensitive = any(getattr(w, 'TIME_SENSITIVE', False)
                                    for w in self.widgets)
1033005
def save_form(self, form, **kwargs):
        """"""

        obj = form.save(commit=False)
        change = obj.pk is not None
        self.save_obj(obj, form, change)
        if hasattr(form, 'save_m2m'):
            form.save_m2m()
        return obj
947140
def save_current_config(self, ):
        
        # check if all configs validate correctly
        btn = None
        for row in range(self.inimodel.rowCount()):
            i = self.inimodel.index(row, 0)
            r = self.inimodel.validate(i)
            if r is not True:
                btn = self.invalid_prompt()
                break

        if btn == QtGui.QMessageBox.Cancel:
            return
        current = self.files_lv.currentIndex()
        c = self.inimodel.data(current, self.inimodel.confobjRole)
        c.write()
        self.inimodel.set_index_edited(current, False)
71132
def recordWidget(xparent, widget):
        
        # record a splitter
        if isinstance(widget, XSplitter):
            xwidget = ElementTree.SubElement(xparent, 'split')
            if ( widget.orientation() == Qt.Horizontal ):
                xwidget.set('orient', 'horizontal')
            else:
                xwidget.set('orient', 'vertical')
            
            xwidget.set('state', nativestring(widget.saveState().toBase64()))
            
            # record sub-widgets
            for i in range(widget.count()):
                XViewProfile.recordWidget(xwidget, widget.widget(i))
        
        # record a view panel
        elif isinstance(widget, XViewPanel):
            xwidget = ElementTree.SubElement(xparent, 'panel')
            xwidget.set('current', nativestring(widget.currentIndex()))
            xwidget.set('hideTabs', nativestring(widget.hideTabsWhenLocked()))
            for i in range(widget.count()):
                XViewProfile.recordWidget(xwidget, widget.widget(i))
        
        # record a view
        elif widget is not None:
            xwidget = ElementTree.SubElement(xparent, 'view')
            xwidget.set('name',  nativestring(widget.objectName()))
            xwidget.set('title', nativestring(widget.windowTitle()))
            xwidget.set('type',  nativestring(widget.viewTypeName()))
            xwidget.set('group', nativestring(widget.viewingGroup()))
            
            # store that this was the current widget
            if widget.isCurrent():
                xwidget.set('current', 'True')
            
            widget.saveXml(xwidget)
457370
def save_state(self, fname=None):
        """"""
        if not fname:
            date = datetime.datetime.now().strftime("%Y-%m-%dT%Hh%Mm%Ss")
            fname = date + "_energy_" + str(self.energy()) + ".state"
        with open(fname, "wb") as fh:
            pickle.dump(self.state, fh)
476199
protected function _saveAppWidgets(): void
    {
        $widgets = $this->_getAppWidgets();

        $found = [];
        foreach ($widgets as $widget) {
            $found[] = $widget['name'];

            // skip adding existing app widgets
            if ($this->exists(['AppWidgets.name' => $widget['name']])) {
                continue;
            }

            $entity = $this->newEntity();
            $entity = $this->patchEntity($entity, $widget);
            $this->save($entity);
        }

        // soft delete non-existing app widgets
        $this->trashAll(! empty($found) ? ['AppWidgets.name NOT IN' => $found] : []);
    }
348820
def save_config(self):
        
        self.set_option('recent_projects', self.recent_projects)
        self.set_option('expanded_state',
                        self.explorer.treewidget.get_expanded_state())
        self.set_option('scrollbar_position',
                        self.explorer.treewidget.get_scrollbar_position())
        if self.current_active_project and self.dockwidget:
            self.set_option('visible_if_project_open',
                            self.dockwidget.isVisible())
714173
def create_widget(self):
        
        d = self.declaration
        self.widget = RelativeLayout(self.get_context(), None, d.style)
87568
def create_widget(self):
        
        d = self.declaration
        self.widget = View(self.get_context(), None, d.style)
103878
def saveToObject(self):
        """"""
        details = self._component.auto_details()
        for field, widget in self.inputWidgets.items():
            self._component.set(field, widget.value())
        self.attributesSaved.emit(self._component.__class__.__name__, self._component.stateDict())
906628
def refresh_plugin(self):
        """"""
        nb = None
        if self.tabwidget.count():
            client = self.tabwidget.currentWidget()
            nb = client.notebookwidget
            nb.setFocus()
        else:
            nb = None
        self.update_notebook_actions()
1337839
def as_widget(self, widget=None, attrs=None, only_initial=False):
        
        attrs = attrs or {}
        attrs.update(self.form.get_widget_attrs(self))
        if hasattr(self.field, 'widget_css_classes'):
            css_classes = self.field.widget_css_classes
        else:
            css_classes = getattr(self.form, 'widget_css_classes', None)
        if css_classes:
            attrs.update({'class': css_classes})
        widget_classes = self.form.fields[self.name].widget.attrs.get('class', None)
        if widget_classes:
            if attrs.get('class', None):
                attrs['class'] += ' ' + widget_classes
            else:
                attrs.update({'class': widget_classes})
        return super(NgBoundField, self).as_widget(widget, attrs, only_initial)
176059
def create_widget(self):
        
        d = self.declaration
        self.widget = TextView(self.get_context(), None,
                               d.style or '@attr/textViewStyle')
565253
def create_widget(self):
        
        d = self.declaration
        self.widget = TextClock(self.get_context(), None, d.style)
284497
def _set_main_widget(self, widget, redraw):
        
        self.set_body(widget)
        self.reload_footer()
        if redraw:
            logger.debug("redraw main widget")
            self.refresh()
735011
def _on_wid_changed(self, wid):
        """"""
        if self._itsme: return
        self.update_model(self._get_idx_from_widget(wid))
        return