How to Load a ComboBox From a Python List

A ComboBox control contains a list of options for a user to select. The ComboBox is useful in client apps, because it lets the programmer control the number of selections that can be clicked. Programmers use a Python list of strings to load the ComboBox values. Use this feature to dynamically set up a ComboBox.

Instructions

    • 1

      Open a Python editor and the source code file you want to edit.

    • 2

      Create a new ComboBox and assign the new control to a variable. The following code initializes the variable:

      combobox = gtk.combo_box_new_text()

    • 3

      Load the CombBox with the Python list. The following code adds two options in the ComboBox:

      combobox.append_text("First Selection")
      combobox.append_text("Section Selection")

Related Searches:

References

Comments

Related Ads

Featured