예제 #1
0
    def on_widget_select_pressed(self, *args):
        '''Event handler to playground widget selector press
        '''
        widgets = get_current_project().app_widgets
        app_widgets = []
        for name in widgets.keys():
            widget = widgets[name]
            if widget.is_root:
                name = 'Root - ' + name
            app_widgets.append(name)

        fake_setting = FakeSettingList()
        fake_setting.allow_custom = False
        fake_setting.items = app_widgets
        fake_setting.desc = 'Select the Widget to edit on Playground'
        fake_setting.group = 'playground_widget'

        content = SettingListContent(setting=fake_setting)
        popup_width = min(0.95 * Window.width, 500)
        popup_height = min(0.95 * Window.height, 500)
        self._popup = popup = Popup(content=content,
                                    title='Playground - Edit Widget',
                                    size_hint=(None, None),
                                    size=(popup_width, popup_height),
                                    auto_dismiss=False)

        content.bind(on_apply=self._perform_select_root_widget,
                     on_cancel=self._popup.dismiss)

        content.selected_items = [self.root_name]
        if self.root_app_widget and self.root_app_widget.is_root:
            content.selected_items = ['Root - ' + self.root_name]
        content.show_items()

        popup.open()
예제 #2
0
 def load_widget_from_file(self, kv_path):
     """Loads first widget from a file
     :param kv_path: absolute kv path
     """
     self.sandbox.clear_widgets()
     proj = get_current_project()
     widgets = proj.app_widgets
     if not os.path.exists(kv_path):
         show_message(kv_path + " not exists", 5, "error")
         return
     self.kv_code_input.text = open(kv_path, "r").read()
     self.kv_code_input.path = kv_path
     for key in widgets:
         wd = widgets[key]
         if wd.kv_path == kv_path:
             self.load_widget(wd.name, update_kv_lang=False)
             return
     # if not found a widget in the path, open the first one
     if len(widgets):
         first_wdg = widgets[list(widgets.keys())[-1]]
         self.load_widget(first_wdg.name, update_kv_lang=False)
         return
     show_message("No widget was found", 5, "error")
예제 #3
0
 def load_widget_from_file(self, kv_path):
     '''Loads first widget from a file
     :param kv_path: absolute kv path
     '''
     self.sandbox.clear_widgets()
     proj = get_current_project()
     widgets = proj.app_widgets
     if not os.path.exists(kv_path):
         show_message(kv_path + ' not exists', 5, 'error')
         return
     self.kv_code_input.text = open(kv_path, 'r').read()
     self.kv_code_input.path = kv_path
     for key in widgets:
         wd = widgets[key]
         if wd.kv_path == kv_path:
             self.load_widget(wd.name, update_kv_lang=False)
             return
     # if not found a widget in the path, open the first one
     if len(widgets):
         first_wdg = widgets[list(widgets.keys())[-1]]
         self.load_widget(first_wdg.name, update_kv_lang=False)
         return
     show_message('No widget was found', 5, 'error')
예제 #4
0
    def on_widget_select_pressed(self, *args):
        '''Event handler to playground widget selector press
        '''
        widgets = get_current_project().app_widgets
        app_widgets = []
        for name in widgets.keys():
            widget = widgets[name]
            if widget.is_root:
                name = 'Root - ' + name
            app_widgets.append(name)

        fake_setting = FakeSettingList()
        fake_setting.allow_custom = False
        fake_setting.items = app_widgets
        fake_setting.desc = 'Select the Widget to edit on Playground'
        fake_setting.group = 'playground_widget'

        content = SettingListContent(setting=fake_setting)
        popup_width = min(0.95 * Window.width, 500)
        popup_height = min(0.95 * Window.height, 500)
        self._popup = popup = Popup(
            content=content,
            title='Playground - Edit Widget',
            size_hint=(None, None),
            size=(popup_width, popup_height),
            auto_dismiss=False
        )

        content.bind(on_apply=self._perform_select_root_widget,
                     on_cancel=self._popup.dismiss)

        content.selected_items = [self.root_name]
        if self.root_app_widget and self.root_app_widget.is_root:
            content.selected_items = ['Root - ' + self.root_name]
        content.show_items()

        popup.open()