Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colorchooser improvements #78

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
551a19c
Create NumberEntry widget
rdbende Mar 1, 2021
a6db0b3
Change the default hover-cursor to hand2
rdbende Mar 1, 2021
7611f2a
Change the movement cursor to fleur
rdbende Mar 1, 2021
61a46c5
Add NumberEntry to __init__.py
rdbende Mar 1, 2021
8941ab3
Fixed portability issues
rdbende Mar 2, 2021
8488995
Restore cursor
rdbende Mar 9, 2021
8b614d2
Restore linklabel
rdbende Mar 9, 2021
9584d3f
Add __getitem__, __setitem__ and configure
rdbende Mar 9, 2021
af42360
Update AUTHORS.md
rdbende Mar 9, 2021
a4af566
Create example for NumberEntry
rdbende Mar 9, 2021
439323e
Create unittest for NumberEntry
rdbende Mar 9, 2021
19f361e
Add NumberEntry to sphinx documentation
rdbende Mar 9, 2021
acdbec5
Update AUTHORS.md
rdbende Mar 9, 2021
fb2dd12
Fixed fatal config bug
rdbende Mar 11, 2021
e5d60f3
Update __init__.py
rdbende Mar 22, 2021
de2d5c2
Update __init__.py
rdbende Mar 22, 2021
d2fa5e6
Update ttkwidgets.rst
rdbende Mar 24, 2021
28d339c
Update __init__.py
rdbende Mar 24, 2021
d7891cb
Update AUTHORS.md
rdbende Mar 24, 2021
e98f416
Delete test_numberentry.py
rdbende Mar 24, 2021
a386adf
Delete example_numberentry.py
rdbende Mar 24, 2021
7806fee
Delete numberentry.py
rdbende Mar 24, 2021
84bcf10
Update functions.py
rdbende Mar 24, 2021
af45532
Update colorpicker.py
rdbende Mar 24, 2021
133ed18
Update gradientbar.py
rdbende Mar 24, 2021
049a9c6
Update alphabar.py
rdbende Mar 24, 2021
66650b4
Update colorsquare.py
rdbende Mar 24, 2021
3e883ba
Update spinbox.py
rdbende Mar 24, 2021
d44c3be
Update colorpicker.py
rdbende Mar 24, 2021
ef832b2
Merge branch 'master' into colorchooser-improvements
rdbende Oct 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 10 additions & 9 deletions ttkwidgets/color/alphabar.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ def __init__(self, parent, alpha=255, color=(255, 0, 0), height=11,
except Exception:
self._variable.trace("w", self._update_alpha)

self.bind('<Configure>', lambda e: self._draw_gradient(alpha, color))
self.bind('<ButtonPress-1>', self._on_click)
self.bind('<B1-Motion>', self._on_move)
self.bind("<Configure>", lambda e: self._draw_gradient(alpha, color))
self.bind("<ButtonPress-1>", self._on_click)
self.bind("<B1-Motion>", self._on_move)

def _draw_gradient(self, alpha, color):
"""Draw the gradient and put the cursor on alpha."""
Expand Down Expand Up @@ -107,20 +107,20 @@ def _draw_gradient(self, alpha, color):
if v < 50:
fill = "gray80"
else:
fill = 'black'
self.create_line(x, 0, x, height, width=2, tags='cursor', fill=fill)
fill = "black"
self.create_line(x, 0, x, height, width=2, tags="cursor", fill=fill)

def _on_click(self, event):
"""Move selection cursor on click."""
x = event.x
self.coords('cursor', x, 0, x, self.winfo_height())
self.coords("cursor", x, 0, x, self.winfo_height())
self._variable.set(round2((255. * x) / self.winfo_width()))

def _on_move(self, event):
"""Make selection cursor follow the cursor."""
w = self.winfo_width()
x = min(max(event.x, 0), w)
self.coords('cursor', x, 0, x, self.winfo_height())
self.coords("cursor", x, 0, x, self.winfo_height())
self._variable.set(round2((255. * x) / w))

def _update_alpha(self, *args):
Expand All @@ -134,7 +134,7 @@ def _update_alpha(self, *args):

def get(self):
"""Return alpha value of color under cursor."""
coords = self.coords('cursor')
coords = self.coords("cursor")
return round2((255. * coords[0]) / self.winfo_width())

def set(self, alpha):
Expand All @@ -149,7 +149,7 @@ def set(self, alpha):
elif alpha < 0:
alpha = 0
x = alpha / 255. * self.winfo_width()
self.coords('cursor', x, 0, x, self.winfo_height())
self.coords("cursor", x, 0, x, self.winfo_height())
self._variable.set(alpha)

def set_color(self, color):
Expand All @@ -164,3 +164,4 @@ def set_color(self, color):
else:
alpha = color[3]
self._draw_gradient(alpha, color[:3])