I am new to App development, Kivy and Python. I tried to show a popup on a button click. When click "Cancel" button on popup, it should get dismissed. I think there is a mistake in my code. When i clicked on 'Cancel' button on popup, nothing happening. Can anyone help me?
import kivy
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.uix.popup import Popup
class NotesMainScreen(FloatLayout):
def Download(self,btn):
DownloadCompletePopup().run()
def __init__(self,**kwargs):
super(NotesMainScreen, self).__init__(**kwargs)
self.add_widget(Label(text="Welcome ", pos=(100, 300), size_hint = (.1,.05)))
self.Url = TextInput(multiline = False, pos=(200, 300), size_hint = (.1,.05))
self.add_widget(self.Url)
btnRun = Button(text="Run", pos=(300,300), size_hint = (.1,.05))
btnRun.bind(on_press = self.Download)
self.add_widget(btnRun)
class DownloadCompletePopup(App):
#override the build method and return the root widget of this App
def build(self):
# Define a layout for this App
self.layout = FloatLayout()
popupLabel = Label(text = "Hoorey Completed!!", pos=(300,300), size_hint = (.3,.1))
closeButton = Button(text = "Close", pos=(320,250), size_hint = (.2,.2))
self.layout.add_widget(popupLabel)
self.layout.add_widget(closeButton)
# Instantiate the modal popup and display
popup = Popup(title='Donwload Completed', content=self.layout, pos=(300,300), size_hint=(.4, .3), auto_dismiss=False)
# Attach close button press with popup.dismiss action
closeButton.bind(on_press = popup.dismiss)
popup.open()
class Notes(App):
def build(self):
return NotesMainScreen()
if __name__ == '__main__':
Notes().run()