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.
Popup widget :
- 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.
- Popup dialogs are used ]when we have to convey certain obvious messages to the user. Messages to the user through status bars as well for specific messages which need to be told with emphasis can still be done through popup dialogs.
- 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.
To use popup you must have to import :
from kivy.uix.popup import Popup
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.
Basic Approach : 1) import kivy 2) import kivyApp 3) import Label 4) import button 5) import Gridlayout 6) import popup 7) Set minimum version(optional) 8) create App class 9) return Layout/widget/Class(according to requirement) 10) In the App class create the popup 11) Run an instance of the class
When click on screen popup will open like this:
When click on Close the popup it will close.
In the second code when we use the size_hint and the size we can give the size accordingly. In this just add something as in the below code in line number 75.
Popup size will be smaller than the window size.
- Python | Popup widget in Kivy using .kv file
- Python | Spinner widget in kivy
- Python | Switch widget in Kivy
- Python | Progress Bar widget in kivy
- Python | Scrollview widget in kivy
- Python | Add image widget in Kivy
- Python | BoxLayout widget in Kivy
- Python | Textinput widget in kivy
- Python | Carousel Widget In Kivy
- Python | Slider widget in Kivy
- Python | Checkbox widget in Kivy
- Python | Carousel Widget In Kivy using .kv file
- Python | Switch widget in Kivy using .kv file
- Python | Spinner widget in Kivy using .kv file
- Python | Progressbar widget in kivy using .kv file
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.