SetupWindow.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:mama 作者: maateen 项目源码 文件源码
def __get_speaker_combobox(self):
        """
        @description: get the speaker 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 = 0
        i = 0
        self.speaker_list = ['Mama (Male)', 'His Wife (Female)']
        for speaker_name in self.speaker_list:
            listmodel.append([speaker_name])
            if speaker_name == self.speaker:
                selected = i
            i += 1

        # a combobox to see the data stored in the model
        speaker_combobox = Gtk.ComboBox(model=listmodel)
        speaker_combobox.set_tooltip_text("Whose speaker to choose?")

        # a cellrenderer to render the text
        speaker_cell = Gtk.CellRendererText()

        # pack the cell into the beginning of the combobox, allocating
        # no more space than needed
        speaker_combobox.pack_start(speaker_cell, False)
        # associate a property ("text") of the cellrenderer (cell) to a column (column 0)
        # in the model used by the combobox
        speaker_combobox.add_attribute(speaker_cell, "text", 0)

        # the first row is the active one by default at the beginning
        speaker_combobox.set_active(selected)

        # connect the signal emitted when a row is selected to the callback function
        speaker_combobox.connect("changed", self.on_speaker_combochanged)
        return speaker_combobox
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号