Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix ToolManager inconsistencies with regular toolbar #18006

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 2 commits into from
Aug 2, 2020
Merged
Show file tree
Hide file tree
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
15 changes: 10 additions & 5 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2984,11 +2984,9 @@ def _wait_cursor_for_draw_cm(self):
else:
yield

def mouse_move(self, event):
self._update_cursor(event)

@staticmethod
def _mouse_event_to_message(event):
if event.inaxes and event.inaxes.get_navigate():

try:
s = event.inaxes.format_coord(event.xdata, event.ydata)
except (ValueError, OverflowError):
Expand All @@ -3005,7 +3003,14 @@ def mouse_move(self, event):
data_str = a.format_cursor_data(data).rstrip()
if data_str:
s = s + '\n' + data_str
self.set_message(s)
return s

def mouse_move(self, event):
self._update_cursor(event)

s = self._mouse_event_to_message(event)
if s is not None:
self.set_message(s)
else:
self.set_message(self.mode)

Expand Down
25 changes: 4 additions & 21 deletions lib/matplotlib/backend_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,27 +339,10 @@ def send_message(self, event):
if self.toolmanager.messagelock.locked():
return

message = ' '

if event.inaxes and event.inaxes.get_navigate():
try:
s = event.inaxes.format_coord(event.xdata, event.ydata)
except (ValueError, OverflowError):
pass
else:
artists = [a for a in event.inaxes._mouseover_set
if a.contains(event) and a.get_visible()]

if artists:
a = cbook._topmost_artist(artists)
if a is not event.inaxes.patch:
data = a.get_cursor_data(event)
if data is not None:
data_str = a.format_cursor_data(data)
if data_str is not None:
s = s + ' ' + data_str

message = s
from matplotlib.backend_bases import NavigationToolbar2
message = NavigationToolbar2._mouse_event_to_message(event)
if message is None:
message = ' '
self.toolmanager.message_event(message, self)


Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/backends/_backend_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,8 +747,7 @@ def _get_groupframe(self, group):
return self._groups[group]

def _add_separator(self):
separator = tk.Frame(master=self, bd=5, width=1, bg='black')
separator.pack(side=tk.LEFT, fill=tk.Y, padx=2)
return NavigationToolbar2Tk._Spacer(self)

def _button_click(self, name):
self.trigger_tool(name)
Expand Down