from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.modalview import ModalView
from kivy.clock import Clock
from kivy.uix.label import Label
class TestApp(App):
def build(self):
root = BoxLayout(orientation='vertical')
Clock.schedule_once(self._init, 2) # popup after some time
return root
def my_callback(self, instance):
print('ModalView', instance, 'is being dismissed, but is prevented!')
return True
def _init (self, dt):
view = ModalView(size_hint=(None,None), size=(200,75))
view.add_widget(Label(text='Hello world'))
view.bind(on_dismiss=self.my_callback)
view.open()
print "***** END *****"
TestApp().run()
--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/6tbZl9VCccs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
That's an interesting one. Is it essential to do all the work in one sweep? Could you not do an initial parse to gather data, then do the popup, then do another parse to apply the gathered user input? Kind like how encoding tools do an analysis before they begin the actual encoding?
--
class Waiter(object):
wait = True
@staticmethod
def return_when_done():
Waiter.wait = True
while Waiter.wait:
sleep(0.25)
Waiter.wait = False
# let thread die
class Waiter(object):
waiters = []
@staticmethod
def return_when_done(obj):
""" obj needs to be unique to each call """
Waiter.waiters.append(obj)
while obj in Waiter.waiters:
sleep(0.25)
@staticmethod
def done():
Waiter.waiters.pop()
import sys
import time
import threading
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import BooleanProperty
from kivy.lang import Builder
from kivy.uix.popup import Popup
Builder.load_string('''
<TestView>:
okBtn: idOK
orientation: "vertical"
Label:
text: "Testing Blocking View"
Button:
id: idOK
text: "OK"
''')
class TestView(BoxLayout):
blocking = BooleanProperty(False)
popup = None
def __init__(self, **kwargs):
super(TestView, self).__init__(**kwargs)
self.okBtn.bind( on_release=self.OnPress )
def open (self):
self.popup = Popup(title = "Testing...",
content = self,
size_hint = (None, None),
size = (250,150),
auto_dismiss = False )
self.popup.open()
if self.blocking:
if threading.current_thread().name != "MainThread":
# NOT executing on the main thread so allow blocking
while(self.blocking):
time.sleep(0.25)
self.popup.dismiss()
def OnPress (self, *args):
print "PRESSED:", args[0].text
if self.blocking == False:
self.popup.dismiss()
self.blocking = False
class TestApp(App):
def build(self):
root = BoxLayout(orientation='vertical')
self.startParsing()
return root
def parse (self, *args):
print "Parsing", args[0]
time.sleep(2.0)
print "Open View..."
view = TestView( blocking=True )
view.open()
print "***** AFTER OPEN EXECUTED *****"
def startParsing (self):
t = threading.Thread( target=self.parse, args = ["/tmp/file"] )
t.start()
TestApp().run()