Skip to content

Give the Tk toolbar buttons a flat look #22174

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

Merged
merged 1 commit into from
Jan 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/matplotlib/backends/_backend_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,10 @@ def _set_image_for_button(self, button):

def _Button(self, text, image_file, toggle, command):
if not toggle:
b = tk.Button(master=self, text=text, command=command)
b = tk.Button(
master=self, text=text, command=command,
relief="flat", overrelief="groove", borderwidth=1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the border width inside or outside the button? Just wondering if the size we allocate is consistent on HiDPI screens?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's outside of the button, and the default width seems to be 2, so space shouldn't be an issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm more concerned about the height of the toolbar than the width of the border itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The toolbar height is set to the height of two text lines here, which on all platforms I've tried is bigger than the size of the buttons, so the buttons becoming 2px smaller shouldn't affect the height of the toolbar.

)
else:
# There is a bug in tkinter included in some python 3.6 versions
# that without this variable, produces a "visual" toggling of
Expand All @@ -667,8 +670,10 @@ def _Button(self, text, image_file, toggle, command):
# https://bugs.python.org/issue25684
var = tk.IntVar(master=self)
b = tk.Checkbutton(
master=self, text=text, command=command,
indicatoron=False, variable=var)
master=self, text=text, command=command, indicatoron=False,
variable=var, offrelief="flat", overrelief="groove",
borderwidth=1
)
b.var = var
b._image_file = image_file
if image_file is not None:
Expand Down