ALICE 1.3  1.3.14
Developer documentation
either-color-chooser-test.py
Go to the documentation of this file.
1 # Python program to create color chooser dialog box
2 import __future__
3 import sys
4 # importing tkinter module
5 if sys.version_info[0] == 2:
6  print ("Python 2.x")
7  import urllib2
8  import tkFont
9  from Tkinter import *
10  from ttk import *
11  from tkFileDialog import askopenfilename
12  from tkFileDialog import asksaveasfilename
13  from tkSimpleDialog import askstring
14  from tkMessageBox import *
15  from tkColorChooser import askcolor
16 if sys.version_info[0] == 3:
17  print ("Python 3.x")
18  import urllib.request, urllib.error, urllib.parse
19  from tkinter.font import *
20  from tkinter import *
21  from tkinter.ttk import *
22  from tkinter.filedialog import askopenfilename
23  from tkinter.filedialog import asksaveasfilename
24  from tkinter.simpledialog import askstring
25  from tkinter.messagebox import *
26 # importing the choosecolor package
27  from tkinter.colorchooser import askcolor
28 
29 # Function that will be invoked when the
30 # button will be clicked in the main window
31 def getcolor(text):
32  tempwindow = Tk()
33  tempwindow.state("withdrawn")
34  rgb,hexcolor = askcolor(parent=tempwindow, title="choose color for "+text)
35  tempwindow.destroy()
36  print("you picked the following color for "+str(text)+": "+str(hexcolor))
37  return hexcolor
38 
40 
41  # variable to store hexadecimal code of color
42  color_code = getcolor("Trace1")
43  print(color_code)
44 
45 root = Tk()
46 button = Button(root, text = "Select color",
47  command = choose_color)
48 button.pack()
49 root.geometry("300x300")
50 root.mainloop()
either-color-chooser-test.getcolor
def getcolor(text)
Definition: either-color-chooser-test.py:31
font
color-chooser-test.askcolor
def askcolor(text)
Definition: color-chooser-test.py:31
messagebox
either-color-chooser-test.choose_color
def choose_color()
Definition: either-color-chooser-test.py:39
ttk