MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / FontLayout

Class FontLayout

lib/matplotlib/backends/qt_editor/_formlayout.py:163–202  ·  view source on GitHub ↗

Font selection

Source from the content-addressed store, hash-verified

161
162
163class FontLayout(QtWidgets.QGridLayout):
164 """Font selection"""
165 def __init__(self, value, parent=None):
166 super().__init__()
167 font = tuple_to_qfont(value)
168 assert font is not None
169
170 # Font family
171 self.family = QtWidgets.QFontComboBox(parent)
172 self.family.setCurrentFont(font)
173 self.addWidget(self.family, 0, 0, 1, -1)
174
175 # Font size
176 self.size = QtWidgets.QComboBox(parent)
177 self.size.setEditable(True)
178 sizelist = [*range(6, 12), *range(12, 30, 2), 36, 48, 72]
179 size = font.pointSize()
180 if size not in sizelist:
181 sizelist.append(size)
182 sizelist.sort()
183 self.size.addItems([str(s) for s in sizelist])
184 self.size.setCurrentIndex(sizelist.index(size))
185 self.addWidget(self.size, 1, 0)
186
187 # Italic or not
188 self.italic = QtWidgets.QCheckBox(self.tr("Italic"), parent)
189 self.italic.setChecked(font.italic())
190 self.addWidget(self.italic, 1, 1)
191
192 # Bold or not
193 self.bold = QtWidgets.QCheckBox(self.tr("Bold"), parent)
194 self.bold.setChecked(font.bold())
195 self.addWidget(self.bold, 1, 2)
196
197 def get_font(self):
198 font = self.family.currentFont()
199 font.setItalic(self.italic.isChecked())
200 font.setBold(self.bold.isChecked())
201 font.setPointSize(int(self.size.currentText()))
202 return qfont_to_tuple(font)
203
204
205def is_edit_valid(edit):

Callers 1

setupMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…