KDE 4.5 PyKDE API Reference

- KDE's Python API

# KFontDialog Class Reference

`from PyKDE4.kdeui import *`

Inherits: KDialog → QDialog → QWidget → QObject

## Detailed Description

A font selection dialog.

The KFontDialog provides a dialog for interactive font selection. It is basically a thin wrapper around the KFontChooser widget, which can also be used standalone. In most cases, the simplest use of this class is the static method KFontDialog.getFont(), which pops up the dialog, allows the user to select a font, and returns when the dialog is closed.

Example:

          QFont myFont;
          int result = KFontDialog.getFont( myFont );
          if ( result == KFontDialog.Accepted )
                ...

"KDE Font Dialog"

Author:
  Preston Brown <pbrown@kde.org>, Bernd Wuebben <wuebben@kde.org>

## Signals
| fontSelected (QFont font)
## Methods
| __init__ (self, QWidget parent=0, KFontChooser.DisplayFlags flags=KFontChooser.NoDisplayFlags, QStringList fontlist=QStringList(), Qt::CheckState sizeIsRelativeState=0)
| __init__ (self, KFontDialog a0)
QFont | font (self)
| setFont (self, QFont font, bool onlyFixed=0)
| setSizeIsRelative (self, Qt::CheckState relative)
Qt::CheckState | sizeIsRelative (self)
## Static Methods
SIP_PYTUPLE | getFont (QFont theFont, KFontChooser.DisplayFlags flags=KFontChooser.NoDisplayFlags, QWidget parent=0, Qt::CheckState sizeIsRelativeState=Qt.Unchecked)
SIP_PYTUPLE | getFontAndText (QFont theFont, QString theString, KFontChooser.DisplayFlags flags=KFontChooser.NoDisplayFlags, QWidget parent=0, Qt::CheckState sizeIsRelativeState=Qt.Unchecked)
SIP_PYTUPLE | getFontDiff (QFont theFont, KFontChooser.FontDiffFlags diffFlags, KFontChooser.DisplayFlags flags=KFontChooser.NoDisplayFlags, QWidget parent=0, Qt::CheckState sizeIsRelativeState=Qt.Unchecked)

## Signal Documentation

fontSelected | ( | QFont | font
| ) |  |  |

Emitted whenever the currently selected font changes. Connect to this to monitor the font as it is selected if you are not running modal.

