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
listmodel.append(['All'])
listmodel.append(['External'])
listmodel.append(['Internal'])
listmodel.append(['Modules'])
# a combobox to see the data stored in the model
combobox = Gtk.ComboBox(model=listmodel)
combobox.set_tooltip_text("What type of command to add?")
# 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(0)
# connect the signal emitted when a row is selected to the callback function
combobox.connect("changed", self.on_combochanged)
return combobox
# callback function attach to the combobox
评论列表
文章目录