Example #1
0
    def update(self, dt):
        # print(f"dt : {dt*60}")
        time_factor = dt * 60
        self.calculate_offset()
        self.update_vertical_lines()
        self.update_horizontal_lines()
        self.update_tiles()
        self.update_ship()
        self.update_score()

        if not self.state_game_over and self.state_game_started:

            # vitesses relatives à la taille de l'écran'
            speed_y = self.SPEED * self.height / 1000
            speed_x = self.current_speed_x * self.width / 1000

            self.current_offset_y += speed_y * time_factor
            self.current_offset_x += speed_x * time_factor

            while self.current_offset_y >= self.y_road_spacing:
                self.current_offset_y -= self.y_road_spacing
                self.current_y_loop += 1
                self.generate_tiles_coordinates()

        if not self.check_ship_collision() and not self.state_game_over:
            print("GAME OVER")
            self.menu_title = "GAME OVER"
            self.menu_button_title = "RESTART"
            self.state_game_over = True
            self.menu_widget.opacity = 1

            self.sound_music1.stop()
            self.sound_gameover_impact.play()
            # self.sound_gameover_impact.seek(0)
            Clock.schedule_once(self.play_voice_game_over, 1)
Example #2
0
    def on_close_tab(self, instance, *args):
        '''Event handler to close icon
        :param instance: tab instance
        '''
        d = get_designer()
        if d.popup:
            return False

        self.switch_to(instance)
        if instance.has_modification:
            # show a dialog to ask if can close
            confirm_dlg = ConfirmationDialog(
                    'All unsaved changes will be lost.\n'
                    'Do you want to continue?')
            popup = Popup(
                    title='New',
                    content=confirm_dlg,
                    size_hint=(None, None),
                    size=('200pt', '150pt'),
                    auto_dismiss=False)

            def close_tab(*args):
                d.close_popup()
                self._perform_close_tab(instance)

            confirm_dlg.bind(
                    on_ok=close_tab,
                    on_cancel=d.close_popup)
            popup.open()
            d.popup = popup
        else:
            Clock.schedule_once(partial(self._perform_close_tab, instance))
Example #3
0
    def __init__(self, **kwargs):
        super(MainWidget, self).__init__(**kwargs)
        # print(f"INIT W = {self.width} // H = {self.height}")
        self.init_vertical_lines()
        self.init_horizontal_lines()
        self.current_offset_y = 0
        self.current_offset_x = 0
        self.current_speed_x = 0
        self.current_y_loop = 0

        self.init_audio()

        self.state_game_started = False
        self.state_game_over = False

        self.init_tiles()
        self.init_ship()
        self.pre_fill_tiles_coordinates()
        self.generate_tiles_coordinates()

        if is_desktop():
            self._keyboard = Window.request_keyboard(self._keyboard_closed,
                                                     self)
            self._keyboard.bind(on_key_down=self._on_keyboard_down)
            self._keyboard.bind(on_key_up=self._on_keyboard_up)

        Clock.schedule_interval(self.update, 1.0 / 60.)

        self.sound_galaxy.play()
Example #4
0
    def buttonPlay(self):
        """再生ボタンクリック時"""

        try:
            if not Holder.getStatus() == "" and not Holder.getStatus(
            ) == "play":
                # 再生中でなければ
                try:
                    pygame.mixer.music.play(0, Holder.getSlideValue())
                    Clock.schedule_interval(self.position, 0.1)
                    self.image_play = "image/pause.png"
                    #                    self.sound_vlc.play()
                    #                    self.sound_vlc.set_time(int(Holder.getSlideValue() * 1000))
                    Holder.setStatus("play")

                except:
                    pass

            else:
                Holder.setSlideValue(self.ids.slider.value)
                pygame.mixer.music.pause()
                self.image_play = "image/play.png"
                #                self.sound_vlc.pause()
                Clock.unschedule(self.position)
                Holder.setStatus("pause")

        except:
            pass
Example #5
0
 def callback1(self, dt):
     if dt >= 0.9:
         self.manager.get_screen('board1').popup.dismiss()
         self.manager.current = 'board2'
     else:
         self.manager.get_screen('board1').popup.open()
         Clock.schedule_once(self.callback1, 1)
    def initiate_downloads(self, image_urls, *_):
        global close_pools
        close_pools = False
        Clock.schedule_once(partial(self.preload, len(image_urls)), 0)

        with concurrent.futures.ThreadPoolExecutor(max_workers=3) as executor:
            results = [
                executor.submit(self.download_image, url, index)
                for index, url in enumerate(image_urls)
            ]

            for future in concurrent.futures.as_completed(results):

                try:
                    if future.result() is None: break

                    image_byte = future.result()[0]
                    filename = future.result()[1]
                    index = future.result()[2]

                    if image_byte is not None:
                        print(f"Image Downloaded -> {filename}")
                        Clock.schedule_once(
                            partial(self.update_images, image_byte, filename,
                                    index), 0)
                except:
                    print("Some Download Exception...")

            print(
                f"All {len(image_urls)} tasks {'done' if not close_pools else 'cancelled'}."
            )
