KDE 4.9 PyKDE API Reference

- KDE's Python API

# KLanguageButton Class Reference

`from PyKDE4.kdeui import *`

Inherits: QWidget → QObject

## Detailed Description

KLanguageButton is a pushbutton which allows a language to be selected from a popup list.

Languages are identified by their ISO 639-1 codes, e.g. en, pt_BR.

"KDE Language Selection Widget"

Author:
  Hans Petter Bieker <bieker@kde.org>, Martijn Klingens <klingens@kde.org>,

David Jarvie <software@astrojar.org.uk>

## Signals

| activated (QString languageCode)
| highlighted (QString languageCode)

## Methods

| __init__ (self, QWidget parent=0)
| __init__ (self, QString text, QWidget parent=0)
| clear (self)
bool | contains (self, QString languageCode)
int | count (self)
QString | current (self)
| insertLanguage (self, QString languageCode, QString name=QString(), int index=-1)
| insertSeparator (self, int index=-1)
| loadAllLanguages (self)
| setCurrentItem (self, QString languageCode)
| setLocale (self, KLocale locale)
| setText (self, QString text)
| showLanguageCodes (self, bool show)

## Signal Documentation

activated | ( | QString | languageCode
| ) |  |  |

This signal is emitted when a new item is activated.

Parameters:

  | languageCode | code of the activated language

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

highlighted | ( | QString | languageCode
| ) |  |  |

This signal is emitted when a new item is highlighted.

Parameters:

  | languageCode | code of the highlighted language

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

## Method Documentation

__init__ | ( | self, |
|  | QWidget | parent=0
| ) |  |  |

Constructs a button whose text is determined by the current language in the popup list.

Parameters:

  | parent | the parent of the button

__init__ | ( | self, |
|  | QString | text,
|  | QWidget | parent=0
| ) |  |  |

Constructs a button with static text.

Parameters:

  | text | the text of the button
  | parent | the parent of the button

clear | ( |  | self ) |

Removes all combobox items.

bool contains | ( | self, |
|  | QString | languageCode
| ) |  |  |

Checks whether the specified language is in the popup list.

Parameters:

  | languageCode | the language's code

Returns:
  true if in the list

int count | ( |  | self ) |

Returns the number of items in the combo box.

QString current | ( |  | self ) |

Returns the language code of the combobox's current item.

Returns:
  the current item's language code

insertLanguage | ( | self, |
|  | QString | languageCode,
|  | QString | name=QString(),
|  | int | index=-1
| ) |  |  |

Inserts a language into the combo box. Normally the display name of the language is obtained automatically, but if either the language code does not exist, or there are special display requirements, the name of the language can be specified in name.

Parameters:

  | languageCode | the code for the language
  | name | language name. If empty, the name is obtained automatically.
  | index | the insertion position, or -1 to insert in alphabetical order

insertSeparator | ( | self, |
|  | int | index=-1
| ) |  |  |

Inserts a separator item into the combo box. A negative index will append the item.

Parameters:

  | index | the insertion position

loadAllLanguages | ( |  | self ) |

Load all known languages into the popup list. The current language in the list is set to the default language for the current locale (as modified by setLocale()).

setCurrentItem | ( | self, |
|  | QString | languageCode
| ) |  |  |

Sets a given language to be the current item.

Parameters:

  | languageCode | the language's code

setLocale | ( | self, |
|  | KLocale | locale
| ) |  |  |

Sets the locale to display language names. By default, KGlobal.locale() is used.

Parameters:

  | locale | locale to use

setText | ( | self, |
|  | QString | text
| ) |  |  |

Sets a static button text.

Parameters:

  | text | button text

showLanguageCodes | ( | self, |
|  | bool | show
| ) |  |  |

Specifies whether language codes should be shown alongside language names in the popup. Calling this method does not affect any previously inserted language texts, so it should normally be called before populating the list.

Parameters:

  | show | true to show codes, false to hide codes