Kivy is a platform independent GUI tool in Python. As it can be run on Android, IOS, linux and Windows etc. It is basically used to develop the Android application, but it does not mean that it can not be used on Desktops applications.
To use popup you must have to import :
from kivy.uix.popup import Popup
The Popup widget is used to create popups. By default, the popup will cover the whole “parent” window. When you are creating a popup, you must at least set a Popup.title and Popup.content.
Keep one thing in mind that the default size of a widget is size_hint=(1, 1). If you don’t want your popup to be on the full screen you must gave either size hints with values less than 1 (for instance size_hint=(.8, .8)) or deactivate the size_hint and use fixed size attributes.
Note: Popup is a special widget. Don’t try to add it as a child to any other widget. If you do, Popup will be handled like an ordinary widget and won’t be created hidden in the background, like:
1) import kivy 2) import kivyApp 3) import Widget 4) import Floatlayout 5) import Label 6) import popup 7) Set minimum version(optional) 8) Create widget class 9) Create Layout class : 10) create App class 9) create .kv file (name same as the app class): 1) create Widget 2) create popup 3) Give label to popup 4) create button to close popup 10) return Layout/widget/Class(according to requirement) 11) define popup function(Which shows the popup on press the button) 12) Run an instance of the class
Implementation of the Approach:
.kv file implementation:
When button press popup appears, click anywhere in the window except popup screen popup will dissappear:
- Python | Popup widget in Kivy
- Python | Switch widget in Kivy using .kv file
- Python | Carousel Widget In Kivy using .kv file
- Python | Progressbar widget in kivy using .kv file
- Python | Spinner widget in Kivy using .kv file
- Python | Checkbox widget in Kivy
- Python | Scrollview widget in kivy
- Python | Textinput widget in kivy
- Python | Add image widget in Kivy
- Python | Carousel Widget In Kivy
- Python | BoxLayout widget in Kivy
- Python | Slider widget in Kivy
- Python | Spinner widget in kivy
- Python | Switch widget in Kivy
- Python | Progress Bar widget in kivy
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.