Example #7
0
    def update(self, dt):
        time_factor = dt * 60
        self.update_vertical_lines()
        self.update_horizontal_lines()
        self.update_tiles()
        self.update_ship()

        if not self.state_game_over and self.state_game_start:
            speed_y = self.SPEED * self.height / 100
            self.current_offset_y += speed_y * time_factor

            spacing_y = self.H_LINES_SPACING * self.height
            while self.current_offset_y >= spacing_y:
                self.current_offset_y -= spacing_y
                self.current_y_loop += 1
                self.score_txt = "SCORE: " + str(self.current_y_loop)
                self.generate_tiles_cordinated()

            speed_x = self.current_speed_x * self.width / 100
            self.current_offset_x += speed_x * time_factor

        if not self.check_ship_collision() and not self.state_game_over:
            self.state_game_over = True
            self.menu_title = "G    A   M   E           O   V   E   R"
            self.menu_button_title = "RESTART"
            self.menu_widget.opacity = 1
            self.sound_music1.stop()
            self.sound_gameover_impact.play()
            self.sound_voice.play()
            Clock.schedule_once(self.play_game_over_voice_sound, 3)
            print("Over")
 def __init__(self, **kwargs):
     super(NavigationDrawerLeftRightIconButton, self).__init__(**kwargs)
     self._set_active_color()
     self.theme_cls.bind(primary_color=self._set_active_color_primary,
                         accent_color=self._set_active_color_accent)
     Clock.schedule_once(lambda x: self.on_left_icon(self, self.icon))
     Clock.schedule_once(lambda x: self.on_right_icon(self, self.icon))
Example #9
0
    def keyboard_on_key_down(self, window, keycode, text, modifiers):
        code, key = keycode
        if (code not in (276, 273) and self.cursor_index() < self.prompt_pos) or \
                (code == 8 and self.cursor_index() == self.prompt_pos):
            self.cursor = self.get_cursor_from_index(self.prompt_pos)
            return
        if code == 13:
            self.validate_cursor_pos()
            text = self.text[self._cursor_pos:]

            if text.strip().startswith('clear'):
                self.text = ''
                self._cursor_pos = 0
                self.prompt()
                return

            elif text.strip():
                Clock.schedule_once(partial(self._run_cmd, text))

            else:
                Clock.schedule_once(self.prompt)
        elif code in [8, 127]:
            self.cancel_selection()
        elif code == 99 and modifiers == ['ctrl']:
            self.cancel_selection()
        return super().keyboard_on_key_down(window, keycode, text, modifiers)
Example #10
0
    def keyboard_on_key_down(self, window: Keyboard, keycode: Tuple[int, str],
                             text: str,
                             modifiers: ObservableList) -> Union[None, bool]:
        """
        Captures specific key presses
        and executes accordingly.
        """
        if keycode[0] in KEYS['enter']:
            self.validate_cursor_pos()
            text = self.text[self._cursor_pos - 1:]

            if text.strip():
                Clock.schedule_once(partial(self._run_cmd, text))
            else:
                Clock.schedule_once(self.prompt)

        elif keycode[0] in KEYS['del', 'backspace']:
            self.cancel_selection()

        elif keycode[0] in KEYS['c'] and 'ctrl' in modifiers:
            self.shell.stop()

        if self.cursor_index() < self._cursor_pos:
            return False

        return super(TerminalInput,
                     self).keyboard_on_key_down(window, keycode, text,
                                                modifiers)
Example #11
0
 def search(self, keyword, source):
     cancel_search = True
     self.search_list.data = []
     
     scraper = MangaScraper(source)
     mangas = scraper.search_online(keyword)
     Clock.schedule_once(partial(self.update_search_list, mangas, source), 1)
Example #12
0
    def __init__(self, **kwargs):
        super(LatestView, self).__init__(**kwargs)
        Logger.info('LatestView: Initialized {}'.format(self))

        Clock.schedule_once(self.pr, 9)

        self.connn = Connector()
 def refresh_callback(self, *args):
     def refresh_callback(interval):
         self.ids.box.clear_widgets()
         self.set_list()
         self.ids.refresh_layout.refresh_done()
         self.tick = 0
     Clock.schedule_once(refresh_callback, 1)