Signal syntax:
  `QObject.connect(source, SIGNAL("fontSelected(const QFont&)"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | QWidget | parent=0,
|  | KFontChooser.DisplayFlags | flags=KFontChooser.NoDisplayFlags,
|  | QStringList | fontlist=QStringList(),
|  | Qt::CheckState | sizeIsRelativeState=0
| ) |  |  |

Constructs a font selection dialog.

Parameters:

  | parent | The parent widget of the dialog, if any.
  | flags | Defines how the font chooser is displayed.

See also:
  KFontChooser.DisplayFlags

Parameters:

  | onlyFixed | only display fonts which have fixed-width character sizes.
  | fontlist | a list of fonts to display, in XLFD format. If no list is formatted, the internal KDE font list is used. If that has not been created, X is queried, and all fonts available on the system are displayed.
  | makeFrame | Draws a frame with titles around the contents.
  | diff | Display the difference version dialog. See getFontDiff().
  | sizeIsRelativeState | If not zero the widget will show a checkbox where the user may choose whether the font size is to be interpreted as relative size. Initial state of this checkbox will be set according to *sizeIsRelativeState, user choice may be retrieved by calling sizeIsRelative().

__init__ | ( | self, |
|  | KFontDialog | a0
| ) |  |  |

QFont font | ( |  | self ) |

Returns:
  The currently selected font in the dialog.

setFont | ( | self, |
|  | QFont | font,
|  | bool | onlyFixed=0
| ) |  |  |

Sets the currently selected font in the dialog.

Parameters:

  | font | The font to select.
  | onlyFixed | readjust the font list to display only fixed width fonts if true, or vice-versa

setSizeIsRelative | ( | self, |
|  | Qt::CheckState | relative
| ) |  |  |

Sets the state of the checkbox indicating whether the font size is to be interpreted as relative size. NOTE: If parameter sizeIsRelative was not set in the constructor of the dialog this setting will be ignored.

Qt::CheckState sizeIsRelative | ( |  | self ) |

Returns:
  Whether the font size is to be interpreted as relative size (default: false)

## Static Method Documentation

SIP_PYTUPLE getFont | ( | QFont | theFont,
|  | KFontChooser.DisplayFlags | flags=KFontChooser.NoDisplayFlags,
|  | QWidget | parent=0,
|  | Qt::CheckState | sizeIsRelativeState=Qt.Unchecked
| ) |  |  |

Creates a modal font dialog, lets the user choose a font, and returns when the dialog is closed.

Parameters:

  | theFont | a reference to the font to write the chosen font into.
  | flags | Defines how the font chooser is displayed.

See also:
  KFontChooser.DisplayFlags

Parameters:

  | parent | Parent widget of the dialog. Specifying a widget different from 0 (Null) improves centering (looks better).
  | makeFrame | Draws a frame with titles around the contents.
  | sizeIsRelativeState | If not zero the widget will show a checkbox where the user may choose whether the font size is to be interpreted as relative size. Initial state of this checkbox will be set according to *sizeIsRelativeState and user choice will be returned therein.

Returns:
  QDialog.result().

SIP_PYTUPLE getFontAndText | ( | QFont | theFont,
|  | QString | theString,
|  | KFontChooser.DisplayFlags | flags=KFontChooser.NoDisplayFlags,
|  | QWidget | parent=0,
|  | Qt::CheckState | sizeIsRelativeState=Qt.Unchecked
| ) |  |  |

When you are not only interested in the font selected, but also in the example string typed in, you can call this method.

Parameters:

  | theFont | a reference to the font to write the chosen font into.
  | theString | a reference to the example text that was typed.
  | flags | Defines how the font chooser is displayed.

See also:
  KFontChooser.DisplayFlags

Parameters:

  | parent | Parent widget of the dialog. Specifying a widget different from 0 (Null) improves centering (looks better).
  | sizeIsRelativeState | If not zero the widget will show a checkbox where the user may choose whether the font size is to be interpreted as relative size. Initial state of this checkbox will be set according to *sizeIsRelativeState and user choice will be returned therein.

Returns:
  The result of the dialog.

SIP_PYTUPLE getFontDiff | ( | QFont | theFont,
|  | KFontChooser.FontDiffFlags | diffFlags,
|  | KFontChooser.DisplayFlags | flags=KFontChooser.NoDisplayFlags,
|  | QWidget | parent=0,
|  | Qt::CheckState | sizeIsRelativeState=Qt.Unchecked
| ) |  |  |

Creates a modal font difference dialog, lets the user choose a selection of changes that should be made to a set of fonts, and returns when the dialog is closed. Useful for choosing slight adjustments to the font set when the user would otherwise have to manually edit a number of fonts.

Parameters:

  | theFont | a reference to the font to write the chosen font into.
  | flags | Defines how the font chooser is displayed.

See also:
  KFontChooser.DisplayFlags

Parameters:

  | diffFlags | a reference to the int into which the chosen difference selection bitmask should be written. Check the returned bitmask like:

            if ( diffFlags & KFontChooser.FontDiffFamily )
                [...]
            if ( diffFlags & KFontChooser.FontDiffStyle )
                [...]
            if ( diffFlags & KFontChooser.FontDiffSize )
                [...]

Parameters:

  | parent | Parent widget of the dialog. Specifying a widget different from 0 (Null) improves centering (looks better).
  | sizeIsRelativeState | If not zero the widget will show a checkbox where the user may choose whether the font size is to be interpreted as relative size. Initial state of this checkbox will be set according to *sizeIsRelativeState and user choice will be returned therein.

Returns:
  QDialog.result().