def __get_combobox(self):
"""
@description: get the combobox of the toolbar
@return: a Gtk.Combobox
"""
# the data in the model, of type string
listmodel = Gtk.ListStore(str)
# append the data in the model
selected = 4
i = 0
self.language_list = ['en-AU', 'en-CA', 'en-GB', 'en-IN', 'en-US']
for language_name in self.language_list:
listmodel.append([language_name])
if language_name == self.locale:
selected = i
i += 1
# a combobox to see the data stored in the model
combobox = Gtk.ComboBox(model=listmodel)
combobox.set_tooltip_text("What format to choose?")
# a cellrenderer to render the text
cell = Gtk.CellRendererText()
# pack the cell into the beginning of the combobox, allocating
# no more space than needed
combobox.pack_start(cell, False)
# associate a property ("text") of the cellrenderer (cell) to a column (column 0)
# in the model used by the combobox
combobox.add_attribute(cell, "text", 0)
# the first row is the active one by default at the beginning
combobox.set_active(selected)
# connect the signal emitted when a row is selected to the callback function
combobox.connect("changed", self.on_combochanged)
return combobox
评论列表
文章目录