Python kivy.core.window.Window.add_widget() Examples

The following are 30 code examples of kivy.core.window.Window.add_widget(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module kivy.core.window.Window , or try the search function .
Example #1
Source File: app.py    From Tickeys-linux with MIT License 6 votes vote down vote up
def display_settings(self, settings):
        '''.. versionadded:: 1.8.0

        Display the settings panel. By default, the panel is drawn directly
        on top of the window. You can define other behaviour by overriding
        this method, such as adding it to a ScreenManager or Popup.

        You should return True if the display is successful, otherwise False.

        :Parameters:
            `settings`: :class:`~kivy.uix.settings.Settings`
                You can modify this object in order to modify the settings
                display.

        '''
        win = self._app_window
        if not win:
            raise Exception('No windows are set on the application, you cannot'
                            ' open settings yet.')
        if settings not in win.children:
            win.add_widget(settings)
            return True
        return False 
Example #2
Source File: connection.py    From Persimmon with MIT License 6 votes vote down vote up
def on_touch_down(self, touch: MotionEvent) -> bool:
        """ On touch down on connection means we are modifying an already
            existing connection, not creating a new one. """
        # TODO: remove start check?
        if self.start and self.start.collide_point(*touch.pos):
            self.forward = False
            # Remove start edge
            self._unbind_pin(self.start)
            self.start.on_connection_delete(self)
            self.start = None
            # This signals that we are dragging a connection
            touch.ud['cur_line'] = self
            Window.add_widget(self.info)
            return True
        elif self.end and self.end.collide_point(*touch.pos):
            # Same as before but with the other edge
            self.forward = True
            self._unbind_pin(self.end)
            self.end.on_connection_delete(self)
            self.end = None
            touch.ud['cur_line'] = self
            Window.add_widget(self.info)
            return True
        else:
            return False 
Example #3
Source File: connection.py    From Persimmon with MIT License 6 votes vote down vote up
def __init__(self, **kwargs):
        """ On this initializer the connection has to check whether the
        connection is being made forward or backwards. """
        super().__init__(**kwargs)
        if self.start:
            self.forward = True
            # The value is repeated for correctness sake
            self.bez_start, self.bez_end = [self.start.center] * 2
            with self.canvas.before:
                Color(*self.color)
                self.lin = Line(bezier=self.bez_start * 4, width=1.5)
            self._bind_pin(self.start)
        else:
            self.forward = False
            self.bez_start, self.bez_end = [self.end.center] * 2
            with self.canvas.before:
                Color(*self.color)
                self.lin = Line(bezier=self.bez_end * 4, width=1.5)
            self._bind_pin(self.end)
        self.warned = False
        self.info = Factory.Info(pos=self.bez_start)
        Window.add_widget(self.info) 
Example #4
Source File: __init__.py    From RaceCapture_App with GNU General Public License v3.0 6 votes vote down vote up
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') 
Example #5
Source File: __init__.py    From pydelhi_mobile with GNU Affero General Public License v3.0 6 votes vote down vote up
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') 
Example #6
Source File: modalview.py    From Tickeys-linux with MIT License 6 votes vote down vote up
def open(self, *largs):
        '''Show the view window from the :attr:`attach_to` widget. If set, it
        will attach to the nearest window. If the widget is not attached to any
        window, the view will attach to the global
        :class:`~kivy.core.window.Window`.
        '''
        if self._window is not None:
            Logger.warning('ModalView: you can only open once.')
            return self
        # search window
        self._window = self._search_window()
        if not self._window:
            Logger.warning('ModalView: cannot open view, no window found.')
            return self
        self._window.add_widget(self)
        self._window.bind(
            on_resize=self._align_center,
            on_keyboard=self._handle_keyboard)
        self.center = self._window.center
        self.bind(size=self._update_center)
        a = Animation(_anim_alpha=1., d=self._anim_duration)
        a.bind(on_complete=lambda *x: self.dispatch('on_open'))
        a.start(self)
        return self 
Example #7
Source File: modalview.py    From Tickeys-linux with MIT License 6 votes vote down vote up
def open(self, *largs):
        '''Show the view window from the :attr:`attach_to` widget. If set, it
        will attach to the nearest window. If the widget is not attached to any
        window, the view will attach to the global
        :class:`~kivy.core.window.Window`.
        '''
        if self._window is not None:
            Logger.warning('ModalView: you can only open once.')
            return self
        # search window
        self._window = self._search_window()
        if not self._window:
            Logger.warning('ModalView: cannot open view, no window found.')
            return self
        self._window.add_widget(self)
        self._window.bind(
            on_resize=self._align_center,
            on_keyboard=self._handle_keyboard)
        self.center = self._window.center
        self.bind(size=self._update_center)
        a = Animation(_anim_alpha=1., d=self._anim_duration)
        a.bind(on_complete=lambda *x: self.dispatch('on_open'))
        a.start(self)
        return self 
Example #8
Source File: app.py    From Tickeys-linux with MIT License 6 votes vote down vote up
def display_settings(self, settings):
        '''.. versionadded:: 1.8.0

        Display the settings panel. By default, the panel is drawn directly
        on top of the window. You can define other behaviour by overriding
        this method, such as adding it to a ScreenManager or Popup.

        You should return True if the display is successful, otherwise False.

        :Parameters:
            `settings`: :class:`~kivy.uix.settings.Settings`
                You can modify this object in order to modify the settings
                display.

        '''
        win = self._app_window
        if not win:
            raise Exception('No windows are set on the application, you cannot'
                            ' open settings yet.')
        if settings not in win.children:
            win.add_widget(settings)
            return True
        return False 
Example #9
Source File: __init__.py    From kivystudio with MIT License 6 votes vote down vote up
def on_path(self, path):
        path_list = path.split('/')

        self._dir_selector.clear_widgets()
        for i in path_list:
            if i:
                btn = Factory.DirButton_(size_hint=(None,1), text=str(i))

                btn.bind(on_release=partial(self._go_dir_with_btn, btn))

                if btn.width <= btn.texture_size[0]:
                    btn.width = btn.texture_size[0]+10

                self._dir_selector.add_widget(btn)
        else:
            if i:
                self.ids.dir_scroll.scroll_to(btn) 
Example #10
Source File: __init__.py    From PyCon-Mobile-App with GNU General Public License v3.0 6 votes vote down vote up
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') 
Example #11
Source File: __init__.py    From PyCon-Mobile-App with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #12
Source File: slidingpanel.py    From KivyMD with MIT License 5 votes vote down vote up
def bind_to_window_if_requested(self, _):
		if self.bind_to_window:
			Window.add_widget(self) 
Example #13
Source File: snackbar.py    From KivyMD with MIT License 5 votes vote down vote up
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) 
Example #14
Source File: snackbar.py    From Blogs-Posts-Tutorials with MIT License 5 votes vote down vote up
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) 
Example #15
Source File: slidingpanel.py    From Blogs-Posts-Tutorials with MIT License 5 votes vote down vote up
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) 
Example #16
Source File: menu.py    From Blogs-Posts-Tutorials with MIT License 5 votes vote down vote up
def open(self, *largs):
        Window.add_widget(self)
        Clock.schedule_once(lambda x: self.display_menu(largs[0]), -1) 