Example #14
0
    def init_game(self, mode):
        game = Game()
        controller = Controller(game)

        ai = AI(game)
        first_player = Player(PieceColor.WHITE, controller,
                              ai if mode == GameMode.AI_VS_HUMAN else None)
        second_player = Player(PieceColor.BLACK, controller,
                               ai if mode == GameMode.HUMAN_VS_AI else None)

        players = [first_player, second_player]

        game_board = GameBoardWidget(game)
        for player in players:
            if player.type == PlayerType.HUMAN:
                game_board.move_receive_from_ui.append(
                    player.move_receive_from_ui_handler)

        if first_player.type == PlayerType.AI:
            first_player.move_complete_event(PieceColor.BLACK)

        Clock.schedule_interval(lambda delta_time: game_board.update(), 0.03)

        self.clear_widgets()

        game_widget = GameWidget(game)
        size = (game_board.width, game_board.height + 50)
        game_widget.size = size
        Window.size = size
        game_widget.set_game_board(game_board)
        self.add_widget(game_widget)
Example #15
0
 def __init__(self, capteur, titre="", **kvargs):
     super().__init__(**kvargs)
     self.g = []
     self.titre = titre
     self.L = 300
     self.H = 200
     self.graphX = []
     self.graphY = []
     self.y_mid = self.H / 2
     self.capteur = capteur
     self.label_titre = Label(text=self.titre,
                              color=(1, 0.5, 0),
                              text_size=(self.width, self.height),
                              size_hint=(1, 2),
                              padding_y=0)
     self.add_widget(self.label_titre)
     Clock.schedule_interval(self.update, FREQ)
     self.temps = 0
     pas = int(300/10*FREQ)
     # pas = 3
     max_graph = int(10/FREQ)
     # max_graph = 90
     if self.capteur.nom == "Altitude":
         for i in range(0, max_graph):
             self.graphX.append(pas*i)
             self.graphY.append(0)
     else:
         for i in range(0, max_graph):
             self.graphX.append(pas*i)
             # pas*i = 89*3 =
             self.graphY.append(self.y_mid)
Example #16
0
    def on_enter(self):
        global ENTRY_PLAYER

        if ENTRY_PLAYER == 0:
            MAIN_SOUND.stop()
            ENTRY_PLAYER = 1
            self.ids.grid.top = 760
            self.ids.grid.right = 1350

            for i in range(NUMBER_OF_BUTTONS):
                for j in range(NUMBER_OF_BUTTONS):
                    button = Button(text="")
                    button.size_hint = (100, 100)
                    button.coords = (i, j)
                    button.bind(on_press=self.button_pressed)
                    for ship in SHIPS_OF_PLAYER:
                        if ship[0] == (i, j):
                            button.background_color = ship[1]
                            button.name = str(ship[2])

                    self.ids.grid.add_widget(button)

            self.manager.current = 'board2'
            self.popup.open()
            Clock.schedule_once(self.callback, 1.5)
    def on_touch_up(self, touch):
        if self.inspection_entity is not None:
            Clock.unschedule(self.show_inspection)
            if self.inspection_entity.is_enemy():
                if self.ids.move_hud.move_hud_open:
                    # If the move hud is open, we are specifiying a single target
                    self.characters_targeting[
                        self.ids.move_hud.index_open] = self.inspection_entity
                    self.animate_targeting_circle(self.inspection_entity)
                    self.target_specified = False
                else:
                    if not self.target_specified or self.inspection_entity != self.characters_targeting[
                            0]:
                        self.target_specified = True
                        self.animate_targeting_circle(self.inspection_entity)
                        for index in range(len(self.characters_targeting)):
                            self.characters_targeting[
                                index] = self.inspection_entity
                    elif self.inspection_entity == self.characters_targeting[
                            0]:
                        self.target_specified = False
                        self.ids.targeting_circle.opacity = 0

            self.inspection_entity = None
        result = super().on_touch_up(touch)
        return result
    def on_text(self, *args):
        '''updates the tab width when it has a new title
        '''
        def update_width(*args):
            self.width = min(self.texture_size[0] + 40, 200)

        Clock.schedule_once(update_width)
Example #19
0
    def add_label(self, dt):

        label = Label(text='Are you excited?\nBeacuse I do!', font_name='Ubuntu-C.ttf', color=[0,0,0,1],
              size_hint=(0.8, 0.2),valign='center', halign='center', pos_hint={"x":0.1, "y":0}, font_size=self.width/10)

        self.manager.ids.loading_screen.add_widget(label)
        Clock.schedule_once(lambda d: self.manager.ids.loading_screen.remove_widget(label), 5)
    def on_close_tab(self, instance, *args):
        '''Event handler to close icon
        :param instance: tab instance
        '''
        d = get_designer()
        if d.popup:
            return False

        self.switch_to(instance)
        if instance.has_modification:
            # show a dialog to ask if can close
            confirm_dlg = ConfirmationDialog(
                'All unsaved changes will be lost.\n'
                'Do you want to continue?')
            popup = Popup(title='New',
                          content=confirm_dlg,
                          size_hint=(None, None),
                          size=('200pt', '150pt'),
                          auto_dismiss=False)

            def close_tab(*args):
                d.close_popup()
                self._perform_close_tab(instance)

            confirm_dlg.bind(on_ok=close_tab, on_cancel=d.close_popup)
            popup.open()
            d.popup = popup
        else:
            Clock.schedule_once(partial(self._perform_close_tab, instance))
