Beispiel #1
0
    def run(self):
        '''Launches the app in standalone mode.
        '''
        if not self.built:
            self.load_config()
            self.load_kv()
            root = self.build()
            if root:
                self.root = root
        if self.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)

        self.dispatch('on_start')
        runTouchApp()
        self.dispatch('on_stop')

        # Clear the window children
        for child in Window.children:
            Window.remove_widget(child)
Beispiel #2
0
 def _reload_keypress(self, instance, code, *largs):
     if code != 286:
         return
     for child in Window.children[:]:
         Window.remove_widget(child)
     root = Builder.load_file(self.options['filename'])
     Window.add_widget(root)
 def _in_out(self, dt):
     self._duration -= dt * 1000
     if self._duration <= 0:
         self._transparency = 1.0 + (self._duration / self._rampdown)
     if -(self._duration) > self._rampdown:
         Window.remove_widget(self)
         return False
Beispiel #4
0
 def update(self, *args):
     Builder.unload_file(join(PATH, TARGET))
     for w in Window.children[:]:
         Window.remove_widget(w)
     try:
         Window.add_widget(Builder.load_file(join(PATH, TARGET)))
     except Exception as e:
         Window.add_widget(Label(text=e.message if e.message else str(e)))
Beispiel #5
0
 def restart_game(self, *args):
     self.fishlife.victory_screen.restart_btn.unbind(on_press=self.restart_game)
     Window.remove_widget(self.fishlife)
     
     # Because widgets later on disappear. Why? Dunno, maybe garbage
     # collector does it's work?
     # Thus, unload and then load the rules again, and now widgets do not
     # disappear.
     Builder.unload_file("main.kv")
     self.begin_game(restart=True)
Beispiel #6
0
 def on_stop(*l):
     if self.modal:
         m = self._modal_view
         m.remove_widget(self)
         Window.remove_widget(m)
     Window.remove_widget(self)
     if self.exit:
         App.get_running_app().stop()
         import sys
         sys.exit()
Beispiel #7
0
    def show_game(self, other_widget, level_number):
        Window.remove_widget(other_widget)
        game = Game.Game()

        if level_number == 1:
            game.map_image = 'data/landscape.jpg'
        elif level_number == 2:
            game.map_image = 'data/landscape_evening.jpg'
        elif level_number == 3:
            game.map_image = 'data/landscape_night.jpg'
        Window.add_widget(game)
        game.start_game()
Beispiel #8
0
    def on_show_label(self, *largs):
        '''Shows/hides the :attr:`pos_label` label.
        '''
        state = self.show_label
        for shape in self.shapes:
            shape.widget.show_label = state

        label = self.pos_label
        if state:
            Window.add_widget(label)
            Window.fbind('mouse_pos', self._update_mouse_pos)
            self._update_mouse_pos(None, Window.mouse_pos)
        else:
            Window.remove_widget(label)
            Window.funbind('mouse_pos', self._update_mouse_pos)
Beispiel #9
0
 def begin_game(self, *largs, **kwargs):
     Builder.load_file("main.kv")
     self.root = self.fishlife = FishLifeGame()
     self.fishlife.victory_screen.restart_btn.bind(on_press=self.restart_game)
     
     try:
         Window.remove_widget(self.intro)
     except:
         pass
         
     Window.add_widget(self.root)
     
     # Fade in
     Window.remove_widget(self.fader)
     Window.add_widget(self.fader)
     anim = Animation(alpha = 0.0, d=0.8)
     anim.bind(on_complete=lambda instance, value: Window.remove_widget(self.fader))
     anim.start(self.fader)
     
     # Timing game start with fade in
     if not kwargs.get("restart", False):
         Clock.schedule_once(self.root.play, 0.85)
     else:
         self.root.play()
Beispiel #10
0
    def begin_game(self, *largs, **kwargs):
        Builder.load_file("main.kv")
        self.root = self.fishlife = FredLifeGame()
        self.fishlife.victory_screen.restart_btn.bind(on_press=self.restart_game)

        try:
            Window.remove_widget(self.intro)
        except:
            pass

        Window.add_widget(self.root)

        # Fade in
        Window.remove_widget(self.fader)
        Window.add_widget(self.fader)
        anim = Animation(alpha=0.0, d=0.8)
        anim.bind(on_complete=lambda instance, value: Window.remove_widget(self.fader))
        anim.start(self.fader)

        # Timing game start with fade in
        if not kwargs.get("restart", False):
            Clock.schedule_once(self.root.play, 0.85)
        else:
            self.root.play()
