text stringlengths 0 828 |
|---|
"""""" |
p = Popen(command.split(), stdout=PIPE, stderr=PIPE) |
(stdout, stderr) = p.communicate() |
# On python 3, subprocess.Popen returns bytes objects. |
if not raw_output: |
return ( |
p.returncode, |
[line.rstrip() for line in stdout.decode(""utf-8"").splitlines()], |
[line.rstrip() for line in stderr.decode(""utf-8"").splitlines()] |
) |
else: |
return (p.returncode, stdout, stderr)" |
985,"def mpl_weight2qt(weight): |
""""""Convert a weight from matplotlib definition to a Qt weight |
Parameters |
---------- |
weight: int or string |
Either an integer between 1 and 1000 or a string out of |
:attr:`weights_mpl2qt` |
Returns |
------- |
int |
One type of the PyQt5.QtGui.QFont.Weight"""""" |
try: |
weight = weights_mpl2qt[weight] |
except KeyError: |
try: |
weight = float(weight) / 10 |
except (ValueError, TypeError): |
weight = QtGui.QFont.Normal |
else: |
try: |
weight = min(filter(lambda w: w >= weight, weights_qt2mpl), |
key=lambda w: abs(w - weight)) |
except ValueError: |
weight = QtGui.QFont.Normal |
return weight" |
986,"def artist_to_qfont(artist): |
""""""Convert a :class:`matplotlib.text.Text` artist to a QFont object |
Parameters |
---------- |
artist: matplotlib.text.Text |
The text artist, e.g. an axes title |
Returns |
------- |
PyQt5.QtGui.QFont |
The QFont object"""""" |
size = int(artist.get_size()) |
weight = mpl_weight2qt(artist.get_weight()) |
italic = artist.get_style() == 'italic' |
for family in artist.get_family(): |
if family in ['sans-serif', 'cursive', 'monospace', 'serif']: |
for name in mpl.rcParams['font.' + family]: |
font = QtGui.QFont(name, size, weight, italic) |
if font.exactMatch(): |
break |
else: |
font = QtGui.QFont(family, size, weight, italic) |
return font" |
987,"def choose_font(self, font=None): |
""""""Choose a font for the label through a dialog"""""" |
fmt_widget = self.parent() |
if font is None: |
if self.current_font: |
font, ok = QFontDialog.getFont( |
self.current_font, fmt_widget, |
'Select %s font' % self.fmto_name, |
QFontDialog.DontUseNativeDialog) |
else: |
font, ok = QFontDialog.getFont(fmt_widget) |
if not ok: |
return |
self.current_font = font |
properties = self.load_properties() |
properties.update(self.qfont_to_artist_props(font)) |
fmt_widget.set_obj(properties) |
self.refresh()" |
988,"def refresh(self): |
""""""Refresh the widgets from the current font"""""" |
font = self.current_font |
# refresh btn_bold |
self.btn_bold.blockSignals(True) |
self.btn_bold.setChecked(font.weight() > 50) |
self.btn_bold.blockSignals(False) |
# refresh btn_italic |
self.btn_italic.blockSignals(True) |
self.btn_italic.setChecked(font.italic()) |
self.btn_italic.blockSignals(False) |
# refresh font size |
self.spin_box.blockSignals(True) |
self.spin_box.setValue(font.pointSize()) |
self.spin_box.blockSignals(False)" |
989,"def init_app(self, app): |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.