Example #21
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     self.rw = RootWidget(gameStatus='Not Completed')
     self.add_widget(self.rw)
     # call update() every second
     #Clock.schedule_interval(self.rw.update, 1.0)
     Clock.schedule_interval(self.update, 1.0)
Example #22
0
 def update(self, obj):
     if self.rw.gameStatus == 'Completed':
         Clock.unschedule(self.update)
         self.rw.clear_widgets()
         self.manager.current = 'optionscreen'
     else:
         self.rw.update(self.rw)
Example #23
0
 def toggle_play_state(self):
     app = App.get_running_app()
     is_playing = app.play_state == "play"
     if is_playing:
         task = lambda x: setattr(App.get_running_app(), "play_state", "pause")
     else:
         task = lambda x: setattr(App.get_running_app(), "play_state", "play")
     Clock.schedule_once(task, 0.1)
Example #24
0
 def __init__(self, nom=""):
     try:
         self.ser = serial.Serial('/dev/cu.usbmodem1411', 9600)
     except:
         print("no reception")
     self.nom = nom
     self.data = .0
     Clock.schedule_interval(self.recepteur_update, FREQ)
Example #25
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     self.ball_size = dp(50)
     self.vx = dp(10)
     self.vy = dp(10)
     with self.canvas:
         self.ball = Ellipse(pos=(100, 100), size=(self.ball_size, self.ball_size))
     Clock.schedule_interval(self.update, 1/60)
Example #26
0
    def on_text(self, *args):
        """updates the tab width when it has a new title
        """

        def update_width(*args):
            self.width = min(self.texture_size[0] + 40, 200)

        Clock.schedule_once(update_width)
Example #27
0
 def on_reset(self):
     self.root.msg_text = "Victory!"
     self.root.popup_label.text = "Victory!\nTouch to start"
     self.root.popup.open()
     Clock.unschedule(self.counting)
     self.root.score += int(1.0 / ((self.root.clock_time / 60.0)**2 + 1) *
                            20)
     self.root.clock_time = 0
     self.should_restart = True
Example #28
0
 def on_slider_value(self, widget):
     print("Slider value: " + str(widget.value))
     self.slider_value = int(widget.value)
     # stop scheduler
     Clock.unschedule(
         self.event)  # https://kivy.org/doc/stable/api-kivy.clock.html
     # restart scheduler at a new speed if cursor > 0
     if self.slider_value > 0:
         self.start()
Example #29
0
 def _add(self, route):
     """Adds the route unless there is a path conflict"""
     if route.path in self._routes:
         raise Exception("Route path must be unique")
     self._routes[route.path] = route
     super(Router, self).add_widget(route)
     if route.path == self.selected_route:
         Clock.schedule_once(lambda *_: self._set_current_route(route.path),
                             0)
Example #30
0
 def __init__(self, recepteur, **kwargs):
     super().__init__(**kwargs)
     Clock.schedule_interval(self.update_controle_tir, .1)
     self.launch_time = None
     self.date_since_launch = None
     self.recepteur = recepteur
     self.feu_reception = RelativeLayout()
     self.feu_reception.add_widget(Label(text="Reception:"))
     self.add_widget(self.feu_reception)
Example #31
0
    def build(self):
        self.plot.points = [(point[0], point[1]) for point in
                            self.eog.gesture_list]
        # self.plot.points = [(x, sin(x / 100.)) for x in range(self.counter,
        #                                                       self.counter + 10)]
        self.graph.add_plot(self.plot)

        Clock.schedule_interval(self.update, 1.0 / 60.0)

        return self.graph
Example #32
0
    def animations(self, dt):
        self.manager.current = 'loading'

        anim_big = Animation(angle=10800, duration=250)
        anim_small = Animation(angle=-10800, duration=500)

        anim_big.start(self.manager.ids.loading_screen.ids.big)
        anim_small.start(self.manager.ids.loading_screen.ids.small)

        Clock.schedule_once(self.add_label, 5)
Example #33
0
    def build(self):
        self.plot.points = [(point[0], point[1]) for point in
                            self.user.userECG.ecgListFFT]
        # self.plot.points = [(x, sin(x / 100.)) for x in range(self.counter,
        #                                                       self.counter + 10)]
        self.graph.add_plot(self.plot)

        Clock.schedule_interval(self.update, 1.0 / 60.0)

        return self.graph
 def on_touch_down(self, touch):
     if self.opacity == 0:
         return False
     if self.disabled:
         return False
     if super().on_touch_down(touch):
         Clock.schedule_once(self.show_description, 0.3)
         if self.state == 'down':
             return True
     return False
