質問

I would like to make an item in my ComboBoxText the default value, instead of a blank combo box until the user selects something. Apparently, this is set by changing Active value in Glade to [the item I want to be default]. This does not work.

Here is my code:

#! /usr/bin/env python3

from gi.repository import Gtk

builder = Gtk.Builder()

builder.add_from_file("./personalinfo.ui")

win = builder.get_object("window")
cancel = builder.get_object("cancel")
ok = builder.get_object("ok")

win.set_title("Persona")

win.connect("destroy", Gtk.main_quit)
cancel.connect("clicked", Gtk.main_quit)
ok.connect("clicked", Gtk.main_quit)

win.show_all()

Gtk.main()

Here is the combo box in Glade:

comboboxtext

役に立ちましたか?

解決

This is actually a bug in Glade. You can manually set this by using:

combo.set_active(int) # 1st item is 0, 2nd is 1, etc.
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top