Welcome folks today in this post we will be making color
picker or chooser popup
dialog window in tkinter. All the source code of the application will be given below.
Get Started
In order to get started you need to install the following library using pip
command as shown below
pip install tkinter
After installing it make an app.py
file and copy paste the following code into it
app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
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") print(color_code) root = Tk() button = Button(root, text = "Select color", command = choose_color) button.pack() root.geometry("300x300") root.mainloop() |
Now if you run this python script
app.py you will see the following result which is shown below