def selectFont(self, fontSample, fontVar, showFontInfo=False, options=QFontDialog.FontDialogOptions(0)): """ Public method used by the font selection buttons. @param fontSample reference to the font sample widget (QLineEdit) @param fontVar reference to the variable containing the font (QFont) @param showFontInfo flag indicating to show some font info as the sample (boolean) @param options options for the font dialog (QFontDialog.FontDialogOptions) @return selected font (QFont) """ font, ok = QFontDialog.getFont(fontVar, self, "", options) if ok: fontSample.setFont(font) if showFontInfo: fontSample.setText("{0} {1}".format(font.family(), font.pointSize())) else: font = fontVar return font
""" from __future__ import unicode_literals from PyQt5.QtCore import pyqtSlot from PyQt5.QtWidgets import QFontDialog from .ConfigurationPageBase import ConfigurationPageBase from .Ui_ShellPage import Ui_ShellPage import Preferences try: MonospacedFontsOption = QFontDialog.MonospacedFonts except AttributeError: MonospacedFontsOption = QFontDialog.FontDialogOptions(0x10) class ShellPage(ConfigurationPageBase, Ui_ShellPage): """ Class implementing the Shell configuration page. """ def __init__(self): """ Constructor """ super(ShellPage, self).__init__() self.setupUi(self) self.setObjectName("ShellPage") # set initial values