Example #17
Source File: various.py    From kivy-material-ui with MIT License 5 votes vote down vote up
def show( self, isLong, *args ) :
        duration = self.duration_long if isLong else self.duration_short
        timeout_down = duration * 0.1
        if timeout_down > 500 : timeout_down = 500
        if timeout_down < 100 : timeout_down = 100
        self._timeout_down = timeout_down
        self._duration = duration - timeout_down
        Window.add_widget(self)
        Clock.schedule_interval(self.animate, 1/60.0) 
Example #18
Source File: kivytoast.py    From RaceCapture_App with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #19
Source File: __init__.py    From RaceCapture_App with GNU General Public License v3.0 5 votes vote down vote up
def increment_refcount():
		ProgressSpinner.busy_refcount += 1
		if ProgressSpinner.instance is None:
			ProgressSpinner.instance = ProgressSpinner(size_hint=(None, None), size=(100, 100), center=Window.center)
			Window.add_widget(ProgressSpinner.instance) 
Example #20
Source File: __init__.py    From RaceCapture_App with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #21
Source File: __init__.py    From RaceCapture_App with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #22
Source File: __init__.py    From pydelhi_mobile with GNU Affero General Public License v3.0 5 votes vote down vote up
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 
Example #23
Source File: __init__.py    From pydelhi_mobile with GNU Affero General Public License v3.0 5 votes vote down vote up
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 
Example #24
Source File: __init__.py    From kivystudio with MIT License 5 votes vote down vote up
def handle_bubble(self, btn):
        if self.new_bub in Window.children:
            Window.remove_widget(self.new_bub)
        else:
            self.new_bub.pos = (btn.x - (self.new_bub.width-btn.width), btn.y - self.new_bub.height)
            Window.add_widget(self.new_bub) 
Example #25
Source File: popup.py    From Tickeys-linux with MIT License 5 votes vote down vote up
def on_content(self, instance, value):
        if self._container:
            self._container.clear_widgets()
            self._container.add_widget(value) 
Example #26
Source File: popup.py    From Tickeys-linux with MIT License 5 votes vote down vote up
def add_widget(self, widget):
        if self._container:
            if self.content:
                raise PopupException(
                    'Popup can have only one widget as content')
            self.content = widget
        else:
            super(Popup, self).add_widget(widget) 
Example #27
Source File: __init__.py    From PyCon-Mobile-App with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #28
Source File: menu.py    From KivyMD with MIT License 5 votes vote down vote up
def open(self, *largs):
		Window.add_widget(self)
		Clock.schedule_once(lambda x: self.display_menu(largs[0]), -1) 
Example #29
Source File: app.py    From Tickeys-linux with MIT License 5 votes vote down vote up
def run(self):
        '''Launches the app in standalone mode.
        '''
        if not self.built:
            self.load_config()
            self.load_kv(filename=self.kv_file)
            root = self.build()
            if root:
                self.root = root
        if self.root:
            if not isinstance(self.root, Widget):
                Logger.critical('App.root must be an _instance_ of Widget')
                raise Exception('Invalid instance in App.root')
            from kivy.core.window import Window
            Window.add_widget(self.root)

        # Check if the window is already created
        from kivy.base import EventLoop
        window = EventLoop.window
        if window:
            self._app_window = window
            window.set_title(self.get_application_name())
            icon = self.get_application_icon()
            if icon:
                window.set_icon(icon)
            self._install_settings_keys(window)
        else:
            Logger.critical("Application: No window is created."
                            " Terminating application run.")
            return

        self.dispatch('on_start')
        runTouchApp()
        self.stop() 
Example #30
Source File: popup.py    From Tickeys-linux with MIT License 5 votes vote down vote up
def on_content(self, instance, value):
        if self._container:
            self._container.clear_widgets()
            self._container.add_widget(value)