Example #35
0
 def __init__(self, avatar, **kwargs):
     if not avatar:
         if kwargs['text'].startswith('#'):
             avatar = assets['no_chat_avatar']
         else:
             avatar = assets['no_user_avatar']
     self.avatar = avatar
     kwargs['text'] = kwargs['text'].ljust(18)
     super().__init__(**kwargs)
     Clock.schedule_once(self.init_ui, 0)
Example #36
0
    def button_pressed(self, button):
        if button.text == 'YES':
            self.manager.current = 'main'
            self.popup.dismiss()
        else:
            global CURRENT_PLAYER, AMOUNT, CURRENT1, SOME_LIST1
            row, column = button.coords
            status_index = row * 10 + column
            already_played = self.status[status_index]
            if not already_played and CURRENT_PLAYER == 1:
                self.status[status_index] = CURRENT_PLAYER

                for ship in SHIPS_OF_COMP:
                    if ship[0] == (row, column):
                        CURRENT1 += 1
                        SOME_LIST1.append((row, column))
                        button.background_color = ship[1]
                        #button.text = str(ship[2])
                        self.sound.stop()
                        self.sound = SoundLoader.load('bomb2.wav')
                        self.sound.play()

                        if CURRENT1 == ship[2]:
                            for ship in SOME_LIST1:
                                x, y = ship
                                s = [1, 0, -1]
                                t = [1, 0, -1]
                                for xx in s:
                                    for yy in t:
                                        for child in self.ids.grid.children:
                                            if child.coords == (x + xx, y + yy) and (x + xx, y + yy) not in SOME_LIST1:
                                                child.text = 'X'
                                                child.background_color = [1, 0, 0, 1]
                            SOME_LIST1 = []
                            CURRENT1 = 0

                        AMOUNT += 1
                        if AMOUNT == 4 + 3 * 2 + 2 * 3 + 4:
                            Winner.play()
                            winner.children[0].text = 'You WIN!!!!!'
                            winner.bind(on_dismiss = self.somefunc)
                            winner.open()
                        break

                if button.background_color == [1, 1, 1, 1]:
                    button.text = 'X'

                    self.sound.stop()
                    self.sound = SoundLoader.load('Not_ship.wav')
                    self.sound.play()

                    button.background_color = [1, 0, 0, 1]
                    Clock.schedule_once(self.callback, 1)
                    CURRENT_PLAYER *= -1
Example #37
0
    def on_pre_enter(self):
        for child in self.ids.grid.children:
                child.background_color = [1, 1, 1, 1]

        def my_callback(dt):
            view.dismiss()

        view = ModalView(size=(100, 100))
        view.background = 'img.jpg'
        view.open()
        Clock.schedule_once(my_callback, 5)
Example #38
0
 def __init__(self, **kwargs):
     super(NewsWidget, self).__init__(**kwargs)
     self.app = App.get_running_app()
     app_config = self.app.config
     provider = app_config.get('news', 'provider')
     news_module = imp.load_source(provider, os.path.join(PROJECT_PATH, 'libs', "news", "%s.py" % provider))
     self.news_provider = news_module.News()
     Clock.schedule_interval(self.update_news, 600)
     Clock.schedule_interval(self.rotate_news, app_config.getint('news', 'cycle_interval'))
     self.update_news()
     self.key_handler = self.app.key_handler
     self.key_handler.bind('down', lambda *args: self.rotate_news(direction='next', manual=True))
     self.key_handler.bind('up', lambda *args: self.rotate_news(direction='prev', manual=True))
Example #39
0
 def on_start(self):
     ble_central.init()
     ble_peripheral.init()
     ble_central.set_callbacks(on_state=self.central_state_changed,
                               on_discover=self.discover)
     ble_peripheral.set_callbacks(on_state=self.peripheral_state_changed,
                                  on_service_added=self.peripheral_service_added,
                                  on_service_error=self.peripheral_service_error,
                                  on_advertising_started=self.peripheral_adv,
                                  on_advertising_error=self.peripheral_adv,
                                  on_characteristic_subscribed=self.char_sub,
                                  on_characteristic_write=self.char_write)
     self.scanning = ble_central.is_scanning
     Clock.schedule_interval(self.update_list, 0.5)
Example #40
0
    def __init__(self, **kw):
        super().__init__(**kw)

        self.playlist = StaticPlaylist([

        ])
        self.__cached_playlist = list(self.playlist)
        self.load_audio()

        def update_position(_):
            if self.sound and self.sound.state == 'play':
                self.last_sound_position = self.sound.get_pos()

        Clock.schedule_interval(update_position, 1.5)
