projects/guix·blob python-team · refs

46 lines · 1.7 KiB

1From: Danny Milosavljevic <[email protected]>
2Date: 2026-02-13
3Subject: Fix compatibility with matplotlib 3.6+
4
5Matplotlib 3.6 removed the `message` Qt signal from NavigationToolbar2QT.
6The old API was:
7
8 message = QtCore.Signal(str)
9
10 def set_message(self, s):
11 self.message.emit(s)
12 self.locLabel.setText(s)
13
14The new API just updates the label directly with no signal:
15
16 def set_message(self, s):
17 self.locLabel.setText(s)
18
19Matplotlib provides no replacement signal. The only way to intercept
20toolbar messages is to override the set_message method.
21
22This patch replaces the signal connection with a method override that
23forwards messages to the status bar.
24
25--- a/src/mslice/plotting/plot_window/plot_window.py
26+++ b/src/mslice/plotting/plot_window/plot_window.py
27@@ -274,7 +274,18 @@ class PlotWindow(QtWidgets.QMainWindow):
28
29 def create_status_bar(self):
30 self.statusbar = QtWidgets.QStatusBar(self)
31- self.stock_toolbar.message.connect(self.statusbar.showMessage)
32+ # Matplotlib 3.6 removed the `message` Qt signal from
33+ # NavigationToolbar2QT. The old code was:
34+ #
35+ # self.stock_toolbar.message.connect(self.statusbar.showMessage)
36+ #
37+ # Since matplotlib provides no replacement signal, we override
38+ # set_message to forward messages to the status bar.
39+ original_set_message = self.stock_toolbar.set_message
40+ def set_message_forwarding_to_statusbar(s):
41+ original_set_message(s)
42+ self.statusbar.showMessage(s)
43+ self.stock_toolbar.set_message = set_message_forwarding_to_statusbar
44 self.setStatusBar(self.statusbar)
45
46 def flag_as_kept(self):