In this video I’ll show you how to ring the system bell with Tkinter and Python.

There are many situations when you might need to ring the system bell in your app. Luckily, it’s incredibly easy to do with Tkinter.

All you have to do is call root.bell()

In this video we’ll make a fun little app with a picture of a bell and a button that you can click to make the system bell ring.

Python Code: bell.py
(Github Code)

from tkinter import *

root = Tk()
root.title('Codemy.com - Ring The Bell!')
root.iconbitmap('c:/gui/codemy.ico')
root.geometry("500x500")

# Define image
bell = PhotoImage(file="images/bell.png")

# Add image to label
bell_label = Label(root, image=bell)
bell_label.pack(pady=20)

# create ring function
def ring():
	root.bell()

# Create our button
my_button = Button(root,
	text="Ring The Bell",
	command=ring,
	font=("Helvetica", 24), 
	fg="#4d4d4d")

my_button.pack(pady=20)



root.mainloop()

John Elder

John is the CEO of Codemy.com 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

2 comments

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

John Elder

John is the CEO of Codemy.com 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...