gtk.OptionMenu
Prev | The gtk Class Reference | Next

## gtk.OptionMenu

gtk.OptionMenu — a widget used to provide a list of valid choices.

## Synopsis

    class gtk.OptionMenu(gtk.Button):
        gtk.OptionMenu()
        def get_menu()
        def set_menu(menu)
        def remove_menu()
        def get_history()
        def set_history(index)

## Ancestry

    +-- gobject.GObject
      +-- gtk.Object
        +-- gtk.Widget
          +-- gtk.Container
            +-- gtk.Bin
              +-- gtk.Button
                +-- gtk.OptionMenu

## Implemented Interfaces

`gtk.OptionMenu` implements `gtk.Buildable`

## gtk.OptionMenu Properties

gtk.Object Properties

gtk.Widget Properties

gtk.Container Properties

gtk.Button Properties

"menu" | Read-Write | The menu of options.

## gtk.OptionMenu Style Properties

gtk.Widget Style Properties

gtk.Button Style Properties

"indicator-size" | Read | The size of the dropdown indicator
"indicator-spacing" | Read | The spacing around the indicator.

## gtk.OptionMenu Signal Prototypes

gobject.GObject Signal Prototypes

gtk.Object Signal Prototypes

gtk.Widget Signal Prototypes

gtk.Container Signal Prototypes

gtk.Button Signal Prototypes

"changed" | `def callback(`optionmenu`, `user_param1`, `...`)`

## Description

### Warning

`gtk.OptionMenu` is deprecated in PyGTK 2.4; use the `gtk.ComboBox` instead.

A `gtk.OptionMenu` is a widget allows the user to choose from a list of valid choices from an associated menu. The `gtk.OptionMenu` displays the last selected choice. When activated (clicked) the `gtk.OptionMenu` displays a popup `gtk.Menu` which allows the user to make a new choice. Using a `gtk.OptionMenu` is simple:

- build a `gtk.Menu` using `gtk.Menu`()
- then append menu items to it using `gtk.MenuShell.append`()
- associate the menu with the option menu using `set_menu`()
- set the selected menu item with `set_history`()
- connect to the "changed" signal on the option menu; in the "changed" signal
- check the new selected menu item with `get_history`().

## Constructor

        gtk.OptionMenu()

Returns : | a new optionmenu widget

Creates a new `gtk.OptionMenu` widget.

## Methods

### gtk.OptionMenu.get_menu

        def get_menu()

Returns : | a menu widget or `None` if no menu is associated

The `get_menu`() method returns the menu that is associated with the optionmenu or `None` if no menu is associated.

### gtk.OptionMenu.set_menu

        def set_menu(menu)

`menu` : | a menu to be associated with the optionmenu

The `set_menu`() method associates the `gtk.Menu` widget specified by `menu` with the optionmenu thus providing the way for a user to select a new choice. A simple menu, avoiding the use of tearoff menu items, submenus, and accelerators, should be used.

### gtk.OptionMenu.remove_menu

        def remove_menu()

The `remove_menu`() method removes the currently associated menu from the optionmenu.

### gtk.OptionMenu.get_history

        def get_history()

Returns : | the index of the selected menu item, or -1 if there are no menu items

The `get_history`() method returns the index of the currently selected menu item or -1 if there are no menu items. The menu items are numbered from top to bottom, starting with 0.

### gtk.OptionMenu.set_history

        def set_history(index)

`index` : | the index of the menu item to display as the selected optionmenu choice

The `set_history`() method selects the menu item specified by `index` as the displayed optionmenu choice.

## Signals

### The "changed" gtk.OptionMenu Signal

        def callback(optionmenu, user_param1, ...)

`optionmenu` : | the optionmenu that received the signal
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "changed" signal is emitted when a new optionmenu choice is made.

Prev | Up | Next
gtk.Object | Home | gtk.PageSetup