InternalWindow.py 文件源码

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

项目:mama 作者: maateen 项目源码 文件源码
def __get_combobox(self, store, iter):
        """
        @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
        self.dic = {}
        self.dic[0] = 'time'
        listmodel.append(['time'])
        self.dic[1] = 'power'
        listmodel.append(['power'])
        self.dic[2] = 'clipboard'
        listmodel.append(['clipboard'])

        selected = 0
        if iter is not None:
            for i in range(len(self.dic)):
                if self.dic[i] == store[iter][1]:
                    selected = i

        # a combobox to see the data stored in the model
        combobox = Gtk.ComboBox(model=listmodel)
        combobox.set_tooltip_text("Which internal command 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)

        return combobox
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号