当前位置: 首页>>代码示例>>Python>>正文


Python Clock.unschedule方法代码示例

本文整理汇总了Python中kivy.properties.Clock.unschedule方法的典型用法代码示例。如果您正苦于以下问题:Python Clock.unschedule方法的具体用法?Python Clock.unschedule怎么用?Python Clock.unschedule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kivy.properties.Clock的用法示例。


在下文中一共展示了Clock.unschedule方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: my_callback

# 需要导入模块: from kivy.properties import Clock [as 别名]
# 或者: from kivy.properties.Clock import unschedule [as 别名]
    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')
#.........这里部分代码省略.........
开发者ID:Xayom,项目名称:Battleship_Kivy,代码行数:103,代码来源:main.py

示例2: stop

# 需要导入模块: from kivy.properties import Clock [as 别名]
# 或者: from kivy.properties.Clock import unschedule [as 别名]
 def stop(self):
     '''Start the label updating in a separated thread
     '''
     Clock.unschedule(self.update_text)
开发者ID:Python-PyBD,项目名称:kivy-designer,代码行数:6,代码来源:designer_git.py

示例3: my_callback

# 需要导入模块: from kivy.properties import Clock [as 别名]
# 或者: from kivy.properties.Clock import unschedule [as 别名]
    def my_callback(self, dt):
        self.current += dt
        if self.current > 5:
            global CURRENT_PLAYER, LIST_OF_TARGETS1, LIST_OF_TARGETS, CURRENT, SOME_LIST, AMOUNT1
            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('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]
                        if AMOUNT1 == 4 + 3 * 2 + 2 * 3 + 4:
                            self.popup1.dismiss()
                            Clock.unschedule(self.my_callback)
                            Lose.play()
                            winner.children[0].text = 'You Lost!!!!!'
                            winner.bind(on_dismiss = self.somefunc)
                            winner.open()
                            return

                        TARGETS.remove((x, y))
                        if CURRENT == int(child.name):
                            LIST_OF_TARGETS1[:] = []
                            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

                        self.current = 0
                        self.sound.stop()
                        self.sound = SoundLoader.load('bomb2.wav')
                        self.sound.play()
                    return

        child = self.popup1.children[0]
        if child.text[-1:-4:-1] == '...':
            child.text = child.text[:-3]
        else:
            child.text += '.'
开发者ID:Xayom,项目名称:Battleship_Kivy,代码行数:100,代码来源:Battleship.py


注:本文中的kivy.properties.Clock.unschedule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。