Example #41
0
 def on_close_tab(self, instance, *args):
     """Event handler to close icon
     :param instance: tab instance
     """
     self.switch_to(instance)
     if instance.has_modification:
         # show a dialog to ask if can close
         confirm_dlg = ConfirmationDialog("All unsaved changes will be lost.\n" "Do you want to continue?")
         self._popup = Popup(
             title="New", content=confirm_dlg, size_hint=(None, None), size=("200pt", "150pt"), auto_dismiss=False
         )
         confirm_dlg.bind(on_ok=partial(self._perform_close_tab, instance), on_cancel=self._popup.dismiss)
         self._popup.open()
     else:
         Clock.schedule_once(partial(self._perform_close_tab, instance))
Example #42
0
        def pull(*args):
            '''Do a pull in a separated thread
            '''
            try:
                remote_repo.pull(progress=progress)

                def set_progress_done(*args):
                    progress.label.text = 'Completed!'

                Clock.schedule_once(set_progress_done, 1)
                progress.stop()
                show_message('Git remote pull completed!', 5)
            except GitCommandError as e:
                progress.label.text = 'Failed to pull!\n' + str(e)
            get_designer().close_popup()
Example #43
0
    def __init__(self, **kwargs):
        super(ZbarQrcodeDetector, self).__init__(**kwargs)
        # my code
        #
        self.add_widget(self.labell)


        def Course_thread(dt):
            self.labell.text = "24923849"
            self._examplefunc()
            print "r"
            #self.examplefunc("rrrr")

            #self._send_request_dzyk(
            #    'bal_sum/', params=None,
            #    success=self._get_commands_result_dzyk_balance_allsum, error=self._get_commands_error_dzyk)


        Clock.schedule_interval(Course_thread, 1)


        # ID of the command being executed
        self._cmd_id = None

        # List of the "completed" statuses.
        # The first status should be "Done"
        self._completed = []

        # If True - sends a request to retrieve a command status
        self._wait_completion = False

        # requested command
        self._command = (0, '')


        #----------------------------------
        self._camera = AndroidCamera(
                size=self.camera_size,
                size_hint=(None, None))
        self._camera.bind(on_preview_frame=self._detect_qrcode_frame)
        self.add_widget(self._camera)

        # create a scanner used for detecting qrcode
        self._scanner = ImageScanner()
        self._scanner.setConfig(0, Config.ENABLE, 0)
        self._scanner.setConfig(Symbol.QRCODE, Config.ENABLE, 1)
        self._scanner.setConfig(0, Config.X_DENSITY, 3)
        self._scanner.setConfig(0, Config.Y_DENSITY, 3)
Example #44
0
        def push(*args):
            '''Do a push in a separated thread
            '''
            try:
                remote_repo.push(self.repo.active_branch.name,
                                 progress=progress)

                def set_progress_done(*args):
                    progress.label.text = 'Completed!'

                Clock.schedule_once(set_progress_done, 1)
                progress.stop()
                show_message('Git remote push completed!', 5)
            except GitCommandError as e:
                progress.label.text = 'Failed to push!\n' + str(e)
            self._popup.dismiss()
Example #45
0
 def _send_command_result(self, request, response):
     # Parses API-call response
     try:
         if response['status'] not in self._completed:
             # Executing in progress
             self._cmd_id = response['id']
             if self._wait_completion:
                 Clock.schedule_once(self._get_status, 1)
         else:
             # Command "completed"
             if response['status'] == self._completed[0]:
                 self.last_accepted_command = response['code_dsp']
             self._progress_complete(
                 'Command "%s" is %s' %
                 (response['code_dsp'], response['status_dsp']))
     except Exception as e:
         XError(text=str(e)[:256])
Example #46
0
 def _reset_screensaver(self, *args, **kwargs):
     # Change screen only of key is not left/right (what we use to navigate screens)
     if self.screen_manager.current == self.saver_screen and (
                     'key' not in kwargs or kwargs['key'] not in ['right', 'left']):
         while self.screen_manager.current != self.default_screen:
             self._key_left()
     if self.saver_scheduler:
         self.saver_scheduler.cancel()
     if self._screensaver_enabled():
         self.saver_scheduler = Clock.schedule_once(self._start_screensaver,
                                                    float(self.config.get('main', 'screensaver_timeout')))
Example #47
0
 def on_webdebugger(self, *args):
     '''when running from webdebugger'''
     self.dispatch('on_module', mod='webdebugger', data=[])
     Clock.schedule_once(partial(webbrowser.open,
                                 'http://localhost:5000/'), 5)
Example #48
0
 def stop(self):
     '''Start the label updating in a separated thread
     '''
     Clock.unschedule(self.update_text)
Example #49
0
 def show_findmenu(self, visible, *args):
     '''Makes find menu visible/invisible
     '''
     self.in_find = visible
     if visible:
         Clock.schedule_once(self._focus_find)
