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

Skip to content

Commit 6cfbb4c

Browse files
authored
Merge pull request #18146 from meeseeksmachine/auto-backport-of-pr-17989-on-v3.3.x
Backport PR #17989 on branch v3.3.x (gtk/tk: Ensure no flicker when hovering over images.)
2 parents 2c61e4a + f673efc commit 6cfbb4c

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/matplotlib/backends/_backend_tk.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,14 @@ def __init__(self, canvas, window, *, pack_toolbar=True):
518518
if tooltip_text is not None:
519519
ToolTip.createToolTip(button, tooltip_text)
520520

521+
# This filler item ensures the toolbar is always at least two text
522+
# lines high. Otherwise the canvas gets redrawn as the mouse hovers
523+
# over images because those use two-line messages which resize the
524+
# toolbar.
525+
label = tk.Label(master=self,
526+
text='\N{NO-BREAK SPACE}\n\N{NO-BREAK SPACE}')
527+
label.pack(side=tk.RIGHT)
528+
521529
self.message = tk.StringVar(master=self)
522530
self._message_label = tk.Label(master=self, textvariable=self.message)
523531
self._message_label.pack(side=tk.RIGHT)

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,17 @@ def __init__(self, canvas, window):
521521
toolitem.set_draw(False)
522522
toolitem.set_expand(True)
523523

524+
# This filler item ensures the toolbar is always at least two text
525+
# lines high. Otherwise the canvas gets redrawn as the mouse hovers
526+
# over images because those use two-line messages which resize the
527+
# toolbar.
528+
toolitem = Gtk.ToolItem()
529+
self.insert(toolitem, -1)
530+
label = Gtk.Label()
531+
label.set_markup(
532+
'<small>\N{NO-BREAK SPACE}\n\N{NO-BREAK SPACE}</small>')
533+
toolitem.add(label)
534+
524535
toolitem = Gtk.ToolItem()
525536
self.insert(toolitem, -1)
526537
self.message = Gtk.Label()
@@ -536,7 +547,8 @@ def ctx(self):
536547
return self.canvas.get_property("window").cairo_create()
537548

538549
def set_message(self, s):
539-
self.message.set_label(s)
550+
escaped = GLib.markup_escape_text(s)
551+
self.message.set_markup(f'<small>{escaped}</small>')
540552

541553
def set_cursor(self, cursor):
542554
window = self.canvas.get_property("window")

0 commit comments

Comments
 (0)