def open_new (self): n_col = tkSimpleDialog.askinteger ("N_Colors", "Enter the number "\ "of colors in new lookup table.", initialvalue=16, minvalue=0, maxvalue=LUT_EDITOR_MAX_COLORS, parent=self.root) if n_col is None: return None cur_col = ((0,0,255), '#0000fe') ans = tkMessageBox.askyesno ("Choose color?", "Choose individual colors? "\ "Answer no to choose one color only.") if ans == 1: for i in range (0, n_col): col = tkColorChooser.askcolor (title="Color number %d"%(i), initialcolor=cur_col[1]) if col[1] is not None: self.lut.append (tk_2_lut_color (col[0])) cur_col = col else: self.lut.append (tk_2_lut_color (cur_col[0])) else: col = tkColorChooser.askcolor (title="Choose default color", initialcolor=cur_col[1]) if col[1] is None: col = cur_col for i in range (0, n_col): self.lut.append (tk_2_lut_color (col[0])) self.lut_changed = 1 self.initialize ()
def on_mouse_release(self, x, y, buttons, modifers): if self.highlighted is not None: if pyglet.window.mouse.LEFT & buttons: self.dispatch_event("on_tool_selected", self.highlighted, "left") self.left_tool = self.highlighted else: self.dispatch_event("on_tool_selected", self.highlighted, "right") self.right_tool = self.highlighted elif self.over_palette_swatch(x, y): swatch, index = self.get_palette_swatch(x, y) if pyglet.window.key.MOD_CTRL & modifers: self.palette[index] = askcolor()[0] or self.palette[index] elif pyglet.window.mouse.LEFT & buttons: self.dispatch_event("on_color_selected", swatch, "left") self.left_color = swatch else: self.dispatch_event("on_color_selected", swatch, "right") self.right_color = swatch elif self.scale_increased(x, y): self.scale += 1 self.dispatch_event("on_scale_changed", self.scale) elif self.scale_decreased(x ,y): self.scale = max(1, self.scale - 1) self.dispatch_event("on_scale_changed", self.scale) elif x > self.tool_loc[-1][0] and y > self.tool_loc[-1][1]: new_bg_color = askcolor()[0] if new_bg_color: self.background_color = new_bg_color self.dispatch_event("on_bg_color_selected", new_bg_color)
def chooseColor(self, textbox): previous = textbox.getValue() try: color = tkColorChooser.askcolor(previous)[1] except: color = tkColorChooser.askcolor()[1] if color is None: color = previous textbox.setValue(color)
def _select_color( self): if self.color: color = tkColorChooser.askcolor( self.color) else: color = tkColorChooser.askcolor() if color[1]: self.set_color( color[1]) self.rgb = color[0] self.configure( background=self.color, activebackground=self.color, activeforeground=self.foreground_color, foreground=self.foreground_color)
def color_map(gfx,butcolor): ''' if gfx.map==[]: MB.showwarning('Info','Select map file') return ''' if gfx.map!=[]: new_color = tkColorChooser.askcolor (title="Map color",initialcolor=mod.vtk2tk_color(gfx.map[0].color)) else: new_color = tkColorChooser.askcolor (title="Map color",initialcolor=mod.vtk2tk_color((0,0.5,0.75))) if new_color[1] != None: col = mod.tk2vtk_color (new_color[0]) butcolor.config(bg=mod.vtk2tkhex_color(col))
def changeColour(): global colour1,colFrame1 (rgb, hexColour) = tkcc.askcolor() colour1 = hexColour print(colour1) updateFile() colFrame1.config(bg = hexColour)
def get_color(): global text_color color = str(askcolor()) if 'None' not in color: color = color.split("'") text_color = color[1] refresh_color_text()
def update_relbuttons(gw,relbuttons): for child in relbuttons.winfo_children(): child.destroy() lb = Label(relbuttons,text="State: {}".format(gw.parent.state_label(gw.g.parent_state))) lb.pack(side = TOP) btns = Frame(relbuttons) btns.pack(side = TOP) foo = Label(btns,text = '+') foo.grid(row = 0, column = 0) foo = Label(btns,text = '?') foo.grid(row = 0, column = 1) foo = Label(btns,text = '-') foo.grid(row = 0, column = 2) foo = Label(btns,text = 'T') foo.grid(row = 0, column = 4) rels = sorted(gw.g.relations,key=lambda r:r.name()) for idx,rel in enumerate(rels): foo = Checkbutton(btns,fg=line_color(idx),variable=gw.get_enabled(rel)[0],command=gw.update) foo.grid(row = idx+1, column = 0) foo = Checkbutton(btns,fg=line_color(idx),variable=gw.get_enabled(rel)[1],command=gw.update) foo.grid(row = idx+1, column = 1) foo = Checkbutton(btns,fg=line_color(idx),variable=gw.get_enabled(rel)[2],command=gw.update) foo.grid(row = idx+1, column = 2) foo = Label(btns,text=rel.name(),fg=line_color(idx),justify=LEFT,anchor="w") foo.grid(sticky=W,row = idx+1, column = 3) foo.bind("<Button-1>", lambda e: askcolor()) foo = Checkbutton(btns,fg=line_color(idx),variable=gw.get_enabled(rel)[3],command=gw.update) foo.grid(row = idx+1, column = 4)
def changeColor() : assert len(pyncData.intlist.curselection()) == 1 intname = pyncData.intlist.get(pyncData.intlist.curselection()[0]) curfile = pyncData.curfile.get() retclr = tkColorChooser.askcolor() if not retclr[0] : return pyncData.files[curfile][1][intname] = [retclr[0][0]/256., retclr[0][1]/256., retclr[0][2]/256.]
def ask_color_axis_bgcolor(self, *args, **kwargs): logging.debug("clicked axis_bgcolor button") result = tkColorChooser.askcolor(parent=self.master, initialcolor=None, title="axis_bgclor") ttk.Style().configure("axis_bgcolor.TButton", background=result[1]) logging.debug("setting axis_bgcolor to chose color %s" % (repr(result))) plt.colors() self.mAxes.set_axis_bgcolor(result[1])
def colorChooser(self, option, widget): """ Gets the name of the color from the color dialog """ color = askcolor() if (color and len(color) > 1 and color[0] != None): widget.delete(0, len(widget.get())) widget.insert(0, str(color[1])) self.widgetDict[option] = widget
def GetColor(): global SelColor ColorTuple, ColorHex = tkColorChooser.askcolor(SelColor) if ColorTuple != None: SelColor = ColorTuple SetColor()
def setColor(self, satisfaction): """ """ currentColor = self.float2hex(self.colors[satisfaction]) result = tkColorChooser.askcolor(currentColor) if result[0]: self.colors[satisfaction] = self.int2floatColor(result[0])
def callback(self): global color verify=0 result = askcolor(color="#6A9662", title = "Bernd's Colour Chooser") print result color=result[1] #drawing_area.create_rectangle(100,100,100,100,outline=result[1]) if (type(curr_object)==int): if(color_val=="outline"): drawing_area.itemconfig(curr_object,outline=color) elif(color_val=="fill"): drawing_area.itemconfig(curr_object,fill=color) return if curr_object is not None: for i in curr_object: temp_list=drawing_area.gettags(i) for j in drawing_area.gettags(i): if ("eraser"==str(j) or j=="line"): verify=1 if verify is not 1: if(color_val=="outline" and "crline" not in temp_list): drawing_area.itemconfig(i,outline=color) elif(color_val=="fill"): drawing_area.itemconfig(i,fill=color) verify=0
def changecanvas(self): try: result = tkColorChooser.askcolor(title="Background Color") if result[0] != None: self.w.config(background=result[1]) except: pass
def onChooseColor(event): if event.widget.cget("highlightbackground") == gNonHoverColor: return event.widget.config(highlightbackground=gNonHoverColor) (rgb, hex) = tkColorChooser.askcolor(event.widget.cget("bg")) if hex: event.widget.config(bg=hex) generatePalette()
def chgCol(gl=gl, b1=b1, l1=l1): tmp = askcolor(gl.color.get())[1] if tmp is None: return gl.color.set(tmp) b1.configure(bg=gl.color.get()) l1.configure(text=gl.color.get()) change_cmd()
def chooseClr(button, protname, chem) : retclr = tkColorChooser.askcolor() if not retclr[0] : return clr = retclr[0] button.config(foreground=retclr[1]) vorshows[protname].chem2clr[chem] = ( clr[0]/256., clr[1]/256., clr[2]/256. ) print vorshows[protname].chem2clr
def update_relbuttons(gw,relbuttons): for child in relbuttons.winfo_children(): child.destroy() lb = Label(relbuttons,text="State: {}".format(gw.parent.state_label(gw.g.parent_state))) lb.pack(side = TOP) btns = Frame(relbuttons) btns.pack(side = TOP) foo = Label(btns,text = '+') foo.grid(row = 0, column = 0) foo = Label(btns,text = '?') foo.grid(row = 0, column = 1) foo = Label(btns,text = '-') foo.grid(row = 0, column = 2) foo = Label(btns,text = 'T') foo.grid(row = 0, column = 4) rels = list(sorted(enumerate(gw.g.relations),key=lambda r:r[1].name())) for idx,(num,rel) in enumerate(rels): foo = Checkbutton(btns,fg=line_color(num),variable=gw.get_enabled(rel)[0],command=gw.update) foo.grid(row = idx+1, column = 0) foo = Checkbutton(btns,fg=line_color(num),variable=gw.get_enabled(rel)[1],command=gw.update) foo.grid(row = idx+1, column = 1) foo = Checkbutton(btns,fg=line_color(num),variable=gw.get_enabled(rel)[2],command=gw.update) foo.grid(row = idx+1, column = 2) foo = Label(btns,text=rel.name(),fg=line_color(num),justify=LEFT,anchor="w") foo.grid(sticky=W,row = idx+1, column = 3) foo.bind("<Button-1>", lambda e: askcolor()) foo = Checkbutton(btns,fg=line_color(num),variable=gw.get_enabled(rel)[3],command=gw.update) foo.grid(row = idx+1, column = 4)
def toggle(self): if self.variable.get() == 1: color1 = tkColorChooser.askcolor(title="Choose first color")[0] if color1 != None: color2 = tkColorChooser.askcolor(title="Choose second color")[0] else: self.deselect() return if color2 != None: self.controller.set_filter(color1, color2) else: self.deselect() else: print "Toggle" self.controller.unset_filter()
def colorChooser(self,option,widget): """ Gets the name of the color from the color dialog """ color = askcolor() if( color and len(color) > 1 and color[0] != None ): widget.delete(0,len( widget.get() ) ) widget.insert(0, str(color[1]) ) self.widgetDict[option] = widget
def changeColour(): global colour1, colFrame1 (rgb, hexColour) = tkcc.askcolor() colour1 = hexColour print(colour1) updateFile() colFrame1.config(bg=hexColour)
def color_callback(self, source): # Prompt a color picker, set the options and the background/foreground of the button nums, hex_color = askcolor(color=getattr(self.options, source), title="Color Chooser") if hex_color: opposite = self.opposite_color(hex_color) setattr(self.options, source, hex_color.upper()) self.buttons[source].configure(bg=hex_color, fg=opposite)
def set_layer_color(self, layer_id): layer = self.get_layer(layer_id) color = tkColorChooser.askcolor(color=layer.color)[0] if color != None: layer.color = color self.select_layer(layer_id)
def btn_getColorSum(self, args): seq, clrName, dic, butNum = args thisClrs = dic[seq] rgb = [thisClrs["r"], thisClrs["g"], thisClrs["b"]] print "rgb pos", rgb print c = dic[seq][clrName] hx = rgb_to_hex(c[0], c[1], c[2]) color = askcolor(color=hx) clrInt = color[0] if clrInt: clrDec = rgb_int_to_dec(clrInt[0], clrInt[1], clrInt[2]) rgbCspace = getClrSum(rgb, clrDec) print "rgb:", rgb print "rgbCspace:", rgbCspace reconstruct = toClrSpace(rgb[0], rgb[1], rgb[2], rgbCspace) print "orrrrrrrrig", clrDec print "reconstruct", reconstruct reconstruct = limitClr(reconstruct) print "limiteeeeed", reconstruct dic[seq][clrName] = reconstruct reconHex = rgb_to_hex(reconstruct[0],reconstruct[1],reconstruct[2]) self.buts[butNum].configure(bg = reconHex) writeClrSpaceDic(dic) self.dic=dic
def setColor(): # global log col = tkColorChooser.askcolor() # workaround: on linux col[1] returns object, not string col2 = isinstance(col[1], str) and col[1] or col[1].string log.config(background=col2) statusHint("Color set to: " + col2)
def change_colour(self, event): if self.selectCol != None: initial = self.itemcget(self.selectCol[0], 'fill') _, hx = tkColorChooser.askcolor(initialcolor=initial) if hx != None: self.itemconfig(self.selectCol[0], fill=hx) self.redraw()
def set_foreground_color(self, event=None): self.foreground = askcolor()[-1] try:self.set_fill() except:pass try:self.set_outline() except:pass self.colorpallete.itemconfig(self.foregroundpallete,outline=self.foreground, fill=self.foreground)
def add_specific_colour(self): if self.colGridLength >= self.maxValues: play_sound() else: _, hx = tkColorChooser.askcolor() if hx != None: self._add_colour(hx)
def clearClick(event): if(zoom_flag != 0): return global p p = [0,'#ffffff'] p = askcolor() w.bind('<Button-1>', click)
def _chooseColor( event=None ): import tkColorChooser newColor = tkColorChooser.askcolor( parent=self )[1] if newColor: variable.set( newColor ) self.newColorChosen( variable )
def l_pickColor(cls, b_config, value_only=False): """ Pick a color from the ColorChoose widget and store the rgb & hex inside the class value_only -> return the askcolor() output without internally setting it return -> None """ color = askcolor() if color[0] is None: return None if value_only: return color # Edit the StringVars and store the raw color output cls.l_rgb_color.set(cls.__l_colorFormatter(color[0], 'RGB')) cls.l_hex_color.set(color[1].upper()) # Update the button background colors b_config.config(background=color[1], activebackground=color[1]) # Switch between black & white to make sure the foreground text can be seen b_config.config(foreground='white' if sum(color[0]) / 3 < cls.__l_threshold else 'black') cls.l_current_color = color
def custermizeSSEColor(self,sse): SSE_col_but = { 'H':self.H_col_but, 'G':self.G_col_but, 'I':self.I_col_but, 'E':self.E_col_but, 'B':self.B_col_but, 'T':self.T_col_but, 'S':self.S_col_but, '-':self.N_col_but, 'b':self.b_col_but, 'C':self.C_col_but, } try: color_tuple, color = tkColorChooser.askcolor(color=self.SSE_col[sse]) if color_tuple is not None and color is not None: self.SSE_col_RGB[sse] = color_tuple self.SSE_col[sse] = color SSE_col_but[sse]['bg']=self.SSE_col[sse] SSE_col_but[sse]['activebackground']=self.SSE_col[sse] SSE_col_but[sse].update() except Tkinter._tkinter.TclError: print 'Old color (%s) will be used.' % (self.mesh_col)
def color_sel(tag): if tag == 'Red': cmd.color('red', glb.SELE) elif tag == 'Green': cmd.color('green', glb.SELE) elif tag == 'Orange': cmd.color('orange', glb.SELE) elif tag == 'Yellow': cmd.color('yellow', glb.SELE) elif tag == 'Blue': cmd.color('blue', glb.SELE) elif tag == 'Violet': cmd.color('violet', glb.SELE) elif tag == 'CPK': glb.procolor(selection=glb.SELE, show_selection='sticks', color_selection='cpk', show_all=None) elif tag == 'Other': color = askcolor(title="Selection Color Chooser") clr = str(color[1]) newcolor = 'newcolor%s' % glb.incnewcolor() if clr != None: cmd.set_color( newcolor, ([int(n, 16) for n in (clr[1:3], clr[3:5], clr[5:7])])) cmd.color(newcolor, glb.SELE)
def onChangeColour(self): index = self.text.search("def colour", "0.0", forwards=True) floatindex = float(index) colourtext = self.text.get((floatindex + 1.0), (floatindex + 1.99)) r,g,b = 255,255,255 if colourtext[-1] == ')': colourtext = colourtext.split("(") colourtext = colourtext[1] colourtext = colourtext[0:-1] colourlist = colourtext.split(",") r = int(colourlist[0]) g = int(colourlist[1]) b = int(colourlist[2]) result = tkColorChooser.askcolor(title="Choose the robot colour", color=(r,g,b)) if result: # get rgb value rgb = str(result[0]) if rgb != 'None': # find the line with def colour method index = self.text.search("def colour", "0.0", forwards=True) floatindex = float(index) newIndex = floatindex + 1.0 # new colour line newline = " " + " "+ "return " + rgb newIndex2 = newIndex + 0.99 self.text.delete(newIndex, newIndex2) self.text.insert(newIndex, newline)
def callback(self): global color verify=0 result = askcolor(color="#6A9662", title = "Bernd's Colour Chooser") print result color=result[1] #drawing_area.create_rectangle(100,100,100,100,outline=result[1]) if (type(curr_object)==int): if(color_val=="outline"): drawing_area.itemconfig(curr_object,outline=color) elif(color_val=="fill"): drawing_area.itemconfig(curr_object,fill=color) return if curr_object is not None: for i in curr_object: for j in drawing_area.gettags(i): if ("eraser"==str(j) or j=="line"): verify=1 if verify is not 1: if(color_val=="outline"): drawing_area.itemconfig(i,outline=color) elif(color_val=="fill"): drawing_area.itemconfig(i,fill=color) verify=0
def color_choose(self,attr): # print "color_choose", attr c = None i = -999 t = ['fg','bg','gridcolor'] try: j = t.index(attr) c = self.plot_opts[attr] i = - (j + 10) except ValueError: try: i = int(attr) c = self.plot_opts['traces'][i][0] except ValueError: pass if (c != None): s = tkColorChooser.askcolor(color= c,parent=self.master) nc = s[1] # nc = new color if ((nc == "") or (nc == None)): nc = c if (i != -999): # bg, fg, gridcolor if (i < 0): qwid = t[-(i+10)] self.plot_opts[qwid] = nc # trace#N else: qwid = 'color#%i' % (i) self.plot_opts['traces'][i][0] = nc # self.opts[qwid].configure(background=nc, activebackground = nc) self.do_plot()
def font(): (triple, color) = askcolor() if color: text.config(foreground=color)
def themecolorbrowse(self, index): (rgb, color) = tkColorChooser.askcolor(self.theme_colors[index], title=self.theme_prompts[index], parent=self.parent) if color: self.theme_colors[index] = color self.themevarchanged()
def RGBColors(): global RGB global rgbToCLients #---------------> Returns a tuple, ((R, G, B), HexColor) (RGB, HEXColor) = askcolor(color="#6A9662", title="SELECT A COLOR") global flag1 ''' if (flag1 == 1): #Remove From Window for New Inputs rgbToClients.remove(RGB[0]) rgbToClients.remove(RGB[1]) rgbToClients.remove(RGB[2]) flag1 = 0 ''' #global data rgbToClients.append(RGB[0]) rgbToClients.append(RGB[1]) rgbToClients.append(RGB[2]) flag1 = 1 print("Will send: ") print rgbToClients
def background(): (triple, color) = askcolor() if color: text.config(background=color)
def onChangeColour(self): index = self.text.search("def colour", "0.0", forwards=True) floatindex = float(index) colourtext = self.text.get((floatindex + 1.0), (floatindex + 1.99)) r, g, b = 255, 255, 255 if colourtext[-1] == ')': colourtext = colourtext.split("(") colourtext = colourtext[1] colourtext = colourtext[0:-1] colourlist = colourtext.split(",") r = int(colourlist[0]) g = int(colourlist[1]) b = int(colourlist[2]) result = tkColorChooser.askcolor(title="Choose the robot colour", color=(r, g, b)) if result: # get rgb value rgb = str(result[0]) if rgb != 'None': # find the line with def colour method index = self.text.search("def colour", "0.0", forwards=True) floatindex = float(index) newIndex = floatindex + 1.0 # new colour line newline = " " + " " + "return " + rgb newIndex2 = newIndex + 0.99 self.text.delete(newIndex, newIndex2) self.text.insert(newIndex, newline)
def setColorVar2(event=None): l = VARS[1].get() if l == 'Custom>': import tkColorChooser ret = tkColorChooser.askcolor() l = ret[1] VARS[1].set(l)
def custermizeSSEColor(self, sse): SSE_col_but = { 'H': self.H_col_but, 'G': self.G_col_but, 'I': self.I_col_but, 'E': self.E_col_but, 'B': self.B_col_but, 'T': self.T_col_but, 'S': self.S_col_but, '-': self.N_col_but, 'b': self.b_col_but, 'C': self.C_col_but, } try: color_tuple, color = tkColorChooser.askcolor( color=self.SSE_col[sse]) if color_tuple is not None and color is not None: self.SSE_col_RGB[sse] = color_tuple self.SSE_col[sse] = color SSE_col_but[sse]['bg'] = self.SSE_col[sse] SSE_col_but[sse]['activebackground'] = self.SSE_col[sse] SSE_col_but[sse].update() except Tkinter._tkinter.TclError: print 'Old color (%s) will be used.' % (self.mesh_col)
def popupBackColorPicker(): baseColor = self.todMgr.getBackLightColor() initColor = self.clipLightValue(baseColor * 127.5, 255.0) color = tkColorChooser.askcolor(parent=interior, initialcolor=(initColor[0], initColor[1], initColor[2])) if color[0] is not None: self.backLightColor.set((round(color[0][0] / 127.5, 2), round(color[0][1] / 127.5, 2), round(color[0][2] / 127.5, 2))) return
def poscol(): c = camfr_PIL.POSCOLOR n = tkColorChooser.askcolor(color="#%02x%02x%02x" % (c[0], c[1], c[2]))[0] if n: camfr_PIL.POSCOLOR = n posButton.config(bg="#%02x%02x%02x" % (n[0], n[1], n[2])) ct.focus()
def popupColorPicker(self): # Can pass in current color with: color = (255, 0, 0) color = tkColorChooser.askcolor( parent=self.interior(), # Initialize it to current color initialcolor=tuple(self.get()[:3]))[0] if color: self.set((color[0], color[1], color[2], self.getAt(3)))
def addColor(): victim = findObject() color = askcolor() find = "background-color:;" rep_color = "\t\t\t\tbackground-color: " + color[1] + ";\n" alterCSSFile(victim, find, rep_color, "") ob = shapeobAr[victim] w.itemconfig(ob, fill=color[1])
def _choose_color(self): result = tkColorChooser.askcolor( parent=self.master, initialcolor=self._color_var.get(), title=self._chooser_title ) """Invokes the command associated with the button.""" if not result[1] is None: self._color_var.set(result[1]) return self.tk.call(self._invocation, "invoke", self)
def showColorPicker (self,name): c = self.c option_name = self.option_names[name] color = c.config.getColor(option_name) rgb,val = tkColorChooser.askcolor(color=color) if val != None: self.update(name,val)
def choosecolor(*arg, **kwargs): """ Set color and update graph if neccessary. """ NV.color = tkColorChooser.askcolor()[1] colorcanvas.itemconfigure(colorcanvas.find_all()[1], fill=NV.color) if NV.stream: create_graph()
def _Evt_ChooseColor(self, evt=None): (rgb, hex) = tkcolor.askcolor(color2hex(self.ColorVar.get()), title='Choose a Light Color...', parent=self) if rgb: self.ColorVar.set(','.join(str(x / 255.0) for x in rgb)) self.Color.config(bg=hex)
def popupColorPicker(self): # Can pass in current color with: color = (255, 0, 0) color = tkColorChooser.askcolor( parent = self.interior(), # Initialize it to current color initialcolor = tuple(self.get()[:3]))[0] if color: self.set((color[0], color[1], color[2], self.getAt(3)))
def color_map(gfx, butcolor): ''' if gfx.map==[]: MB.showwarning('Info','Select map file') return ''' if gfx.map != []: new_color = tkColorChooser.askcolor(title="Map color", initialcolor=mod.vtk2tk_color( gfx.map[0].color)) else: new_color = tkColorChooser.askcolor(title="Map color", initialcolor=mod.vtk2tk_color( (0, 0.5, 0.75))) if new_color[1] != None: col = mod.tk2vtk_color(new_color[0]) butcolor.config(bg=mod.vtk2tkhex_color(col))