How to use the kivy.app.App function in Kivy

To help you get started, we’ve selected a few Kivy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kivy / kivent / old_tutorials / 6_adding_a_pause_button / main.py View on Github external
physics = systems['cymunk-physics']
        asteroid_system = systems['asteroids']
        physics.add_collision_handler(
            1, 1, separate_func=asteroid_system.asteroids_collide)

    def set_state(self):
        self.gameworld.state = 'main'

    def setup_map(self):
        self.gameworld.currentmap = self.gameworld.systems['map']

    def set_pause(self):
        self.gameworld.state = 'pause'


class BasicApp(App):
    def build(self):
        pass

if __name__ == '__main__':
    BasicApp().run()
github AndreMiras / KivyMD / kivymd / slider.py View on Github external
if super(MDSlider, self).on_touch_down(touch):
            self.active = True

    def on_touch_up(self, touch):
        if super(MDSlider, self).on_touch_up(touch):
            self.active = False
#             thumb = self.ids['thumb']
#             if thumb.collide_point(*touch.pos):
#                 thumb.on_touch_down(touch)
#                 thumb.on_touch_up(touch)

if __name__ == '__main__':
    from kivy.app import App
    from kivymd.theming import ThemeManager

    class SliderApp(App):
        theme_cls = ThemeManager()

        def build(self):
            return Builder.load_string("""
BoxLayout:
    orientation:'vertical'
    BoxLayout:
        size_hint_y:None
        height: '48dp'
        Label:
            text:"Toggle disabled"
            color: [0,0,0,1]
        CheckBox:
            on_press: slider.disabled = not slider.disabled
    BoxLayout:
        size_hint_y:None
github rconcep / snl-quest / es_gui / apps / data_manager / widgets.py View on Github external
def check_connection_settings():
    """Checks QuESt settings and returns configuration for connection settings """
    app_config = App.get_running_app().config
    proxy_settings = {}

    # Proxy settings.
    if int(app_config.get('connectivity', 'use_proxy')):
        http_proxy = app_config.get('connectivity', 'http_proxy')
        https_proxy = app_config.get('connectivity', 'https_proxy')
        
        if http_proxy:
            proxy_settings['http'] = http_proxy
        if https_proxy:
            proxy_settings['https'] = https_proxy
    
    # SSL verification.
    ssl_verify = True if int(app_config.get('connectivity', 'use_ssl_verify')) else False

    return ssl_verify, proxy_settings
github AndreMiras / KivyMD / kivymd / elevationbehavior.py View on Github external
def _update_shadow(self, *args):
        if self.elevation > 0:
            ratio = self.width / (self.height if self.height != 0 else 1)
            if ratio > -2 and ratio < 2:
                self._shadow = App.get_running_app().theme_cls.quad_shadow
                width = soft_width = self.width * 1.9
                height = soft_height = self.height * 1.9
            elif ratio <= -2:
                self._shadow = App.get_running_app().theme_cls.rec_st_shadow
                ratio = abs(ratio)
                if ratio > 5:
                    ratio = ratio * 22
                else:
                    ratio = ratio * 11.5

                width = soft_width = self.width * 1.9
                height = self.height + dp(ratio)
                soft_height = self.height + dp(ratio) + dp(self.elevation) * .5
            else:
                self._shadow = App.get_running_app().theme_cls.quad_shadow
                width = soft_width = self.width * 1.8
                height = soft_height = self.height * 1.8
                #                 self._shadow = App.get_running_app().theme_cls.rec_shadow
                #                 ratio = abs(ratio)
                #                 if ratio > 5:
github deepdiy / deepdiy / deepdiy / main.py View on Github external
from core.plugin_mgr import PluginManager
from core.widget_mgr import WidgetManager
from core.display_mgr import DisplayManager
from core.data_mgr import Data
from core.hotkey import Hotkey
from kivy.app import App
from kivy.properties import ObjectProperty,DictProperty
from threading import Thread
from test.debug import *

class MainWindow(App):
    title='DeepDIY'
    data=ObjectProperty(lambda: None,force_dispatch=True)
    plugins=DictProperty()

    def __init__(self,**kwargs):
        super(MainWindow, self).__init__(**kwargs)

    def load_plugins(self):
        self.plugin_manager=PluginManager()
        self.plugin_manager.load_plugins()
        self.display_manager=DisplayManager()
        self.data=Data()
        debug()

    def build(self):
        # self.hotkey=Hotkey()
github kivy / kivy / examples / widgets / shorten_text.py View on Github external
Rectangle:
                    size: self.size
            Label:
                size_hint: 1, 1
                text_size: self.size
                shorten: shorten.state == 'down'
                max_lines: max_lines.value
                valign: 'middle'
                halign: 'center'
                color: (1, 1, 1, 1)
                font_size: 22
                text: 'Michaelangelo Smith'
'''


class ShortenText(App):
    def build(self):
        return Builder.load_string(kv)


ShortenText().run()
github AndreMiras / EtherollApp / src / etherollapp / etheroll / createnewaccount.py View on Github external
def load_landing_page(self):
        """
        Returns to the landing page.
        """
        controller = App.get_running_app().root
        screen_manager = controller.screen_manager
        screen_manager.transition.direction = 'right'
        screen_manager.current = 'roll_screen'
github ohlogic / kivyImageViewer / kivyImageViewer.py View on Github external
index = images.index(os.path.abspath(filename))
            except ValueError:
                pass    
                
        Window.remove_widget(self)
        
        cw = MyCustomImageWidget(directory)
        Window.add_widget(cw)
        self.superparent.customwidget = cw   # needed for the Window keybindings
        self.superparent.topwidget = cw      # now MyCustomImageWidget is on top
        
        if len(self.images) >= 1:
            cw.bg.source=self.images[0]


class MyImageApp(App):

    def build(self):
        self.index = 0
        self.popup = Popup(title='Usage:', content=Label(
            text='Press "f" on the keyboard to find a directory with images\n' + \
            'Press "r" to rotate an image\n' + \
            'Press the left and right arrows on keyboard to cycle images'),auto_dismiss=True)
        self.popup.open()
        Clock.schedule_once(self.popup.dismiss, 5)
        
        Window.bind(on_key_down=self._on_keyboard_down)
        
        self.topwidget = TopBuildWidget()
        return self.topwidget
        
    def _on_keyboard_down(self, keyboard, x, keycode, text, modifiers):
github deepdiy / deepdiy / deepdiy / core / plugin_wrapper.py View on Github external
def instantiate(self):
		if self.is_valid == False:
			return
		self.instance=self._class()
		app=App.get_running_app()
		if hasattr(self.instance,'data') and self.type == 'processing':
			'''use and sync app's data property'''
			self.instance.data=app.data
			app.bind(data=self.instance.setter('data'))
			self.instance.bind(data=app.setter('data'))
github yingshaoxo / kivy-chat / asyncio_main.py View on Github external
'[b][color=2980b9]{}:[/color][/b] {}\n'.format(nickname, esc_markup(msg))
            )

            Clipboard.copy(msg)

    def connection_lost(self, exc):
        print('The server closed the connection')
        self.transport.close()


class RootWidget(ScreenManager):
    def __init__(self, **kwargs):
        super(RootWidget, self).__init__(**kwargs)


class ChatApp(App):

    def build(self):
        self.base_folder =os.path.dirname(os.path.abspath('.'))
        self.setting_file = os.path.join(self.base_folder, 'chat_setting.json')
        self.read_config() 
        return RootWidget()

    def read_config(self):
        try:
            with open(self.setting_file, 'r') as f:
                text = f.read()
            self.setting_dict = json.loads(text)

            self.host = self.setting_dict['host']
            self.nick = self.setting_dict['nick']
        except: