Skip to content

Commit 9de5745

Browse files
committed
[pyqgis-console] Sets minimum height for input area based of font metric
1 parent 50542b9 commit 9de5745

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

python/console/console_sci.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ def __init__(self, parent=None):
9191

9292
# not too small
9393
#self.setMinimumSize(500, 300)
94-
self.setMinimumHeight(20)
9594

9695
self.setWrapMode(QsciScintilla.WrapCharacter)
9796
self.SendScintilla(QsciScintilla.SCI_EMPTYUNDOBUFFER)
@@ -113,6 +112,13 @@ def __init__(self, parent=None):
113112
self.newShortcutCAS.activated.connect(self.autoCompleteKeyBinding)
114113
self.newShortcutCSS.activated.connect(self.showHistory)
115114

115+
def _setMinimumHeight(self):
116+
fnt = self.settings.value("pythonConsole/fontfamilytext", "Monospace")
117+
fntSize = self.settings.value("pythonConsole/fontsize", 10, type=int)
118+
fm = QFontMetrics(QFont(fnt, fntSize))
119+
120+
self.setMinimumHeight(fm.height() + 10)
121+
116122
def refreshSettingsShell(self):
117123
# Set Python lexer
118124
self.setLexers()
@@ -133,6 +139,9 @@ def refreshSettingsShell(self):
133139
cursorColor = self.settings.value("pythonConsole/cursorColor", QColor(Qt.black))
134140
self.setCaretForegroundColor(cursorColor)
135141

142+
# Sets minimum height for input area based of font metric
143+
self._setMinimumHeight()
144+
136145
def showHistory(self):
137146
if not self.historyDlg.isVisible():
138147
self.historyDlg.show()

0 commit comments

Comments
 (0)