What changed, and why it matters
This commit adds a simple user-facing feature to Electrum's Qt console: the ability to make the text bigger or smaller using Ctrl+Plus and Ctrl+Minus. It is a straightforward UI improvement with no security relevance.
No security action needed. This is a benign UI enhancement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies electrum/gui/qt/console.py to introduce a configurable font size for the QPlainTextEdit-based console widget. It adds constants for default/min/max font size, stores the current font size in self.font_size, and implements set_font_size() to clamp the value and apply a new QFont. Key press handling now intercepts Ctrl+Plus and Ctrl+Minus to increment/decrement the font size. No input parsing, network, cryptographic, or script execution behavior is changed.
Changed components
electrum/gui/qt/console.pyInspect captured patch +17 / −2
diff --git a/electrum/gui/qt/console.py b/electrum/gui/qt/console.py
index a6ce897..e953c3c 100644
--- a/electrum/gui/qt/console.py
+++ b/electrum/gui/qt/console.py
@@ -1,4 +1,3 @@
-
# source: http://stackoverflow.com/questions/2758159/how-to-embed-a-python-interpreter-in-a-pyqt-widget
import sys
@@ -48,17 +47,22 @@ class OverlayLabel(QtWidgets.QLabel):
class Console(QtWidgets.QPlainTextEdit):
+ DEFAULT_FONT_SIZE = 10
+ MIN_FONT_SIZE = 6
+ MAX_FONT_SIZE = 32
+
def __init__(self, parent=None):
QtWidgets.QPlainTextEdit.__init__(self, parent)
self.history = []
self.namespace = {}
self.construct = []
+ self.font_size = self.DEFAULT_FONT_SIZE
self.setGeometry(50, 75, 600, 400)
self.setWordWrapMode(QtGui.QTextOption.WrapMode.WrapAnywhere)
self.setUndoRedoEnabled(False)
- self.setFont(QtGui.QFont(MONOSPACE_FONT, 10, QtGui.QFont.Weight.Normal))
+ self.setFont(QtGui.QFont(MONOSPACE_FONT, self.font_size, QtGui.QFont.Weight.Normal))
self.newPrompt("") # make sure there is always a prompt, even before first server.banner
self.updateNamespace({'run':self.run_script})
@@ -72,6 +76,11 @@ class Console(QtWidgets.QPlainTextEdit):
)
self.messageOverlay = OverlayLabel(warning_text, self)
+ def set_font_size(self, size: int):
+ size = max(self.MIN_FONT_SIZE, min(self.MAX_FONT_SIZE, size))
+ self.font_size = size
+ self.setFont(QtGui.QFont(MONOSPACE_FONT, self.font_size, QtGui.QFont.Weight.Normal))
+
def resizeEvent(self, e):
super().resizeEvent(e)
vertical_scrollbar_width = self.verticalScrollBar().width() * self.verticalScrollBar().isVisible()
@@ -308,6 +317,12 @@ class Console(QtWidgets.QPlainTextEdit):
elif event.key() == Qt.Key.Key_C and event.modifiers() == Qt.KeyboardModifier.ControlModifier:
if not self.textCursor().selectedText():
self.keyboard_interrupt()
+ elif event.key() == Qt.Key.Key_Plus and Qt.KeyboardModifier.ControlModifier in event.modifiers():
+ self.set_font_size(self.font_size + 1)
+ return
+ elif event.key() == Qt.Key.Key_Minus and Qt.KeyboardModifier.ControlModifier in event.modifiers():
+ self.set_font_size(self.font_size - 1)
+ return
super(Console, self).keyPressEvent(event)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.