Open In App
Related Articles

Python – Tkinter Choose color Dialog

Improve Article
Save Article
Like Article

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 a 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 the Tkinter module is the 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 colorchooser. This package of the Tkinter module helps in developing the color chooser dialog box. This package has a function named askcolor() that plays a 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 colorchooser
# 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.

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 22 Jan, 2021
Like Article
Save Article
Similar Reads
Complete Tutorials