Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7438275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:31:43+00:00 2026-05-29T10:31:43+00:00

How could I set up the text of a combobox without knowing its id?

  • 0

How could I set up the text of a combobox without knowing its id? I have a combobox populated with a list of name (‘Jack’,’Emily’,’Paul’,…). By default, the combo is set on -1 but I want it to be set on “Paul”.

Here is my code to declare and populate the combo with tuple (id,fabName) :

    self.cmbFabricant = builder.get_object("cmbFabricant")
    self.cmbFabricant.set_model(lstStore)
    self.cmbFabricant.set_entry_text_column(1)

Now, I’d like to set the combobox on the item called “Paul”. I thought I could write :

    self.cmbFabricant.set_active_id('Paul')

I was wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:31:43+00:00Added an answer on May 29, 2026 at 10:31 am

    I could be wrong, but I think set_active_id is new in GTK+ 3, and PyGTK is GTK+ 2. If you want to use GTK+ 3, you have to switch to PyGObject.

    But if you’re stuck on PyGTK, you can easily work around it by doing something like this:

    import gtk
    
    def set_active_name(combobox, col, name):
        liststore = combobox.get_model()
        for i in xrange(len(liststore)):
            row = liststore[i]
            if row[col] == name:
                combobox.set_active(i)
    
    window = gtk.Window()
    window.connect("destroy", gtk.main_quit)
    
    liststore = gtk.ListStore(int, str)
    liststore.append([0, 'Jack'])
    liststore.append([1, 'Emily'])
    liststore.append([2, 'Paul'])
    
    combobox = gtk.ComboBox()
    cell = gtk.CellRendererText()
    combobox.pack_start(cell)
    combobox.add_attribute(cell, 'text', 1)
    combobox.set_model(liststore)
    
    set_active_name(combobox, 1, 'Paul')
    
    window.add(combobox)
    window.show_all()
    
    gtk.main()
    

    I’m not sure if there is a more elegant/efficient way, but this works at least.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just begin programming with android home widget, so i could set text to
The location text from Twitter could be just about anything. Sometimes Twitter clients set
Where Could I set the application name that user see in home screen, under
In android you could set a navigation list in action bar by passing spinner
I have a simple comboBox with some Value/Text items in it. I have using
In former versions of Parallel Extensions you could set the number of threads: enumerable.AsParallel(numberOfThreads)
I was wondering how I could set up css pseudo classes, specifically hover so
How could I set the value of the Height property of a WPF control
I need to compile the unit with /EHsc option, how could i set this
I could use another set of eyes - perhaps I am missing somehting obvious.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.