In this video I’ll show you how to create alert popup dialog boxes with kivymd and python.

Popup boxes are super popular in most software or apps, and creating dialog box alerts is super easy with KivyMD. In this video I’ll show you how to create an alert with a title and some text, as well as a couple of buttons.

We’ll also look at making the buttons functional so that they do something when you click them in the alert.

#kivy #codemy

Python Code:
GitHub Code:

from kivy.lang import Builder
from import MDApp
from kivymd.uix.dialog import MDDialog
from kivymd.uix.button import MDFlatButton, MDRectangleFlatButton

class MainApp(MDApp):
	dialog = None
	def build(self):
		self.theme_cls.theme_style = "Dark"
		self.theme_cls.primary_palette = "BlueGray"
		return Builder.load_file('alert.kv')
	def show_alert_dialog(self):
		if not self.dialog:
			self.dialog = MDDialog(
				title = "Pretty Neat, Right?!",
				text = "This is just some text that goes here...",
				buttons =[
						text="CANCEL", text_color=self.theme_cls.primary_color, on_release = self.close_dialog
						text="Yes It's Neat!", text_color=self.theme_cls.primary_color, on_release = self.neat_dialog

	# Click Cancel Button
	def close_dialog(self, obj):
		# Close alert box
	# Click the Neat Button
	def neat_dialog(self, obj):
		# Close alert box
		# Change label text
		self.root.ids.my_label.text = "Yes It's Neat!"


Kivy Design Code: alert.kv
GitHub Code: alert.kv

    orientation: 'vertical'


            text: "ALERT POPUP!"
            pos_hint: {'center_x': .5, 'center_y': .5}
            on_release: app.show_alert_dialog()

            id: my_label
            text: "Some Stuff"
            pos_hint: {'center_x': .95, 'center_y': .4}            


John Elder

John is the CEO of where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts


Your email address will not be published. Required fields are marked *

John Elder