Beispiel #11
0
 def close_tooltip(self, *args):
     Window.remove_widget(self.tooltip)
Beispiel #12
0
 def dismiss(self):
     Window.remove_widget(self)
Beispiel #13
0
 def on_stop(*l):
     Window.remove_widget(self)
Beispiel #14
0
 def close_tooltip(self, *args):
     Window.remove_widget(self.tooltip)
Beispiel #15
0
 def show_menu(self, other_widget):
     Window.remove_widget(other_widget)
     Window.add_widget(self.menu_screen)
Beispiel #16
0
 def decrement_refcount():
     ProgressSpinner.busy_refcount -= 1 if ProgressSpinner.busy_refcount > 0 else 0
     if ProgressSpinner.busy_refcount == 0 and ProgressSpinner.instance:
         Window.remove_widget(ProgressSpinner.instance)
         ProgressSpinner.instance = None
Beispiel #17
0
 def on_dismiss(self):
     Window.remove_widget(self)
Beispiel #18
0
 def restart_game(self, *args):
     self.fishlife.victory_screen.restart_btn.unbind(on_press=self.restart_game)
     Window.remove_widget(self.fishlife)
     Builder.unload_file("main.kv")
     self.begin_game(restart=True)
 def select_expo(self, expo):
     for child in Window.children[:]:
         Window.remove_widget(child)
     self.app.show_expo(expo['id'])
Beispiel #20
0
 def back_to_lobby_browser(self, *args):
     app = App.get_running_app()
     app.change_screen("lobby_browser_screen")
     Window.remove_widget(self.fab)
     Window.remove_widget(self)
Beispiel #21
0
 def remove_self_and_fab(self, *args):
     Window.remove_widget(self.fab)
     Window.remove_widget(self)
Beispiel #22
0
 def hide_particles(self):
    print "hiding"
    Window.remove_widget(self.sun)
 def on_touch_up(self, touch, window):
     global dragAndDropWidget
     if dragAndDropWidget is not None:
         Window.remove_widget(dragAndDropWidget)
         dragAndDropWidget = None
     return False
Beispiel #24
0
    def on_mouse_down(self, mouse, x, y, button, modifiers):
        """Manage event when some mouse button is utliized.
        
        For example, when the middle mouse button is used to scroll,
        the cursor is repositioned here.
        
        :param mouse: Instance of the mouse listener.
        :param x: x position of the mouse.
        :param y: y position of the mouse.
        :param button: Mouse button pressed ('left', 'right', 'scrollup', ...)
        :param modifiers: Modifiers used for the mouse press ('ctrl', 'alt', ...)
        """
        self.editor.last_click = button

        # In any case, remove a right click menu if there is one
        rc_menu = self.editor_container.right_click_menu
        if rc_menu is not None and rc_menu in Window.children:

            top = Window.size[1] - (rc_menu.y + rc_menu.height)
            bottom = (top + rc_menu.height - 10
                      )  #TODO find a way to remove this 10
            # It's in the widget and I don't know why (in the widget in rightclickmenu.kv)

            if ((x < rc_menu.x or x > rc_menu.width + rc_menu.x)
                    or (y < top or y > bottom) or button == 'right'):

                Window.remove_widget(rc_menu)

        # To show right click menu, let's brute force this.
        # It calculates if the click is inside the visible area
        # of the editor.
        if button == 'right':

            self.editor.text_from = self.editor._selection_from
            self.editor.text_to = self.editor._selection_to
            c_y = self.editor_container.y
            c_h = self.editor_container.height
            m_c_x = self.editor_container.to_widget(x, y, relative=True)

            top = (Window.size[1] - c_y - c_h +
                   self.editor_container._tab_layout.height)

            bottom = c_h + self.editor_container.parent.menu_bar.height

            editor = self.editor_container.current_tab.content.editor

            e_x = editor.x
            e_w = editor.x + editor.width
            if (len(self.editor_container.tab_list) > 0
                    and (x >= e_x and x < e_w) and (y >= top and y <= bottom)):

                self.editor_container.open_right_click_menu(x + 15, y)

        if button == 'scrollup':

            editor = self.editor
            y_pos = math.floor(self.scroll_y *
                               float(self.viewport_size[1] - self.height))

            new_col, new_row = editor.get_cursor_from_xy(self.scroll_x, y_pos)

            editor.cursor = (editor.cursor_col, new_row)

        if button == 'scrolldown':

            editor = self.editor

            y_pos = math.floor(self.scroll_y *
                               float(self.viewport_size[1] - self.height))

            new_col, new_row = editor.get_cursor_from_xy(
                self.scroll_x, y_pos + self.height)

            editor.cursor = (editor.cursor_col, new_row)
