Skip to content

Commit

Permalink
Feature remove for more consistency
Browse files Browse the repository at this point in the history
Remove apdative highlightbackground, trigger on _bg_ change.
  • Loading branch information
Saadmairaj committed May 19, 2021
1 parent 5d8e69a commit b784ff4
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions tkmacosx/basewidgets/button_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,9 @@ def _get_master_bg():
if self.cnf.get('bordercolor') == _get_master_bg():
self.cnf.pop('bordercolor', None)
self.cnf.pop('highlightbackground', None)
bd_color = self.cnf.get(
'bordercolor', get_shade(self['bg'], 0.04, 'auto-120'))
bd_color = self.cnf.get('bordercolor', SYSTEM_DEFAULT.bg)

This comment has been minimized.

Copy link
@Saadmairaj

Saadmairaj May 19, 2021

Author Owner

fix to #27

if bd_color == '':
bd_color = get_shade(self['bg'], 0.04, 'auto-120')
elif bd_color.lower() == 'default':
bd_color = get_shade('white', 0.04, 'auto-120')
self.cnf.update({'bordercolor': bd_color})
bd_color = SYSTEM_DEFAULT.bg
self.cnf['highlightbackground'] = self.cnf['bordercolor'] = bd_color
if self.itemcget('_bd_color', 'outline') != bd_color:
_opt[1] = [('itemconfigure', '_bd_color'), {'outline': bd_color}, None]
Expand Down Expand Up @@ -229,9 +225,7 @@ def overforeground(self, kw):
{'className': 'overforeground', 'sequence': '<Leave>',
'func': fn.get('<Leave>')}]
if self._mouse_state_condition():
# [issue-3] doesn't change if overrelief is on.
# [issue-3] (FIXED) using after with 0ms delay
# fixes the issue. To be safe delay is 1ms.

self.after(1, lambda: _Canvas._configure(self,
('itemconfigure', '_txt'), {'fill': kw.get('overforeground')}, None))
elif kw.get('overforeground') == '':
Expand Down Expand Up @@ -408,7 +402,7 @@ def _img(self, *ags, **kw):

def _bd_color(self, *ags, **kw):
"Border color item."
bd_color = self.cnf.get('bordercolor', get_shade(self['bg'], 0.04, 'auto-120'))
bd_color = self.cnf.get('bordercolor', SYSTEM_DEFAULT.bg)
if self._type == 'circle':
pad = 2
width = r = int(self.cnf.get('width', 87)/2) # radius = x = y (in pixels)
Expand Down Expand Up @@ -598,8 +592,6 @@ def overfg(seq):
'<Leave>': if_state(lambda _: self._configure(
'configure', {'_relief': self._rel[0]}))},

# [issue-3] doesn't change if overrelief is on.
# [issue-3] (FIXED) using after with 0ms delay fixes the issue. To be safe delay is 1ms.
'overforeground': {'<Enter>': if_state(lambda _: self.after(1, overfg, 'enter')),
'<Leave>': if_state(lambda _: overfg('leave'))},

Expand Down Expand Up @@ -816,9 +808,7 @@ def _set_size(self, evt=None):
cur_focus.focus()
else:
self.master.focus()
# [issue-7] Need a better fix to get focus back to the button if it has it previously
if cur_focus == self:
# [issue-7] (fixed) using after with 1ms delay solves the issue.
self._after_IDs[3] = self.after(1, self.focus)

def _active(self, value):
Expand Down Expand Up @@ -1053,7 +1043,7 @@ def __init__(self, _type=None, master=None, cnf={}, **kw):
_Canvas.__init__(self, master=master, **kw)
self.cnf = check_param(self, 'button', **cnf)
self.cnf['bordercolor'] = self.cnf['highlightbackground'] = self.cnf.get(
'bordercolor', self.cnf.get('highlightbackground', get_shade(self['bg'], 0.04, 'auto-120')))
'bordercolor', self.cnf.get('highlightbackground', SYSTEM_DEFAULT.bg))

self._buttons.append(self)
self._size = (self.winfo_width(), self.winfo_height())
Expand Down

0 comments on commit b784ff4

Please sign in to comment.