I’m not sure I understand your question, but here is an example of a popup that takes a message at runtime. I use something similar for errors.
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.popup import Popup
from kivy.properties import StringProperty
kv = """
#:import Factory kivy.factory.Factory
<ErrorPopup>:
title: 'Error'
BoxLayout:
orientation: 'vertical'
Label:
text: root.error_msg
Button:
size_hint_y: None
height: 48
text: 'Okay'
on_release: root.dismiss()
BoxLayout:
orientation: 'vertical'
Button:
text: 'Press Error Popup 1'
on_release: Factory.ErrorPopup(error_msg='Error Message Number One').open()
Button:
text: 'Press Error Popup 2'
on_release:Factory.ErrorPopup(error_msg='A non-fatal error has occurred').open()
Button:
text: 'Press Error Popup 3'
on_release: Factory.ErrorPopup(error_msg='You lose, your get nothing!').open()
Button:
text: 'Press Error Popup 4, from python'
on_release: app.error('Oh My, somthing has happened here!')
"""
class ErrorPopup(Popup):
error_msg = StringProperty()
class ErrorPopApp(App):
def build(self):
return Builder.load_string(kv)
def error(self, text):
ErrorPopup(error_msg=text).open()
ErrorPopApp().run()
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/ed9c9c1e-8999-4506-99db-b2d305894755n%40googlegroups.com.
<WrongPopup>:
title: ''
separator_height: 0
size_hint:(None, None)
size:(350, 150)
auto_dismiss: False
BoxLayout:
orientation: 'vertical'
Label:
text: app.root.ids.sm.get_screen('Screen_1').ids.ti.text + 'is wrong guess...Try again!'
FloatLayout:
#orientation:'horizontal'
#size_hint_y:None
#height:30
#spacing: 10
Button:
text:'Yes'
size_hint: .2,.5
pos_hint:{'x':.4, 'y':.3}
on_press: root.dismiss()
Button:
text:'No'
size_hint: .2,.5
pos_hint:{'x':.6, 'y':.3}
on_press: app.stop()
RootBox:
ScreenManager:
id: sm
HomeScreen:
Screen1:
Screen2:
'''
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/603422b3.1c69fb81.1d494.e6ddSMTPIN_ADDED_MISSING%40gmr-mx.google.com.
If you want to instance a popup in kv, use Factory as I did in the example I posted previously. Note that Factory was imported into kv
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CABDb-Vhv505oRd%3DP%3DyznL-wUCg2z3Q-Nb3A%2Bz5%3DstK3F9xTLUA%40mail.gmail.com.