Beispiel #25
0
 def remove_tooltip(self, *args):
     Window.remove_widget(self._tooltip)
Beispiel #26
0
	def die(self):
		anim = Animation(top=0, duration=.3, t='out_quad')
		anim.bind(on_complete=lambda *args: _play_next(self))
		anim.bind(on_complete=lambda *args: Window.remove_widget(self))
		anim.start(self)
Beispiel #27
0
 def remove_info(self):
     Window.remove_widget(self.info)
 def die(self):
     anim = Animation(top=0, duration=.3, t='out_quad')
     anim.bind(on_complete=lambda *args: _play_next(self))
     anim.bind(on_complete=lambda *args: Window.remove_widget(self))
     anim.start(self)
Beispiel #29
0
    def remove_tooltip(self, *args) -> None:
        """Removes the tooltip widget from the screen."""

        Window.remove_widget(self._tooltip)
Beispiel #30
0
 def show_map(self, other_widget):
     Window.remove_widget(other_widget)
     Window.add_widget(self.map_screen)
Beispiel #31
0
def remove_info_on_mouse():
    if info_label in Window.children:
        Window.remove_widget(info_label)
Beispiel #32
0
async def ceed_app(request, nursery, temp_file, tmp_path, tmp_path_factory,
                   app_list):

    params = request.param if hasattr(request,
                                      'param') and request.param else {}
    ts0 = time.perf_counter()
    from kivy.core.window import Window
    from kivy.context import Context
    from kivy.clock import ClockBase
    from kivy.animation import Animation
    from kivy.base import stopTouchApp
    from kivy.factory import FactoryBase, Factory
    from kivy.lang.builder import BuilderBase, Builder
    from kivy.logger import LoggerHistory

    context = Context(init=False)
    context['Clock'] = ClockBase(async_lib='trio')
    # context['Factory'] = FactoryBase.create_from(Factory)
    # have to make sure all ceed files are imported before this because
    # globally read kv files will not be loaded again in the new builder,
    # except if manually loaded, which we don't do
    # context['Builder'] = BuilderBase.create_from(Builder)
    context.push()

    Window.create_window()
    Window.register()
    Window.initialized = True
    Window.canvas.clear()

    from kivy.clock import Clock
    Clock._max_fps = 0

    import ceed.view.controller
    ceed.view.controller.ignore_vpixx_import_error = True

    if params.get('persist_config'):
        base = str(tmp_path_factory.getbasetemp() / params['persist_config'])
        app = CeedTestApp(json_config_path=base + 'config.yaml',
                          ini_file=base + 'config.ini',
                          open_player_thread=False)
    else:
        app = CeedTestApp(json_config_path=temp_file('config.yaml'),
                          ini_file=temp_file('config.ini'),
                          open_player_thread=False)
    app.ceed_data.root_path = str(tmp_path)

    try:
        app.set_async_lib('trio')
        nursery.start_soon(app.async_run)

        ts = time.perf_counter()
        while not app.app_has_started:
            await trio.sleep(.1)
            if time.perf_counter() - ts >= 120:
                raise TimeoutError()

        await app.wait_clock_frames(5)

        ts1 = time.perf_counter()
        yield weakref.proxy(app)
        ts2 = time.perf_counter()

        stopTouchApp()

        ts = time.perf_counter()
        while not app.app_has_stopped:
            await trio.sleep(.1)
            if time.perf_counter() - ts >= 40:
                raise TimeoutError()

    finally:
        stopTouchApp()
        for anim in list(Animation._instances):
            anim._unregister()
        app.clean_up()
        for child in Window.children[:]:
            Window.remove_widget(child)

        context.pop()
        del context
        LoggerHistory.clear_history()

    app_list.append((weakref.ref(app), weakref.ref(request)))

    ts3 = time.perf_counter()
    print(ts1 - ts0, ts2 - ts1, ts3 - ts2)
	def decrement_refcount():
		ProgressSpinner.busy_refcount -= 1 if ProgressSpinner.busy_refcount > 0 else 0
		if ProgressSpinner.busy_refcount == 0 and ProgressSpinner.instance:
			Window.remove_widget(ProgressSpinner.instance)
			ProgressSpinner.instance = None
Beispiel #34
0
 def close_tooltip(self, *args):
     try:
         Window.remove_widget(self.tooltip)
     except Exception as e:
         print 'Error occurred in close_tooltip: ', str(e)
