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


Python ModalView.dismiss方法代码示例

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


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

示例1: ButtonTreeItem

# 需要导入模块: from kivy.uix.modalview import ModalView [as 别名]
# 或者: from kivy.uix.modalview.ModalView import dismiss [as 别名]
class ButtonTreeItem(Button):
  def __init__(self, num, outward, **kwargs):
    super(ButtonTreeItem, self).__init__(**kwargs)
    self.size = (20, window_height/btnHeightRate) # 20 isn't change anything
    self.size_hint_y = None
    self.num = num
    self.context = False
    self.outward = outward

  def on_touch_down(self, touch):
    if self.collide_point(*touch.pos):
      self.create_clock()
    return super(ButtonTreeItem, self).on_touch_down(touch) 
  def on_touch_up(self, touch):
    if self.collide_point(*touch.pos):
      self.delete_clock()
      if self.context :
        self.context = False
        return True 
    return super(ButtonTreeItem, self).on_touch_up(touch) 

  def create_clock(self, *args):
    Clock.schedule_once(self.openContextMenu, timeOut_forContextMenu)
  def delete_clock(self, *args):
    Clock.unschedule(self.openContextMenu)

  def openContextMenu(self, *args):
    self.context = True
    self.contextMenu = ModalView(size_hint=(0.5, 0.5))
    self.contextMenu.bind(on_dismiss=self.outward.showTree())
    contextLayout = BoxLayout(
        padding = 10,
        spacing = 10,
        pos_hint = {'center_x': 0.5, 'center_y': 0.5}, 
        size_hint = (0.7, 0.8), 
        orientation = 'vertical')
    contextLayout.add_widget(Label(text=self.text))
    btnDelete = Button(text='delete')
    btnDelete.bind(on_press=self.delete)
    contextLayout.add_widget(btnDelete)
    close = Button(text='close')
    close.bind(on_release=self.contextMenu.dismiss)
    contextLayout.add_widget(close)
    self.contextMenu.add_widget(contextLayout)
    self.contextMenu.open()
  def delete(self, *args):
    tree.curItem().remove(self.num)
    self.contextMenu.dismiss()
    self.outward.showTree()
开发者ID:snaiffer,项目名称:TreeNote,代码行数:51,代码来源:main.py

示例2: HomeScreen

# 需要导入模块: from kivy.uix.modalview import ModalView [as 别名]
# 或者: from kivy.uix.modalview.ModalView import dismiss [as 别名]
class HomeScreen(Screen):
    def workout_options(self):
        layout = BoxLayout(orientation='vertical')

        blank_btn = Button(text='Start Blank', size_hint=[.8, 1],
                pos_hint={'x': .1}, on_release=self.new_workout)
        template_btn = Button(text='Start from Template', size_hint=[.8, 1],
                pos_hint={'x': .1})
        previous_btn = Button(text='Copy from Previous', size_hint=[.8, 1],
                pos_hint={'x': .1})

        layout.add_widget(blank_btn)
        layout.add_widget(template_btn)
        layout.add_widget(previous_btn)

        self.popup = ModalView(content=layout, size_hint=[1, .5],
                pos_hint={'top': .5})
        self.popup.add_widget(layout)

        self.popup.open()

    def new_workout(self, instance):
        self.popup.dismiss()
        self.manager.current = 'workout'
开发者ID:Aaron1011,项目名称:domorereps-android,代码行数:26,代码来源:screens.py

示例3: BoardScreen2

# 需要导入模块: from kivy.uix.modalview import ModalView [as 别名]
# 或者: from kivy.uix.modalview.ModalView import dismiss [as 别名]
class BoardScreen2(Screen):
    status = ListProperty([0 for i in range(100)])
    coords = ListProperty([0, 0])
    popup1 = ModalView(size_hint=(0.3, 0.0), auto_dismiss=False)
    popup1.pos_hint = {'x': 0.35, 'y': 0.9}
    popup1.add_widget(Label(text='Computers Turn, Please wait...', font_size=26))
    current = 0
    sound = ''

    def on_enter(self):
        global ENTRY_COMP

        if ENTRY_COMP == 0:
            ENTRY_COMP = 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.coords = (i, j)
                    button.bind(on_press=self.button_pressed)
                    self.ids.grid.add_widget(button)

    def exit(self):
        self.popup = ModalView(size_hint=(0.5, 0.4))
        grd = GridLayout()
        grd.cols = 2
        grd.padding = 120
        flt = FloatLayout()
        lbl = Label(pos=(320, 340), text='Are you sure to exit game????', font_size=35)
        flt.add_widget(lbl)
        btn1 = Button(text='YES', font_size=50)
        btn1.bind(on_press=self.button_pressed)
        btn2 = Button(text='NO', font_size=50)
        btn2.bind(on_press=self.popup.dismiss)
        grd.add_widget(btn1)
        grd.add_widget(btn2)
        self.popup.add_widget(flt)
        self.popup.add_widget(grd)
        self.popup.open()

    # def somefunc(self, *args):
    #     self.manager.current = 'main'
    #
    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