Example #50
0
 def on_current_tab(self, tabbed_panel, *args):
     '''Event handler to tab selection changes
     '''
     self.show_findmenu(False)
     Clock.schedule_once(partial(self._selected_content, tabbed_panel))
Example #51
0
 def start(self):
     '''Start the label updating in a separated thread
     '''
     Clock.schedule_interval(self.update_text, 0.2)
Example #52
0
 def on_start(self):
     Clock.schedule_interval(self.update, 0)
Example #53
0
 def __init__(self, **kwargs):
     super(DesignerContent, self).__init__(**kwargs)
     self.find_tool.bind(on_close=partial(self.show_findmenu, False))
     self.find_tool.bind(on_next=self.find_tool_next)
     self.find_tool.bind(on_prev=self.find_tool_prev)
     self.focus_code_input = Clock.create_trigger(self._focus_input)
Example #54
0
 def resume_watching(self, delay=1):
     '''Resume the watcher
     :param delay: seconds to start the watching
     '''
     Clock.schedule_once(self._resume_watching, delay)
 def on_webdebugger(self, *args):
     """when running from webdebugger"""
     self.dispatch("on_module", mod="webdebugger", data=[])
     Clock.schedule_once(partial(webbrowser.open, "http://localhost:5000/"), 5)
Example #56
0
    def my_callback(self, dt):
        self.current += dt
        if self.current > 2:
            global CURRENT_PLAYER, LIST_OF_TARGETS1, LIST_OF_TARGETS, CURRENT, SOME_LIST, AMOUNT1, finish
            grid = self.manager.get_screen('board1').ids.grid
            rand = random.randint(0, len(LIST_OF_TARGETS) - 1)
            TARGETS = LIST_OF_TARGETS
            if len(LIST_OF_TARGETS1):
                rand = random.randint(0, len(LIST_OF_TARGETS1) - 1)
                TARGETS = LIST_OF_TARGETS1

            for child in grid.children:
                if child.coords == TARGETS[rand]:
                    if child.background_color == [1, 1, 1, 1]:
                        child.text = 'X'
                        child.background_color = [1, 0, 0, 1]
                        self.popup1.dismiss()
                        Clock.unschedule(self.my_callback)
                        CURRENT_PLAYER *= -1
                        self.sound.stop()
                        self.sound = SoundLoader.load('files/Not_ship.wav')
                        self.sound.play()
                        Clock.schedule_once(self.callback1, 0.7)
                        TARGETS.remove(child.coords)
                    else:
                        x, y = child.coords
                        CURRENT += 1
                        AMOUNT1 += 1
                        SOME_LIST.append((x, y))

                        if (x + 1, y + 1) in TARGETS:
                            TARGETS.remove((x + 1, y + 1))
                        if (x - 1, y - 1) in TARGETS:
                            TARGETS.remove((x - 1, y - 1))
                        if (x + 1, y - 1) in TARGETS:
                            TARGETS.remove((x + 1, y - 1))
                        if (x - 1, y + 1) in TARGETS:
                            TARGETS.remove((x - 1, y + 1))

                        if (x + 1, y + 1) in LIST_OF_TARGETS:
                            LIST_OF_TARGETS.remove((x + 1, y + 1))
                        if (x - 1, y - 1) in LIST_OF_TARGETS:
                            LIST_OF_TARGETS.remove((x - 1, y - 1))
                        if (x + 1, y - 1) in LIST_OF_TARGETS:
                            LIST_OF_TARGETS.remove((x + 1, y - 1))
                        if (x - 1, y + 1) in LIST_OF_TARGETS:
                            LIST_OF_TARGETS.remove((x - 1, y + 1))

                        if (x + 1, y) not in LIST_OF_TARGETS1 and (x + 1, y) in LIST_OF_TARGETS:
                            LIST_OF_TARGETS1.append((x + 1, y))
                            LIST_OF_TARGETS.remove((x + 1, y))
                        if (x - 1, y) not in LIST_OF_TARGETS1 and (x - 1, y) in LIST_OF_TARGETS:
                            LIST_OF_TARGETS1.append((x - 1, y))
                            LIST_OF_TARGETS.remove((x - 1, y))
                        if (x, y - 1) not in LIST_OF_TARGETS1 and (x, y - 1) in LIST_OF_TARGETS:
                            LIST_OF_TARGETS1.append((x, y - 1))
                            LIST_OF_TARGETS.remove((x, y - 1))
                        if (x, y + 1) not in LIST_OF_TARGETS1 and (x, y + 1) in LIST_OF_TARGETS:
                            LIST_OF_TARGETS1.append((x, y + 1))
                            LIST_OF_TARGETS.remove((x, y + 1))

                        child.background_color = [0, 1, 0, 1]
                        AMOUNT1 = 4 + 3 * 2 + 2 * 3 + 4
                        if AMOUNT1 == 4 + 3 * 2 + 2 * 3 + 4:
                            self.popup1.dismiss()
                            Clock.unschedule(self.my_callback)
                            finish = SoundLoader.load('files/proval.mp3')
                            finish.play()
                            winner = ModalView(size_hint=(0.75, 0.5))
                            winner.background = 'files/You_Lost.png'
                            # victory_label = Label(text='You Lost!!!!!', font_size=50)
                            # winner.add_widget(victory_label)
                            winner.bind(on_dismiss=self.somefunc)
                            winner.open()
                            return

                        TARGETS.remove((x, y))
                        if CURRENT == int(child.name):
                            LIST_OF_TARGETS1[:] = []
                            if self.sound != '':
                                self.sound.stop()
                            self.sound = SoundLoader.load('files/boom.mp3')
                            self.sound.play()

                            for ship in SOME_LIST:
                                x, y = ship
                                s = [1, 0, -1]
                                t = [1, 0, -1]
                                for xx in s:
                                    for yy in t:
                                        for child in grid.children:
                                            if child.coords == (x + xx, y + yy) and (x + xx, y + yy) not in SOME_LIST:
                                                child.text = 'X'
                                                child.background_color = [1, 0, 0, 1]
                            SOME_LIST = []
                            CURRENT = 0
                        else:
                            if self.sound != '':
                                self.sound.stop()
                            self.sound = SoundLoader.load('files/bomb2.wav')
                            self.sound.play()
                        self.current = 0
                    return

        child = self.popup1.children[0]
        if child.text[-1:-4:-1] == '...':
            child.text = child.text[:-3]
        else:
            child.text += '.'
