def line_color(): if LL.FLOAT_COLOR[LL.I.get()].get() == 'None': rgb, hx = askcolor(parent=parent) else: backup = LL.FLOAT_COLOR[LL.I.get()].get() rgb, hx = askcolor(color=LL.FLOAT_COLOR[LL.I.get()].get(),parent=parent) if hx is None: LL.FLOAT_COLOR[LL.I.get()].set(backup) else: LL.FLOAT_COLOR[LL.I.get()].set(hx)
def line_color(): # =============== backup = PLOT.LINE_COLOR.get() if PLOT.LINE_COLOR.get() == 'None': rgb, hx = askcolor(parent=parent) else: rgb, hx = askcolor(color=PLOT.LINE_COLOR.get(),parent=parent) if hx is None: PLOT.LINE_COLOR.set(backup) else: PLOT.LINE_COLOR.set(hx)
def initial_color(): # ================== backup = PLOT.MARKER_COLOR.get() if PLOT.MARKER_COLOR.get() == 'None': rgb, hx = askcolor(parent=parent) else: rgb, hx = askcolor(color=PLOT.MARKER_COLOR.get(),parent=parent) if hx is None: PLOT.MARKER_COLOR.set(backup) else: PLOT.MARKER_COLOR.set(hx)
def color_chooser(color_out, mbutton): if color_out.get() != "": grab_color = color_out.get() color_code = askcolor("#" + grab_color, title="Choose color") if "None" not in str(color_code): color_out.delete(0, END) color_out.insert(INSERT, color_code[1][1:]) mbutton.config(bg=color_code[1]) if color_out.get() == "": color_code = askcolor("#F3F3F3") color_out.insert(INSERT, color_code[1][1:]) mbutton.config(bg=color_code[1])
def cselection(): # =============== ''' Color picker with backup''' backup = PLOT.CONTOUR_COLOR.get() if PLOT.CONTOUR_COLOR.get() == 'None': rgb, hx = askcolor(parent=parent) else: rgb, hx = askcolor(color=PLOT.CONTOUR_COLOR.get(), parent=parent) if hx is None: PLOT.CONTOUR_COLOR.set(backup) else: PLOT.CONTOUR_COLOR.set(hx)
def cselection(): # =============== ''' Color picker with backup''' backup = PLOT.CONTOUR_COLOR.get() if PLOT.CONTOUR_COLOR.get() == 'None': rgb, hx = askcolor(parent=parent) else: rgb, hx = askcolor(color=PLOT.CONTOUR_COLOR.get(),parent=parent) if hx is None: PLOT.CONTOUR_COLOR.set(backup) else: PLOT.CONTOUR_COLOR.set(hx)
def test_askcolor(self): def test(event): event.widget.ok() self.assertEqual(event.widget.color[-1], '#FF0000') def events(): self.window.update() c = list(self.window.children.values())[0] c.bind('<Visibility>', test) self.window.update() c.withdraw() self.window.update() c.deiconify() self.window.after(100, events) tkc.askcolor(parent=self.window)
def pick_color(self): color = askcolor(title='Choose color') self.picked_color = color[0] self.picked_hex_value = color[1] if self.current_mode == 'fill': cursor_str = 'coffee_mug' + ' ' + self.picked_hex_value self.root.config(cursor=cursor_str)
def ask_color(self, frame, sequence): color = askcolor() if color[0] is not None: rgb = [int(x) for x in color[0]] sequence.append(Color(*rgb)) self.moodlights.color_wipe(sequence, 1, 0) color_frame = tk.Frame(frame, width=20, height=20, bg=color[1]).pack(side=tk.LEFT)
def change_fillcolour(self): new_colour = askcolor(self.fillcolour, self)[0] if new_colour is None: # If you press cancel return self.fillcolour = new_colour self.fillcolour_button.config(bg=Colours.get_hex(new_colour), fg=Colours.contrasting(*new_colour))
def change_left_color(self): self.left_color = askcolor() #bug fixed, when cancel is pressed in tkcolorpicker None colors are selected, instead previous color is unchanged if self.left_color[HEXA] is not None: self.messages["colors"][LEFT_BUTTON] = self.left_color[RGB] self.messages["colors"][PREV_LEFT_BUTTON] = self.left_color[RGB] self.left_button.config(bg=self.left_color[HEXA])
def pickColor(profName): try: color = StringVar(value=th.currentProf[profName]) except: color = StringVar(value=th.defaultFallback[profName]) color.set(askcolor(color.get(), root)[1]) if color.get() != 'None': unifiedWrite(profName, color.get())
def pick_color(label, color_var): _, rgb = askcolor((255, 255, 0)) if rgb is not None: label.config(background=rgb, text='Picked', compound='right', foreground=contrast(rgb)) color_var.set(rgb)
def bg_com(self): style = ttk.Style(self.wnd) style.theme_use('clam') self.bg_color = askcolor((255, 255, 0), self.wnd) self.bg_color = self.bg_color[1] self.main_cnv.config(bg=self.bg_color) return self.bg_color
def choose_wolf_color(self): try: _, colorStr = askcolor(title="Choose color") except TclError: colorStr = None if colorStr is not None: cfg.config['wolf_color'] = colorStr self.update_animals()
def f(self, data): if data.basing != None: return # opens color choosing window _, color = askcolor() if color != None: # updates color of specified dataset and legend data.color[idx] = color self.fill = color
def callbackSecondChangeColorBtn(self): color = askcolor() color_name = color[1] if color_name: self.canvas.itemconfig('line2', fill=color_name) self.canvas.itemconfig('lined2', fill=color_name) self.canvas.itemconfig('PointC', fill=color_name) self.canvas.itemconfig('PointD', fill=color_name)
def callbackFirstChangeColorBtn(self): color = askcolor() color_name = color[1] if color_name: self.canvas.itemconfig('line1', fill=color_name) self.canvas.itemconfig('lined1', fill=color_name) self.canvas.itemconfig('PointA', fill=color_name) self.canvas.itemconfig('PointB', fill=color_name)
def buttonfarbe(): global buttfarbe bfarben = tkcolorpicker.askcolor(color=buttfarbe, parent=fenster) buttfarbe = str(bfarben[1]) button_schriftfarbe.configure(bg=buttfarbe) button_wortliste.configure(bg=buttfarbe) button_hashen.configure(bg=buttfarbe) button_hintergrund.configure(bg=buttfarbe) button_buttonfarbe.configure(bg=buttfarbe)
def bg_color(): colore1 = askcolor()[1] if colore1: chd_2() file_colore1 = open("colore-sfondo.txt", "w").write(colore1) chd_1() messagebox.showinfo("Background color Saved", "The background color has been saved. Restart the app to apply the changes") else: pass
def openbgdialog(): rgb_value = askcolor() # Write To LED rgb_write(rgb_value[0][0],rgb_value[0][1],rgb_value[0][2]) #Set Sliders set_val_red.set(rgb_value[0][0]) set_val_green.set(rgb_value[0][1]) set_val_blue.set(rgb_value[0][2])
def color(): root = tk.Tk() style = ttk.Style(root) style.theme_use('clam') color = askcolor(title="Seleccione color") root.destroy() root.mainloop() return color
def fnt_color(): colore2 = askcolor()[1] if colore2: chd_2() file_colore2 = open("colore-scritte.txt", "w").write(colore2) chd_1() messagebox.showinfo("Font color Saved", "The font color has been saved. Restart the app to apply the changes") else: pass
def pick_replacement_color(self): self.correction_color = askcolor(color="red", parent=None, title=("Color Chooser"), alpha=False) self.canvas_replacement.create_rectangle(0, 0, 20, 20, fill=self.correction_color[1])
def clicked(event): fill = var.get() RGB_code, hex_code = askcolor(fill, self.root, title='Color Picker (Subject Color)') fill = hex_code if fill != None: var.set(fill) if var != None else '' picker.config(background=fill)
def askcolor(self): icolor = self.entry.get() try: self.winfo_rgb(icolor) except tk.TclError: icolor = "red" color = askcolor(icolor, parent=self, title='Color')[1] self.update_idletasks() if color is not None: self.entry.delete(0, 'end') self.entry.insert(0, color)
def colora(): colorb=askcolor((255, 255, 0),tk)[1] button1.configure(fg=colorb) button2.configure(fg=colorb) button3.configure(fg=colorb) button4.configure(fg=colorb) button5.configure(fg=colorb) button6.configure(fg=colorb) button7.configure(fg=colorb) button8.configure(fg=colorb) button9.configure(fg=colorb)
def start(self): self.root = tk.Tk() rgb = askcolor((255, 255, 0), self.root)[0] led_list = [] for i in range(0, self.controller.size): for j in range(0, self.controller.size): led_list.append(Led(i, j, Color(rgb[0], rgb[1], rgb[2]))) self.controller.set_pixels(led_list) while True: pass
def colorPicker(self, event): b, g, r = self.clr m, n = askcolor((r, g, b), root) if m: r, g, b = m self.clrEntry.config(bg=n) if self.clrC: self.clr2 = (b, g, r) else: self.clr = (b, g, r) self.imgtk = readOverlay(self.newImageList[self.count][0], self.clr) self.canvas.itemconfig(self.image_on_canvas, image=self.imgtk)
def activate_color_palette(*args): # tkcolorpicker requires tkinter and pillow to be installed (https://libraries.io/pypi/tkcolorpicker) # tkcolorpicker is both the package and module name # pillow is the Python 3 version of PIL which was an older Python 2 version # PIL being the commmon module for both packages, you need to check for PIL and trap PIL to tell the user to install pillow from tkcolorpicker import askcolor if color_var.get() == 1: style = ttk.Style(window) style.theme_use('clam') color_list = askcolor((255, 255, 0), window) color_style = color_list[0] color_style_var.set(color_style) csvField_color_list.append(str(color_style)) csvField_color_list.append("|")
def ask_color(self, window, button, x, y, default_color): global colors_to_set color = tkcolorpicker.askcolor(color=tuple(default_color), parent=window) if color[0] != None: color_to_set = [int(min(255, max(0, c))) for c in color[0]] if all(c < 4 for c in color_to_set): rerun = lambda: self.ask_color(window, button, x, y, default_color) self.popup(window, "Invalid Color", self.warning_image, "That color is too dark to see.", "OK", rerun) else: colors_to_set[x][y] = color_to_set self.button_color_with_text_update(button, color[1])
def pickColor() -> None: '''Opens up a tkinter window to pick a color from the palette. Upon closing the window it sends the value to the LED controller''' global state try: rgb = getData()[1:] color = list( askcolor(tuple([int(s * 255 / limit) for s in rgb]), root)[0]) rgb = [int(s * limit / 255) for s in color] sendMore(rgb=rgb) saveState(rgb) except Exception as e: print('No Color Picked') print(e) return
def choosecolor(): global bgr, iconUp, iconDown, speedUp, speedDown, iconTotal, totalUsage, playlabel, prevbut, playbut, nextbut, shufbut, musiclist, backbut, locbut, time_elapsed, total_time, songlabel value = askcolor(bgr, app)[1] if (not (value is None)): bgr = value for w in widgetlist: w.configure(background=bgr) stylescale.configure('TScale', background=bgr) if (os.path.exists('C:\\ProgramData\\SideBar')): with open('C:\\ProgramData\\SideBar\\sidebardata.log', 'w+') as f: f.write(bgr) else: os.mkdir('C:\\ProgramData\\SideBar') with open('C:\\ProgramData\\SideBar\\sidebardata.log', 'w+') as f: f.write(bgr)
def ask_color(self, window, button, x, y, default_color): global colors_to_set if lp_mode == "Mk1": color = self.classic_askcolor(color=tuple(default_color), title="Select Color for Button (" + str(x) + ", " + str(y) + ")") else: color = tkcolorpicker.askcolor(color=tuple(default_color), parent=window, title="Select Color for Button (" + str(x) + ", " + str(y) + ")") if color[0] != None: color_to_set = [int(min(255, max(0, c))) for c in color[0]] if all(c < 4 for c in color_to_set): rerun = lambda: self.ask_color(window, button, x, y, default_color) self.popup(window, "Invalid Color", self.warning_image, "That color is too dark to see.", "OK", rerun) else: colors_to_set[x][y] = color_to_set self.button_color_with_text_update(button, color[1])
def marker_color(): if PLOT.ONMAP_COLOR.get() == 'None': rgb, hx = askcolor(parent=parent) else: rgb, hx = askcolor(color=PLOT.ONMAP_COLOR.get(),parent=parent) PLOT.ONMAP_COLOR.set(hx)
def tselection(): if PLOT.STREAM_COLOR.get() == 'None': rgb, hx = askcolor(parent=parent) else: rgb, hx = askcolor(color=PLOT.STREAM_COLOR.get(),parent=parent) PLOT.STREAM_COLOR.set(hx)
def cselection(): if PLOT.CURRENT_COLOR.get() == 'None': rgb, hx = askcolor(parent=parent) else: rgb, hx = askcolor(color=PLOT.CURRENT_COLOR.get(),parent=parent) PLOT.CURRENT_COLOR.set(hx)