Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
l.pack()
f.grid(row=i % 2, column=i // 2, padx=2, pady=2)
col_frame = ttk.Frame(self)
# --- hsv
hsv_frame = ttk.Frame(col_frame, relief="ridge", borderwidth=2)
hsv_frame.pack(pady=(0, 4), fill="x")
hsv_frame.columnconfigure(0, weight=1)
self.hue = LimitVar(0, 360, self)
self.saturation = LimitVar(0, 100, self)
self.value = LimitVar(0, 100, self)
# self.hue = tk.StringVar(self)
# self.saturation = tk.StringVar(self)
# self.value = tk.StringVar(self)
s_h = Spinbox(hsv_frame, from_=0, to=360, width=4, name='spinbox',
textvariable=self.hue, command=self._update_color_hsv)
s_s = Spinbox(hsv_frame, from_=0, to=100, width=4,
textvariable=self.saturation, name='spinbox',
command=self._update_color_hsv)
s_v = Spinbox(hsv_frame, from_=0, to=100, width=4, name='spinbox',
textvariable=self.value, command=self._update_color_hsv)
h, s, v = rgb_to_hsv(*self._old_color)
s_h.delete(0, 'end')
s_h.insert(0, h)
s_s.delete(0, 'end')
s_s.insert(0, s)
s_v.delete(0, 'end')
s_v.insert(0, v)
s_h.grid(row=0, column=1, sticky='w', padx=4, pady=4)
s_s.grid(row=1, column=1, sticky='w', padx=4, pady=4)
s_v.grid(row=2, column=1, sticky='w', padx=4, pady=4)
def test_spinbox_init(self):
spinbox = color.spinbox.Spinbox(self.window, from_=0, to=10)
spinbox.pack()
self.window.update()
def test_spinbox_bindings(self):
spinbox = color.spinbox.Spinbox(self.window, from_=0, to=10)
spinbox.pack()
self.window.update()
event = TestEvent(widget=spinbox.frame)
spinbox.focusin(event)
spinbox.focusout(event)
hsv_frame = ttk.Frame(col_frame, relief="ridge", borderwidth=2)
hsv_frame.pack(pady=(0, 4), fill="x")
hsv_frame.columnconfigure(0, weight=1)
self.hue = LimitVar(0, 360, self)
self.saturation = LimitVar(0, 100, self)
self.value = LimitVar(0, 100, self)
# self.hue = tk.StringVar(self)
# self.saturation = tk.StringVar(self)
# self.value = tk.StringVar(self)
s_h = Spinbox(hsv_frame, from_=0, to=360, width=4, name='spinbox',
textvariable=self.hue, command=self._update_color_hsv)
s_s = Spinbox(hsv_frame, from_=0, to=100, width=4,
textvariable=self.saturation, name='spinbox',
command=self._update_color_hsv)
s_v = Spinbox(hsv_frame, from_=0, to=100, width=4, name='spinbox',
textvariable=self.value, command=self._update_color_hsv)
h, s, v = rgb_to_hsv(*self._old_color)
s_h.delete(0, 'end')
s_h.insert(0, h)
s_s.delete(0, 'end')
s_s.insert(0, s)
s_v.delete(0, 'end')
s_v.insert(0, v)
s_h.grid(row=0, column=1, sticky='w', padx=4, pady=4)
s_s.grid(row=1, column=1, sticky='w', padx=4, pady=4)
s_v.grid(row=2, column=1, sticky='w', padx=4, pady=4)
ttk.Label(hsv_frame, text=_('Hue')).grid(row=0, column=0, sticky='e',
padx=4, pady=4)
ttk.Label(hsv_frame, text=_('Saturation')).grid(row=1, column=0, sticky='e',
padx=4, pady=4)
ttk.Label(hsv_frame, text=_('Value')).grid(row=2, column=0, sticky='e',
# --- rgb
rgb_frame = ttk.Frame(col_frame, relief="ridge", borderwidth=2)
rgb_frame.pack(pady=4, fill="x")
rgb_frame.columnconfigure(0, weight=1)
# self.red = tk.StringVar(self)
# self.green = tk.StringVar(self)
# self.blue = tk.StringVar(self)
self.red = LimitVar(0, 255, self)
self.green = LimitVar(0, 255, self)
self.blue = LimitVar(0, 255, self)
s_red = Spinbox(rgb_frame, from_=0, to=255, width=4, name='spinbox',
textvariable=self.red, command=self._update_color_rgb)
s_green = Spinbox(rgb_frame, from_=0, to=255, width=4, name='spinbox',
textvariable=self.green, command=self._update_color_rgb)
s_blue = Spinbox(rgb_frame, from_=0, to=255, width=4, name='spinbox',
textvariable=self.blue, command=self._update_color_rgb)
s_red.delete(0, 'end')
s_red.insert(0, self._old_color[0])
s_green.delete(0, 'end')
s_green.insert(0, self._old_color[1])
s_blue.delete(0, 'end')
s_blue.insert(0, self._old_color[2])
s_red.grid(row=0, column=1, sticky='e', padx=4, pady=4)
s_green.grid(row=1, column=1, sticky='e', padx=4, pady=4)
s_blue.grid(row=2, column=1, sticky='e', padx=4, pady=4)
ttk.Label(rgb_frame, text=_('Red')).grid(row=0, column=0, sticky='e',
padx=4, pady=4)
ttk.Label(rgb_frame, text=_('Green')).grid(row=1, column=0, sticky='e',
padx=4, pady=4)
ttk.Label(rgb_frame, text=_('Blue')).grid(row=2, column=0, sticky='e',
padx=4, pady=4)
self.hexa = ttk.Entry(hexa_frame, justify="center", width=10, name='entry')
self.hexa.insert(0, old_color.upper())
ttk.Label(hexa_frame, text="HTML").pack(side="left", padx=4, pady=(4, 1))
self.hexa.pack(side="left", padx=6, pady=(4, 1), fill='x', expand=True)
# --- alpha
if alpha:
alpha_frame = ttk.Frame(self)
alpha_frame.columnconfigure(1, weight=1)
# self.alpha = tk.StringVar(self)
self.alpha = LimitVar(0, 255, self)
alphabar = ttk.Frame(alpha_frame, borderwidth=2, relief='groove')
self.alphabar = AlphaBar(alphabar, alpha=self._old_alpha, width=200,
color=self._old_color, highlightthickness=0)
self.alphabar.pack()
s_alpha = Spinbox(alpha_frame, from_=0, to=255, width=4,
textvariable=self.alpha, command=self._update_alpha)
s_alpha.delete(0, 'end')
s_alpha.insert(0, self._old_alpha)
alphabar.grid(row=0, column=0, padx=(0, 4), pady=4, sticky='w')
ttk.Label(alpha_frame, text=_('Alpha')).grid(row=0, column=1, sticky='e',
padx=4, pady=4)
s_alpha.grid(row=0, column=2, sticky='w', padx=(4, 6), pady=4)
# --- validation
button_frame = ttk.Frame(self)
ttk.Button(button_frame, text="Ok",
command=self.ok).pack(side="right", padx=10)
ttk.Button(button_frame, text=_("Cancel"),
command=self.destroy).pack(side="right", padx=10)
# --- placement
padx=4, pady=4)
# --- rgb
rgb_frame = ttk.Frame(col_frame, relief="ridge", borderwidth=2)
rgb_frame.pack(pady=4, fill="x")
rgb_frame.columnconfigure(0, weight=1)
# self.red = tk.StringVar(self)
# self.green = tk.StringVar(self)
# self.blue = tk.StringVar(self)
self.red = LimitVar(0, 255, self)
self.green = LimitVar(0, 255, self)
self.blue = LimitVar(0, 255, self)
s_red = Spinbox(rgb_frame, from_=0, to=255, width=4, name='spinbox',
textvariable=self.red, command=self._update_color_rgb)
s_green = Spinbox(rgb_frame, from_=0, to=255, width=4, name='spinbox',
textvariable=self.green, command=self._update_color_rgb)
s_blue = Spinbox(rgb_frame, from_=0, to=255, width=4, name='spinbox',
textvariable=self.blue, command=self._update_color_rgb)
s_red.delete(0, 'end')
s_red.insert(0, self._old_color[0])
s_green.delete(0, 'end')
s_green.insert(0, self._old_color[1])
s_blue.delete(0, 'end')
s_blue.insert(0, self._old_color[2])
s_red.grid(row=0, column=1, sticky='e', padx=4, pady=4)
s_green.grid(row=1, column=1, sticky='e', padx=4, pady=4)
s_blue.grid(row=2, column=1, sticky='e', padx=4, pady=4)
ttk.Label(rgb_frame, text=_('Red')).grid(row=0, column=0, sticky='e',
padx=4, pady=4)
ttk.Label(rgb_frame, text=_('Green')).grid(row=1, column=0, sticky='e',
padx=4, pady=4)
col_frame = ttk.Frame(self)
# --- hsv
hsv_frame = ttk.Frame(col_frame, relief="ridge", borderwidth=2)
hsv_frame.pack(pady=(0, 4), fill="x")
hsv_frame.columnconfigure(0, weight=1)
self.hue = LimitVar(0, 360, self)
self.saturation = LimitVar(0, 100, self)
self.value = LimitVar(0, 100, self)
# self.hue = tk.StringVar(self)
# self.saturation = tk.StringVar(self)
# self.value = tk.StringVar(self)
s_h = Spinbox(hsv_frame, from_=0, to=360, width=4, name='spinbox',
textvariable=self.hue, command=self._update_color_hsv)
s_s = Spinbox(hsv_frame, from_=0, to=100, width=4,
textvariable=self.saturation, name='spinbox',
command=self._update_color_hsv)
s_v = Spinbox(hsv_frame, from_=0, to=100, width=4, name='spinbox',
textvariable=self.value, command=self._update_color_hsv)
h, s, v = rgb_to_hsv(*self._old_color)
s_h.delete(0, 'end')
s_h.insert(0, h)
s_s.delete(0, 'end')
s_s.insert(0, s)
s_v.delete(0, 'end')
s_v.insert(0, v)
s_h.grid(row=0, column=1, sticky='w', padx=4, pady=4)
s_s.grid(row=1, column=1, sticky='w', padx=4, pady=4)
s_v.grid(row=2, column=1, sticky='w', padx=4, pady=4)
ttk.Label(hsv_frame, text=_('Hue')).grid(row=0, column=0, sticky='e',
padx=4, pady=4)
padx=4, pady=4)
ttk.Label(hsv_frame, text=_('Value')).grid(row=2, column=0, sticky='e',
padx=4, pady=4)
# --- rgb
rgb_frame = ttk.Frame(col_frame, relief="ridge", borderwidth=2)
rgb_frame.pack(pady=4, fill="x")
rgb_frame.columnconfigure(0, weight=1)
# self.red = tk.StringVar(self)
# self.green = tk.StringVar(self)
# self.blue = tk.StringVar(self)
self.red = LimitVar(0, 255, self)
self.green = LimitVar(0, 255, self)
self.blue = LimitVar(0, 255, self)
s_red = Spinbox(rgb_frame, from_=0, to=255, width=4, name='spinbox',
textvariable=self.red, command=self._update_color_rgb)
s_green = Spinbox(rgb_frame, from_=0, to=255, width=4, name='spinbox',
textvariable=self.green, command=self._update_color_rgb)
s_blue = Spinbox(rgb_frame, from_=0, to=255, width=4, name='spinbox',
textvariable=self.blue, command=self._update_color_rgb)
s_red.delete(0, 'end')
s_red.insert(0, self._old_color[0])
s_green.delete(0, 'end')
s_green.insert(0, self._old_color[1])
s_blue.delete(0, 'end')
s_blue.insert(0, self._old_color[2])
s_red.grid(row=0, column=1, sticky='e', padx=4, pady=4)
s_green.grid(row=1, column=1, sticky='e', padx=4, pady=4)
s_blue.grid(row=2, column=1, sticky='e', padx=4, pady=4)
ttk.Label(rgb_frame, text=_('Red')).grid(row=0, column=0, sticky='e',
padx=4, pady=4)