Python Kivy Creating Popup Window

This is our twelfth article in Python Kivy, in this article we are going to learn Creating Kivy Popup Window.

The Popup widget is used to create modal 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.

Remember that the default size of a Widget is size_hint=(1, 1). If you don’t want your popup to be full screen, either use size hints with values less than 1 (for instance size_hint=(.8, .8)) or deactivate the size_hint and use fixed size attributes.

 

 

 

Also if you are interested in Python GUI Development with different libraries, you can check the below links.

1: PyQt5 GUI Development Tutorials

2: Pyside2 GUI Development Tutorials 

3: wxPython GUI Development Tutorials

4: TKinter GUI Development Tutorials 

 

 

 

 

Also you can watch the complete video for this article

 

 

 

 

OK so first of all create a python file , and add these codes in that file. our first class extends from Popup class and we are not going to add anything in that class, the second class extends from RelativeLayout class, because we want to use Relative Layout in this tutorial. and we simply create a method in here, because in my gui i will have a button and i want to connect this method with that button, in this method we have created our Popup class object. after that we have created our main class that extends from the App class, and we have returned our MyRelativeLayout class in our main class .

 

 

 

 

Now let’s create our .kv file, i have named my kv file popupwindow.kv, make sure that this name should be similar to the main  class name, in my case it is PopUpWindow class. we are going to define some rules for our RelativeLayout also we are going to add a button in our Relative Layout.

 

 

 

 

You can see that we have connected our button from MyRelative class in our kv file like this.

 

 

 

 

 

So run the complete code this will be the result

Python Kivy Creating Popup Window
Python Kivy Creating Popup Window

 

Subscribe and Get Free Video Courses & Articles in your Email

 

2 thoughts on “Python Kivy Creating Popup Window”

Comments are closed.

Codeloop
Share via
Copy link
Powered by Social Snap
×