from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.popup import Popup
from kivy.uix.widget import Widget
class P(FloatLayout):
pass
class Popup1(Widget):
def btn(self):
popupWindow = Popup(title="Popup Window", content=P(),
size_hint=(None, None), size=(400, 400))
popupWindow.open()
class PopupApp(App):
def build(self):
return Popup1()
PopupApp().run()
-------------------------------
#popup.kv
<Popup1>:
Button:
text: "Open popup"
size: root.width, 0.2*root.height
on_release: root.btn()
<p>:
Label:
text: "Popup button pressed"
size_hint: 0.6, 0.2
pos_hint: {"x":0.2, "top":1}
Button:
text: "click outside to close popup"
size_hint: 0.8, 0.2
pos_hint: {"x": 0.1, "y":0.1}
reference:
No comments:
Post a Comment