我们从Python开源项目中,提取了以下28个代码示例,用于说明如何使用kivy.core.window.Window.add_widget()。
def add_widget(self, widget): if len(self.children) == 0: super(NavigationDrawer, self).add_widget(widget) self._side_panel = widget elif len(self.children) == 1: super(NavigationDrawer, self).add_widget(widget) self._main_panel = widget elif len(self.children) == 2: super(NavigationDrawer, self).add_widget(widget) self._join_image = widget elif self.side_panel is None: self._side_panel.add_widget(widget) self.side_panel = widget elif self.main_panel is None: self._main_panel.add_widget(widget) self.main_panel = widget else: raise NavigationDrawerException( 'Can\'t add more than two widgets' 'directly to NavigationDrawer')
def _update_quickfind_label(self, _, value): qlabel = self._quickfind_label if value: if qlabel: qlabel.text = value else: self._quickfind_label = CompatTextInput( text=value, size_hint=(None, None), pos=self.pos, font_size=self.quickfind_font_size, size=(self.width, int(self.quickfind_font_size * 2.3))) Window.add_widget(self._quickfind_label) else: if qlabel: Window.remove_widget(qlabel) self._quickfind_label = None
def init_template_widgets(self, *args): Logger.info('TemplateApp: initialising template widgets') self.load_kv('kivy_soil/template_app/themes_layouts/term_and_toast.kv') self.info_widget = InfoWidget() self.term_widget = TerminalWidget() for data in logs.LoggerHistoryProper.data: self.term_widget.add_data(data['text'], data['level']) logs.LoggerHistoryProper.bind( on_add_data=lambda obj, data: self.term_widget.add_data( data['text'], data['level'])) Window.add_widget(self.term_widget) Window.add_widget(self.info_widget) self.init_keybinds()
def open(self, *largs): Window.add_widget(self) # Clock.schedule_once(lambda x: self.display_menu(largs[0]), -1) self.display_menu(largs[0])
def set_side_panel(self, widget): '''Removes any existing side panel widgets, and replaces them with the argument `widget`. ''' # Clear existing side panel entries if len(self._side_panel.children) > 0: for child in self._side_panel.children: self._side_panel.remove(child) # Set new side panel self._side_panel.add_widget(widget) self.side_panel = widget
def set_main_panel(self, widget): '''Removes any existing main panel widgets, and replaces them with the argument `widget`. ''' # Clear existing side panel entries if len(self._main_panel.children) > 0: for child in self._main_panel.children: self._main_panel.remove(child) # Set new side panel self._main_panel.add_widget(widget) self.main_panel = widget
def begin(self): if self.button_text == '': self.remove_widget(self.ids['_button']) else: self.ids['_spacer'].width = dp(16) if \ DEVICE_TYPE == "mobile" else dp(40) self.padding_right = dp(16) Window.add_widget(self) anim = Animation(y=0, duration=.3, t='out_quad') anim.start(self) Clock.schedule_once(lambda dt: self.die(), self.duration)
def __init__(self, **kwargs): super(SlidingPanel, self).__init__(**kwargs) self.shadow = PanelShadow() Clock.schedule_once(lambda x: Window.add_widget(self.shadow,89), 0) Clock.schedule_once(lambda x: Window.add_widget(self,90), 0)
def open(self, *largs): Window.add_widget(self) Clock.schedule_once(lambda x: self.display_menu(largs[0]), -1)
def begin(self): if self.button_text == '': self.remove_widget(self.ids['_button']) else: self.ids['_spacer'].width = dp(16) if DEVICE_TYPE == "mobile" else dp(40) self.padding_right = dp(16) Window.add_widget(self) anim = Animation(y=0, duration=.3, t='out_quad') anim.start(self) Clock.schedule_once(lambda dt: self.die(), self.duration)
def __init__(self, **kwargs): super(SlidingPanel, self).__init__(**kwargs) self.shadow = PanelShadow() Clock.schedule_once(lambda x: Window.add_widget(self.shadow, 89), 0) Clock.schedule_once(lambda x: Window.add_widget(self, 90), 0)
def show(self, length_long, *largs): duration = 5000 if length_long else 1000 rampdown = duration * 0.1 if rampdown > 500: rampdown = 500 if rampdown < 100: rampdown = 100 self._rampdown = rampdown self._duration = duration - rampdown Window.add_widget(self) Clock.schedule_interval(self._in_out, 1/60.0)