Mercurial > libervia-desktop-kivy
view libervia/desktop_kivy/plugins/plugin_wid_settings.py @ 494:a4a5565e7026
doc (README): move to README.md to use Markdown, and update content
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 28 Aug 2023 17:09:15 +0200 |
parents | b3cedbee561d |
children |
line wrap: on
line source
#!/usr/bin/env python3 #Libervia Desktop-Kivy # Copyright (C) 2016-2021 Jérôme Poisson (goffi@goffi.org) # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from libervia.backend.core import log as logging from libervia.backend.core.i18n import _ from libervia.backend.core.constants import Const as C from libervia.backend.tools.common import data_format from libervia.frontends.quick_frontend import quick_widgets from kivy.uix.label import Label from kivy.uix.widget import Widget from libervia.desktop_kivy.core import cagou_widget from libervia.desktop_kivy import G log = logging.getLogger(__name__) PLUGIN_INFO = { "name": _("settings"), "main": "LiberviaDesktopKivySettings", "description": _("LiberviaDesktopKivy/SàT settings"), "icon_symbol": "wrench", } class LiberviaDesktopKivySettings(quick_widgets.QuickWidget, cagou_widget.LiberviaDesktopKivyWidget): # XXX: this class can't be called "Settings", because Kivy has already a class # of this name, and the kv there would apply def __init__(self, host, target, profiles): quick_widgets.QuickWidget.__init__(self, G.host, target, profiles) cagou_widget.LiberviaDesktopKivyWidget.__init__(self) # the Widget() avoid LiberviaDesktopKivyWidget header to be down at the beginning # then up when the UI is loaded self.loading_widget = Widget() self.add_widget(self.loading_widget) extra = {} G.local_platform.update_params_extra(extra) G.host.bridge.param_ui_get( -1, C.APP_NAME, data_format.serialise(extra), self.profile, callback=self.get_params_ui_cb, errback=self.get_params_ui_eb) def change_widget(self, widget): self.clear_widgets([self.loading_widget]) del self.loading_widget self.add_widget(widget) def get_params_ui_cb(self, xmlui): G.host.action_manager({"xmlui": xmlui}, ui_show_cb=self.change_widget, profile=self.profile) def get_params_ui_eb(self, failure): self.change_widget(Label( text=_("Can't load parameters!"), bold=True, color=(1,0,0,1))) G.host.show_dialog("Can't load params UI", str(failure), "error")