dimanche 18 octobre 2020

in kivy Popup automatically dismisses once checkbox becomes active

I have a problem in kivy . i am using a Md Checkbox and i want that whenever the checkbox is active a popup should open. though Popup opens but in less then a second it dismisses. How can I fix this??

I am using kivy 1.10.1 and python3 and my os in ubuntu 20.04

my main python file :

import kivy
import kivymd
kivy.require('1.10.1')
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.uix.popup import Popup
from kivy.uix.screenmanager import ScreenManager,Screen
from kivy.uix.gridlayout import GridLayout

    
class WindowManager(ScreenManager):
    pass 
    
class SecondWindow(Screen):
    
    def pop_(self,checkbox,active):
        if active:
            self.popup = pop_up()



class time_intrvl(GridLayout): 
    pass


class ExamPortal(MDApp):

    def build(self):
        kv = Builder.load_file('my.kv')        
        return kv
        
def pop_up():
    pop_window = time_intrvl()
    PopUpWindow = Popup(title = 'Trial' ,content = pop_window,size_hint = (0.5,0.3))
    PopUpWindow.open()     
    return PopUpWindow    
            

if __name__ == "__main__":
    ExamPortal().run()

and my.kv file

        
<time_intrvl>:

    TextInput:
        id : my_field
        multiline : False
        pos_hint : {'x':0.1 , 'top': 0.74}
        size_hint : None,None
        size : 200,60
        font_size : 26

            
WindowManager:

    SecondWindow:
              
<SecondWindow>
    name : 'sec_wind'
    
    GridLayout:
        cols : 1
        MDCheckbox:
            on_active:
                root.pop_(self,self.active)                

Any help is apperciated




Aucun commentaire:

Enregistrer un commentaire