Example #57
0
 def _perform_kill_run(self, *args):
     '''Stop the running project/command and then run the project
     '''
     self._popup.dismiss()
     self.stop()
     Clock.schedule_once(self.run)
Example #58
0
 def callback(self, dt):
     self.manager.current = 'board1'
     self.popup1.open()
     self.current = 0
     Clock.schedule_interval(self.my_callback, 1.0)
Example #59
0
    def button_pressed(self, button):
        if button.text == 'YES':
            self.manager.current = 'main'
            self.popup.dismiss()
        else:
            global CURRENT_PLAYER, AMOUNT, CURRENT1, SOME_LIST1, finish
            row, column = button.coords
            status_index = row * 10 + column
            already_played = self.status[status_index]
            if not already_played and CURRENT_PLAYER == 1:
                self.status[status_index] = CURRENT_PLAYER

                for ship in SHIPS_OF_COMP:
                    if ship[0] == (row, column):
                        CURRENT1 += 1
                        SOME_LIST1.append((row, column))
                        button.background_color = ship[1]
                        # button.text = str(ship[2])
                        if CURRENT1 == ship[2]:
                            if self.sound != '':
                                self.sound.stop()
                            self.sound = SoundLoader.load('files/boom.mp3')
                            self.sound.play()

                            for ship in SOME_LIST1:
                                x, y = ship
                                s = [1, 0, -1]
                                t = [1, 0, -1]
                                for xx in s:
                                    for yy in t:
                                        for child in self.ids.grid.children:
                                            if child.coords == (x + xx, y + yy) and (x + xx, y + yy) not in SOME_LIST1:
                                                child.text = 'X'
                                                child.background_color = [1, 0, 0, 1]
                            SOME_LIST1 = []
                            CURRENT1 = 0
                        else:
                            if self.sound != '':
                                self.sound.stop()
                            self.sound = SoundLoader.load('files/bomb2.wav')
                            self.sound.play()

                        AMOUNT += 1
                        AMOUNT = 4 + 3 * 2 + 2 * 3 + 4
                        if AMOUNT == 4 + 3 * 2 + 2 * 3 + 4:
                            finish = SoundLoader.load('files/winner.mp3')
                            finish.play()
                            winner = ModalView(size_hint=(0.75, 0.5))
                            winner.background = 'files/youWin.png'
                            # victory_label = Label(text='You WIN!!!!!', font_size=50)
                            # winner.add_widget(victory_label)
                            winner.bind(on_dismiss=self.somefunc)
                            winner.open()
                        break

                if button.background_color == [1, 1, 1, 1]:
                    button.text = 'X'
                    if self.sound != '':
                        self.sound.stop()
                    self.sound = SoundLoader.load('files/Not_ship.wav')
                    self.sound.play()

                    button.background_color = [1, 0, 0, 1]
                    Clock.schedule_once(self.callback, 1)
                    CURRENT_PLAYER *= -1
Example #60
0
 def __init__(self, **kwargs):
     super(NavigationDrawerIconButton, self).__init__(**kwargs)
     self._set_active_color()
     self.theme_cls.bind(primary_color=self._set_active_color_primary, accent_color=self._set_active_color_accent)
     Clock.schedule_once(lambda x: self.on_icon(self, self.icon))