Python – Tkinter Choose color Dialog

Python provides many options for GUI (Graphical User Interface ) development. tkinter is the most commonly used method options apart from all other available alternatives. It is a standard method for developing GUI applications using Tk GUI toolkit. The steps involved in developing basic tkinter app are:

  1. Importing the tkinter module.
  2. Creating the main window or the container.
  3. Insert as many widgets as you want to the main window.
  4. Apply the event Trigger on all the widgets.

The process of importing tkinter module is same as importing any other module in Python.

import tkinter

Creating choose color dialog box using Tkinter

The tkinter module has a package in it named as colorchooser. This package of tkinter module helps in developing the color chooser dialog box. This package has a function named as askcolor() that plays the major role.


This function belongs to the colorchooser package of tkinter module. The function helps in creating a color chooser dialog box. As soon as the function is called, it makes the color chooser dialogue box pop up. The function returns the hexadecimal code of the color selected by the user.







# Python program to create color chooser dialog box
# importing tkinter module
from tkinter import *
# importing the choosecolor package
from tkinter import choosecolor
# Function that will be invoked when the
# button will be clicked in the main window
def choose_color():
    # variable to store hexadecimal code of color
    color_code = colorchooser.askcolor(title ="Choose color"
root = Tk()
button = Button(root, text = "Select color",
                   command = "choose_color")



Note:The color chooser dialog box may vary for different operating systems.

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to 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.

Article Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.