#.........这里部分代码省略.........
开发者ID:Xayom,项目名称:Battleship_Kivy,代码行数:103,代码来源:main.py

示例4: PitstopTimerView

# 需要导入模块: from kivy.uix.modalview import ModalView [as 别名]
# 或者: from kivy.uix.modalview.ModalView import dismiss [as 别名]

#.........这里部分代码省略.........
        if self.current_speed > self._pitstop_trigger_speed:
            self._set_exit_speed_frame_visible(True)
        self._update_speed_color()

    def _stop_stopwatch(self):
        '''
        Stops the stopwatch timer
        '''
        Clock.unschedule(self._tick_stopwatch)
        self.current_time = STOPWATCH_NULL_TIME

    def _in_race_mode(self):
        '''
        Return True if we think we're in 'racing mode'
        '''
        return self.current_speed > self._pitstop_exit_speed and\
            self.current_lap > 0

    def user_preferences_updated(self, user_preferences):
        '''
        Update runtime values from user preferences
        '''
        self._pitstop_timer_enabled = user_preferences.get_pref_bool('dashboard_preferences', 'pitstoptimer_enabled')
        self._pitstop_trigger_speed = user_preferences.get_pref_int('dashboard_preferences', 'pitstoptimer_trigger_speed')
        self._pitstop_exit_speed = user_preferences.get_pref_int('dashboard_preferences', 'pitstoptimer_exit_speed')
        self._pitstop_alert_speed = user_preferences.get_pref_int('dashboard_preferences', 'pitstoptimer_alert_speed')

    def _start_stopwatch(self):
        '''
        Starts the stopwatch timer
        '''

        if not self._popup:
            self._popup = ModalView(size_hint=self._POPUP_SIZE_HINT, auto_dismiss=False)
            self._popup.add_widget(self)
        self._set_exit_speed_frame_visible(False)
        self._popup.open()
        self._current_time = 0.0
        self._start_time = time()
        self._flash_count = 0
        self._currently_racing = False
        Clock.schedule_interval(self._tick_stopwatch, self._STOPWATCH_TICK)

    def _is_popup_open(self):
        '''
        Indicates if current popup is open
        :return True if popup is currently open
        '''
        return self._popup and self._popup._window is not None

    def _flash_pit_stop_time(self, *args):
        '''
        Flashes the final pit stop time when complete
        '''
        self.current_time = self._format_stopwatch_time() if self._flash_count % 2 == 0 else ''
        self._flash_count += 1
        if self._flash_count < self._FLASH_COUNT * 2:
            Clock.schedule_once(self._flash_pit_stop_time, self._FLASH_INTERVAL)
        else:
            self._popup.dismiss()

    def _finish_stopwatch(self):
        '''
        Finish the current stopwatch
        '''
        self._flash_count = 0
开发者ID:autosportlabs,项目名称:RaceCapture_App,代码行数:70,代码来源:stopwatch.py

示例5: rootEngine

# 需要导入模块: from kivy.uix.modalview import ModalView [as 别名]
# 或者: from kivy.uix.modalview.ModalView import dismiss [as 别名]
class rootEngine(FloatLayout):


#    def mp(self,mn):
#        # {
#        def __init__(**kwargs):
#            super(mp,self).__init__(self)
#            
#        def lambida(object):
#            lambda mn, mn * mn // .2 ## get power
#            
#        def squary(object):
#            lambda mn: mn ** mn / 2
        # } 
        
