<s> from PyQt4 import QtCore , QtGui <EOL> class QFontButton ( QtGui . QWidget ) : <EOL> fontChanged = QtCore . pyqtSignal ( '<STR_LIT>' ) <EOL> def __init__ ( self , font = None , parent = None ) : <EOL> super ( ) . __init__ ( parent ) <EOL> layout = QtGui . QVBoxLayout ( self ) <EOL> self . label = QtGui . QLabel ( "<STR_LIT>" , self ) <EOL> self . button = QtGui . QPushButton ( self ) <EOL> self . button . clicked . connect ( lambda x : self . adjustFont ( ) ) <EOL> layout . addWidget ( self . label ) <EOL> layout . addWidget ( self . button ) <EOL> if isinstance ( font , QtGui . QFont ) : <EOL> self . font = font <EOL> else : <EOL> self . font = QtGui . QFont ( ) <EOL> def adjustFont ( self ) : <EOL> self . font , _ = QtGui . QFontDialog . getFont ( self . font , self , "<STR_LIT>" ) <EOL> def font ( self ) : <EOL> return self . _font <EOL> def setFont ( self , font ) : <EOL> if isinstance ( font , QtGui . QFont ) : <EOL> self . _font = font <EOL> self . button . setText ( "<STR_LIT>" . format ( font . family ( ) , font . pointSize ( ) ) ) <EOL> self . label . setFont ( font ) <EOL> self . fontChanged . emit ( self . font ) <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> font = QtCore . pyqtProperty ( '<STR_LIT>' , fget = font , fset = setFont ) </s>
