def __get_rate_combobox(self):
"""
@description: get the sample rate combobox of the toolbar
@return: a Gtk.Combobox
"""
# the data in the model, of type string
listmodel = Gtk.ListStore(int)
# append the data in the model
selected = 0
i = 0
self.rate_list = [8000, 16000]
for rate_name in self.rate_list:
listmodel.append([rate_name])
if rate_name == self.audio_rate:
selected = i
i += 1
# a combobox to see the data stored in the model
rate_combobox = Gtk.ComboBox(model=listmodel)
rate_combobox.set_tooltip_text("Set Sampling Rate")
# a cellrenderer to render the text
rate_cell = Gtk.CellRendererText()
# pack the cell into the beginning of the combobox, allocating
# no more space than needed
rate_combobox.pack_start(rate_cell, False)
# associate a property ("text") of the cellrenderer (cell) to a column (column 0)
# in the model used by the combobox
rate_combobox.add_attribute(rate_cell, "text", 0)
# the first row is the active one by default at the beginning
rate_combobox.set_active(selected)
# connect the signal emitted when a row is selected to the callback function
rate_combobox.connect("changed", self.on_rate_combochanged)
return rate_combobox
评论列表
文章目录