# just some dictionaries below        

    def __init__(self,**kwargs):
        """
        Main Engine
        """
        super(rootEngine,self).__init__(**kwargs)
        self.rstView(name="coreEngine/Rst/index.rst")
        self.Config = None
        self.savedSource = "" # None Immutable
        self.current = "" # None Immutable
        _savedInts = open("coreEngine/Rst/saved.ctex","r")
        self.saved = 0
        self.savedMake = 0
        self.iterSaved = 0
        self.toMakeSaved = None
        self.coreTexMimes = {
            "index":"coreEngine/Rst/index.rst",
            "code":"coreEngine/Rst/code.rst",
            "help":"coreEngine/Rst/help.rst",
            "new":"coreEngine/Rst/new.rst",
            "web":"coreEngine/Rst/web.rst",
            "cache":"coreEngine/Rst/cache.rst",
            "saved":"coreEngine/Rst/saved.ctex",
            "cleared":"coreEngine/Rst/cleared.rst",
            } # .rst = ReST File ,  .ctex = CoreTEX File


    def getLatestSaved(self):
        _openFile = open(self.coreTexMimes["saved"],"r") # .ctex is the Mimetype for the CoreTEX File
        _contents = _openFile.read()
        _openFile.close()
        #if _openFile.close():
        eval_isDangerous = eval(_contents)
        for Ints in eval_isDangerous:
            Latest =  int(max(eval_isDangerous)) # Latest Enumeration
            Iterable = list(eval_isDangerous) # List / Array
            break
        self.saved = Latest
        self.iterSaved = Iterable 


    def reloadCode(self):
        """
        reload Compiler
        """
        self.rstView(name=str(self.current))


    def loadRemotely(self):
        """
        Load Remotely (web)
        """
        toDownload = ""
        main = Popup(title="Load .RST Document Remotely",
                     size_hint=(.9,.4))
        layer = FloatLayout()
        cancelBtn = Button(text="Cancel",
                           size_hint=(.4,.12),
                           pos_hint={"x":.10,"y":0.04}) # 100% - hint (divide if needed)
        openBtn = Button(text="Load",
                           size_hint=(.4,.12),
                           pos_hint={"x":.50,"y":0.04})                         
        desc = "Make sure to load a raw RST Source"
        descWid = Label(text=str(desc),size_hint=(.4,.4),
                                pos_hint={"x":0.30,
                                "y":0.50})
        url_box = TextInput(text="http://",
                            size_hint=(.8,0.15),
                            pos_hint={"x":0.10,"y":0.24},
                            multiline = False)


        def closePop(object):
            
            """
            Close Popups
            INNER FUNC
            """
            main.dismiss()
            
        
        def LabelError(object):
            """
            Exception Message
#.........这里部分代码省略.........
开发者ID:onecore,项目名称:rest-viewer-app,代码行数:103,代码来源:main.py

示例6: MainScreen

# 需要导入模块: from kivy.uix.modalview import ModalView [as 别名]
# 或者: from kivy.uix.modalview.ModalView import dismiss [as 别名]
class MainScreen(Screen):
  def __init__(self, **kwargs):
    super(MainScreen, self).__init__(**kwargs)

    mainLayout = GridLayout(cols=1)

    global window_height
    window_height = mainLayout.height
    # top
    btnBack = Button(text='Back', size_hint_x=0.1)
    
    self.lblPath = Label(size_hint_x=0.8, color = color['lblPath'])
    self.lblPath.anchors_x = 'left'
    btnAdd = Button(text='+', size_hint_x=0.1)
    topLayout = BoxLayout(size_hint_y = 0.1)
    topLayout.add_widget(btnBack)
    topLayout.add_widget(self.lblPath)
    topLayout.add_widget(btnAdd)
    mainLayout.add_widget(topLayout) 
    btnAdd.bind(on_press=self.addMenu)
    # Content
    scroll = ScrollView(size_hint=(1,1), do_scroll_x=False)
    self.contentLayout = GridLayout(cols = 1, padding = 10, spacing = 10, size_hint_y = None)
    self.contentLayout.bind(minimum_height=self.contentLayout.setter('height'))  # for scrolling
    scroll.add_widget(self.contentLayout)
    mainLayout.add_widget(scroll)
    btnBack.bind(on_press=self.goBack)

    self.add_widget(mainLayout)
    self.showTree()

    self.win = Window

    mainLayout.bind(
          size=self._update_rect,
          pos=self._update_rect)
    with mainLayout.canvas.before:
      Color(0.5, 0.8, 1, 0.9) 
      self.rect = Rectangle(
                  size=mainLayout.size,
                  pos=mainLayout.pos)
  def _update_rect(self, instance, value):
    self.rect.pos = instance.pos
    self.rect.size = instance.size

  def on_pre_enter(self, *args):
    self.win.bind(on_keyboard=self.keyboardHandler)
    self.showTree()
    
  def on_pre_leave(self):
    self.win.unbind(on_keyboard=self.keyboardHandler)

  def keyboardHandler(self, window, keycode1, keycode2, text, modifiers):
    if keycode1 == systemBtnBack:
      if tree.reachRoot():
        self.doExit()
      else:  
        self.goBack()
      return True
    return False

  def doExit(self, *args):
    self.contextMenu = ModalView(size_hint=(0.5, 0.5))
    mainLayout = BoxLayout(
        padding = 10,
        spacing = 10,
        pos_hint = {'center_x': 0.5, 'center_y': 0.5}, 
        size_hint = (0.7, 0.8), 
        orientation = 'vertical')
    mainLayout.add_widget(Label(text='Exit?'))
    chooserField = BoxLayout()
    btnAddBranch = Button(text='yes')
    chooserField.add_widget(btnAddBranch)
    btnAddBranch.bind(on_press=MainScreen.exit)
    close = Button(text='no')
    close.bind(on_release=self.contextMenu.dismiss)
    chooserField.add_widget(close)
    mainLayout.add_widget(chooserField)

    self.contextMenu.add_widget(mainLayout)
    self.contextMenu.open()
  
  def exit(*args):
    raise wantExit

  def showTree(self, *args):  
    self.contentLayout.clear_widgets()
    self.lblPath.text = tree.getPath()
    counter = 0
    for cur in tree.curItem().get():
      if isinstance(cur, Branch):
        btnBranch = ButtonBranch(text=cur.name, num=counter, outward=self)
        btnBranch.bind(on_release=btnBranch.goHere)
        btnBranch.bind(on_release=self.showTree)
        self.contentLayout.add_widget(btnBranch)
      if isinstance(cur, Leaf):
        self.contentLayout.add_widget(ButtonLeaf(text=cur.name, num=counter, outward=self))
      counter += 1  

  def goBack(self, *args):
#.........这里部分代码省略.........
开发者ID:snaiffer,项目名称:TreeNote,代码行数:103,代码来源:main.py

示例7: CpuPlayer

# 需要导入模块: from kivy.uix.modalview import ModalView [as 别名]
# 或者: from kivy.uix.modalview.ModalView import dismiss [as 别名]
class CpuPlayer():

    EXACT = 0
    LOWERBOUND = -1
    UPPERBOUND = 1

    def __init__(self,cputype,**kwargs):
        self.type = cputype
        self.transtable = {}

        self.view = ModalView(size_hint=(0.4, 0.1),auto_dismiss=False)
        self.view.add_widget(SimpleModal(text="CPU Moving..."))

    @mainthread
    def showModal(self):
        self.view.open()

    @mainthread
    def hideModal(self):
        self.view.dismiss()

    # hg is hexgrid
    def move(self,hg,*largs):

        self.showModal()
        opt = {
            GAMETYPE["IA_DUMMY"]: self.mvDummy,
            GAMETYPE["IA_EASY"]: self.mvNegamax,
        }

        opt[self.type](hg)
        self.hideModal()
        return True
        

    def mvDummy(self,hg):
        time.sleep(0.5) # we need a minimum time

        sz = hg.gridsize
        possibles = list(itertools.product(range(0,sz),range(0,sz)))

        finished = False
        while not finished:
            if not len(possibles): break # sortim i passem
            
            x,y = random.choice(possibles)
            t = hg.grid[x][y]
            if t and t.content == 0:
                state = hg.getState()
                if hg.doMovement(t):
                    finished = True
                hg.loadState(state)

            if not finished:
                possibles.remove((x,y))
        else:
            # Trobat, juguem
            hg.manageTurn(t,False)
            return

        # No trobat, passem
        hg.doPass(False)

    def negamax(self,hg,ply,alpha,beta,color,player):
        alphaOrig = alpha

        # Busquem en transp table
        key = str(hg.getState())
        if key in self.transtable:
            ttentry = self.transtable[key]
            if ttentry['ply'] >= ply:
                if ttentry['flag'] == CpuPlayer.EXACT:
                    return ttentry['value'],None,None
                elif ttentry['flag'] == CpuPlayer.LOWERBOUND:
                    alpha = max(alpha,ttentry['value'])
                elif ttentry['flag'] == CpuPlayer.UPPERBOUND:
                    beta = min(beta,ttentry['value'])
                if alpha >= beta:
                    return ttentry['value'],None,None

        if ply == 0:
            score = hg.score()
            return score[player]*color,None,None

        bestValue = float('-infinity')
        bestX = None
        bestY = None
        sz = hg.gridsize
        moves = list(itertools.product(range(0,sz),range(0,sz)))
        random.shuffle(moves)

        for x,y in moves:

            doPass = False
            if x == 0 and y == 0: # Sempre es None, la fem servir com a "passar" per poder-ho integrar al bucle
                doPass = True
            else:
                t = hg.grid[x][y]
                if not t: continue

#.........这里部分代码省略.........
开发者ID:afibanez,项目名称:hexland,代码行数:103,代码来源:cpuplayer.py


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