Beispiel #35
0
 def handle_escape(self):
     if self.new_bub in Window.children:
         Window.remove_widget(self.new_bub)
     else:
         self.dismiss()
Beispiel #36
0
 def on_pos(self, instance, value):
     for child in Window.children:
         if type(child) == ToolTip:
             Window.remove_widget(child)
Beispiel #37
0
 def tearDown(self):
     for child in Window.children[:]:
         Window.remove_widget(child)
Beispiel #38
0
 def dismiss(self, *args):
     Window.remove_widget(self.panel)
Beispiel #39
0
    def on_dismiss(self):
        Window.unbind(on_key_down=self.handle_key)

        # remove bubble if open
        if self.new_bub in Window.children:
            Window.remove_widget(self.new_bub)
Beispiel #40
0
 def close_tooltip(self, *args):
     self.open = False
     Window.remove_widget(self.tooltip)
Beispiel #41
0
 def finished(self):
     Window.remove_widget(self.current_widget)
     novel = Novel('talk2', self.finished)
     Window.add_widget(novel)
     self.current_widget = novel
Beispiel #42
0
 def hide_label(self):
     Window.remove_widget(self)
     self.attached_widget.funbind('center', self._reposition)
     self.funbind('size', self._reposition)
Beispiel #43
0
# https://www.flaticon.com/

if __name__ == '__main__':
    import os
    if os.environ.get('COVERAGE_PROCESS_START', None) == '1':
        import coverage
        coverage.process_startup()

    import multiprocessing
    multiprocessing.freeze_support()
    from ceed.main import run_app
    app = run_app()

    from kivy.core.window import Window
    for child in Window.children[:]:
        Window.remove_widget(child)
    from kivy.logger import LoggerHistory
    LoggerHistory.clear_history()
    import gc
    import weakref
    app = weakref.ref(app)
    gc.collect()
    import logging

    if app() is not None:
        logging.error('Memory leak: failed to release app for test ')
        import objgraph
        objgraph.show_backrefs(
            [app()], filename=r'E:\backrefs.png', max_depth=100,
            too_many=1)
        # objgraph.show_chain(
Beispiel #44
0
    def submit(self, userN, passW):
        global current_user
        loggedon = False
        for account in teachers:
            if userN == account.get_userName():
                loggedon = True
                if passW == account.get_password():
                    navigationdrawer = SideBar()

                    side_panel = BoxLayout(orientation='vertical')
                    side_panel.add_widget(
                        Label(
                            text='~~~ * ------------- Menu ------------- * ~~~',
                            size_hint_y=None,
                            height=40))

                    homepage = Button(text='Homepage',
                                      background_color=(0, 1, 0.7, 1))
                    homepage.bind(
                        on_press=lambda x: self.change_screen('Homepage'))

                    teach = Button(text='Teacher Profile',
                                   background_color=(0, 1, 0.7, 1))
                    teach.bind(
                        on_press=lambda x: self.change_screen('Profile'))

                    general = Button(text='General Activities',
                                     background_color=(0, 1, 0.7, 1))
                    general.bind(
                        on_press=lambda x: self.change_screen('General'))

                    coding = Button(text='Coding Club',
                                    background_color=(0, 1, 0.7, 1))
                    coding.bind(
                        on_press=lambda x: self.change_screen('Coding'))

                    robotics = Button(text='Robotics',
                                      background_color=(0, 1, 0.7, 1))
                    robotics.bind(
                        on_press=lambda x: self.change_screen('Robotics'))

                    scanner = Button(text='Scanner',
                                     background_color=(0, 1, 0.7, 1))
                    scanner.bind(
                        on_press=lambda x: self.change_screen('Scanner'))

                    # Adds all buttons to the sidebar for changing screens
                    side_panel.add_widget(homepage)
                    side_panel.add_widget(teach)
                    side_panel.add_widget(general)
                    side_panel.add_widget(coding)
                    side_panel.add_widget(robotics)
                    side_panel.add_widget(scanner)
                    navigationdrawer.add_widget(side_panel)

                    # Displays the current screen
                    main_panel = screen_manager
                    navigationdrawer.add_widget(main_panel)

                    navigationdrawer.anim_type = 'slide_above_anim'
                    navigationdrawer.anim_to_state('open')

                    Window.add_widget(navigationdrawer)
                    Window.remove_widget(firstScreen)

                    current_user = account

                else:
                    passwPop = Popup(
                        title="Login Error",
                        content=Label(text="Wrong password"),
                        background=
                        'atlas://data/images/defaulttheme/button_pressed',
                        size_hint=(None, None),
                        size=(400, 150))
                    passwPop.open()

        if not loggedon:
            userPop = Popup(
                title="Login Error",
                content=Label(text="Invalid username"),
                background='atlas://data/images/defaulttheme/button_pressed',
                size_hint=(None, None),
                size=(400, 150))
            userPop.open()
Beispiel #45
0
 def on_leave(self):
     if self._tooltip:
         Window.remove_widget(self._tooltip)
         self._tooltip = None
Beispiel #46
0
 def dismiss(self):
     if self in Window.children:
         Window.remove_widget(self)
Beispiel #47
0
async def kivy_app(request, nursery):
    gc.collect()
    if apps:
        last_app, last_request = apps.pop()
        assert last_app() is None, \
            'Memory leak: failed to release app for test ' + repr(last_request)

    from os import environ
    environ['KIVY_USE_DEFAULTCONFIG'] = '1'

    # force window size + remove all inputs
    from kivy.config import Config
    Config.set('graphics', 'width', '320')
    Config.set('graphics', 'height', '240')
    for items in Config.items('input'):
        Config.remove_option('input', items[0])

    from kivy.core.window import Window
    from kivy.context import Context
    from kivy.clock import ClockBase
    from kivy.factory import FactoryBase, Factory
    from kivy.app import App
    from kivy.lang.builder import BuilderBase, Builder
    from kivy.base import stopTouchApp
    from kivy import kivy_data_dir
    from kivy.logger import LoggerHistory

    kivy_eventloop = environ.get('KIVY_EVENTLOOP', 'asyncio')
    if kivy_eventloop == 'asyncio':
        pytest.importorskip(
            'pytest_asyncio',
            reason='KIVY_EVENTLOOP == "asyncio" but '
                   '"pytest_asyncio" is not installed')
        async_lib = 'asyncio'
    elif kivy_eventloop == 'trio':
        pytest.importorskip(
            'pytest_trio',
            reason='KIVY_EVENTLOOP == "trio" but '
                   '"pytest_trio" is not installed')
        async_lib = 'trio'
    else:
        pytest.skip(
            'KIVY_EVENTLOOP must be set to either of "asyncio" or '
            '"trio" to run async tests')

    context = Context(init=False)
    context['Clock'] = ClockBase(async_lib=async_lib)

    # have to make sure all global kv files are loaded before this because
    # globally read kv files (e.g. on module import) will not be loaded again
    # in the new builder, except if manually loaded, which we don't do
    context['Factory'] = FactoryBase.create_from(Factory)
    context['Builder'] = BuilderBase.create_from(Builder)
    context.push()

    Window.create_window()
    Window.register()
    Window.initialized = True
    Window.canvas.clear()

    app = request.param[0]()
    app.set_async_lib(async_lib)

    if async_lib == 'asyncio':
        import asyncio
        loop = asyncio.get_event_loop()
        loop.create_task(app.async_run())
    else:
        nursery.start_soon(app.async_run)
    from kivy.clock import Clock
    Clock._max_fps = 0

    ts = time.perf_counter()
    while not app.app_has_started:
        await app.async_sleep(.1)
        if time.perf_counter() - ts >= 10:
            raise TimeoutError()

    await app.wait_clock_frames(5)

    yield app

    stopTouchApp()

    ts = time.perf_counter()
    while not app.app_has_stopped:
        await app.async_sleep(.1)
        if time.perf_counter() - ts >= 10:
            raise TimeoutError()

    for child in Window.children[:]:
        Window.remove_widget(child)
    context.pop()

    # release all the resources
    del context
    LoggerHistory.clear_history()
    apps.append((weakref.ref(app), request))
    del app
    gc.collect()
Beispiel #48
0
 def hide_menu(self, *args):
     """
     fonction qui retire le widget à la fenetre
     """
     Window.remove_widget(self.rootMenu)
Beispiel #49
0
 def hide_select(self, *args):
     """
     fonction qui "hide" cet écran de selection
     """
     Window.remove_widget(self.rootSelect)
Beispiel #50
0
 def hide_game(self, *args):
     """
     Fonction qui "cache" le jeu
     """
     Window.remove_widget(self.rootGame)
Beispiel #51
0
 def on_dismiss(self):
     Window.remove_widget(self)
     self.menu.width = 0
     self.menu.height = 0
     self.menu.opacity = 0
Beispiel #52
0
 def hide_quit(self, *args):
     Window.remove_widget(self.rootQuit)
Beispiel #53
0
 def on_stop(*l):
     Window.remove_widget(self)
Beispiel #54
0
 def anim_complete(self, *args):
     Window.remove_widget(self)