Python gi.repository.Gtk 模块,CellRendererText() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用gi.repository.Gtk.CellRendererText()

项目:pyspc    作者:carlosqsilva    | 项目源码 | 文件源码
def add_treeview(self):
        num_columns = [float for x in range(len(self.data.columns))]

        liststore = Gtk.ListStore(*num_columns)
        for ref in self.data.values.tolist():
            liststore.append(ref)

        treeview = Gtk.TreeView.new_with_model(liststore)
        for i, column_title in enumerate(self.data.columns):
            renderer = Gtk.CellRendererText()
            column = Gtk.TreeViewColumn(column_title, renderer, text=i)
            treeview.append_column(column)

        self.scrollable_treelist = Gtk.ScrolledWindow()
        self.scrollable_treelist.add(treeview)
        self.scrollable_treelist.set_vexpand(True)
        self.scrollable_treelist.set_hexpand(True)
        self.verticalbox.pack_start(self.scrollable_treelist, True, True, 0)
        self.verticalbox.show_all()
项目:gedit-jshint    作者:Meseira    | 项目源码 | 文件源码
def __init__(self, window):
        Gtk.ScrolledWindow.__init__(self)

        # Parent window
        self._window = window

        # Tree view
        self._tree_view = Gtk.TreeView(Gtk.ListStore(int, int, str, str))
        self._tree_view.set_headers_visible(False)
        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Message", renderer, text=2, background=3)
        self._tree_view.append_column(column)
        self._tree_view.connect("row-activated", self.on_row_activated)
        self.add(self._tree_view)

        self.show_all()
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def create_relocs_columns(self):

        rendererPix = Gtk.CellRendererPixbuf()
        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Name")
        column.set_spacing(5)
        column.pack_start(rendererPix, False)
        column.pack_start(rendererText, True)
        column.set_attributes(rendererText, text=1)
        column.set_attributes(rendererPix, pixbuf=0)
        column.set_sort_column_id(0)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Virtual Address", rendererText, text=2)
        self.store.set_sort_column_id(2,Gtk.SortType.ASCENDING)
        column.set_sort_column_id(2)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Size", rendererText, text=3)
        column.set_sort_column_id(3)
        self.append_column(column)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def create_exports_columns(self):

        rendererPix = Gtk.CellRendererPixbuf()
        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Offset")
        column.set_spacing(5)
        column.pack_start(rendererPix, False)
        column.pack_start(rendererText, True)
        column.set_attributes(rendererText, text=1)
        column.set_attributes(rendererPix, pixbuf=0)
        self.store.set_sort_column_id(1,Gtk.SortType.ASCENDING)
        column.set_sort_column_id(1)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Name", rendererText, text=2)
        column.set_sort_column_id(2)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Ordinal", rendererText, text=3)
        column.set_sort_column_id(3)
        self.append_column(column)
        self.set_model(self.store)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def create_classes_tree(self):

        self.treestore = Gtk.TreeStore(GdkPixbuf.Pixbuf, str, str)

        renderer_pix = Gtk.CellRendererPixbuf()
        renderer_text = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn()
        column.set_title("Offset")
        column.set_spacing(5)
        column.pack_start(renderer_pix, True)
        column.pack_start(renderer_text, False)
        column.set_attributes(renderer_pix, pixbuf=0)
        column.set_attributes(renderer_text, text=1)
        self.append_column(column)

        renderer_text = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Name", renderer_text, text=2)
        column.set_sort_column_id(2)
        self.append_column(column)

        self.set_model(self.treestore)
        self.expand_all()
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def create_strings_columns(self):

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Address", rendererText, text=0)
        column.set_sort_column_id(0)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Size", rendererText, text=1)
        #self.store.set_sort_column_id(2,Gtk.SortType.ASCENDING)
        column.set_sort_column_id(1)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("String", rendererText, text=2)
        column.set_sort_column_id(2)
        self.append_column(column)
项目:AncestryCitations    作者:tecknicaltom    | 项目源码 | 文件源码
def __create_gui(self):
        """
        Create and display the GUI components of the gramplet.
        """
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self.model = Gtk.ListStore(object, str, int)
        view = Gtk.TreeView(self.model)
        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(_("Person"), renderer, text=1)
        view.append_column(column)
        renderer = Gtk.CellRendererText()
        renderer.set_property('editable', True)
        renderer.connect('edited', self.__cell_edited)
        column = Gtk.TreeViewColumn(_("ID"), renderer, text=2)
        view.append_column(column)

        vbox.pack_start(view, expand=True, fill=True, padding=0)
        return vbox
项目:pycam    作者:SebKuzminsky    | 项目源码 | 文件源码
def __init__(self, choices, change_handler=None):
        self.model = gtk.ListStore(GObject.TYPE_STRING)
        self._values = []
        for label, value in choices:
            self.model.append((label,))
            self._values.append(value)
        renderer = gtk.CellRendererText()
        self.control = gtk.ScrolledWindow()
        self.control.show()
        self._treeview = gtk.TreeView(self.model)
        self._treeview.show()
        self.control.add(self._treeview)
        self.control.set_shadow_type(gtk.ShadowType.ETCHED_OUT)
        self.control.set_policy(gtk.PolicyType.AUTOMATIC, gtk.PolicyType.AUTOMATIC)
        # Sadly there seems to be no way to adjust the size of the ScrolledWindow to its content.
        # The default size of the ScrolledWindow is too small (making it hard to select the model).
        self.control.set_size_request(200, -1)
        column = gtk.TreeViewColumn()
        column.pack_start(renderer, expand=False)
        column.set_attributes(renderer, text=0)
        self._treeview.append_column(column)
        self._treeview.set_headers_visible(False)
        self._selection = self._treeview.get_selection()
        self._selection.set_mode(gtk.SelectionMode.MULTIPLE)
        self.connect("changed", change_handler, self._selection)
项目:google-tasks-indicator    作者:atareao    | 项目源码 | 文件源码
def create_window(self):
        self.dialog = Gtk.Dialog(None, None, Gtk.DialogFlags.MODAL) 
        self.dialog.set_decorated(False)
        #
        scrolledwindow = Gtk.ScrolledWindow()
        scrolledwindow.set_can_focus(False) 
        scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        scrolledwindow.set_shadow_type(Gtk.ShadowType.ETCHED_OUT)
        self.dialog.vbox.pack_start(scrolledwindow, Gtk.AttachOptions.SHRINK, Gtk.AttachOptions.SHRINK,0)
        #
        self.store = Gtk.ListStore(str)
        for value in self.values:
            self.store.append([value])
        self.tree = Gtk.TreeView(self.store)
        self.tree.set_headers_visible(False)
        self.tree.set_can_focus(False) 
        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(title=None,cell_renderer=renderer, text=0)
        self.tree.append_column(column)
        #
        scrolledwindow.add(self.tree)
        self.tree.connect('focus-out-event',self.on_focus_out)
        self.dialog.connect('focus-out-event',self.on_focus_out)
        self.tree.connect('cursor-changed',self.on_cursor_changed)
        self.dialog.show_all()
项目:XFWM_theme_creator    作者:Sjc1000    | 项目源码 | 文件源码
def __init__(self):
        Gtk.ScrolledWindow.__init__(self)
        self.list = Gtk.ListStore(str, bool)
        self.view = Gtk.TreeView(self.list)
        self.view.set_hexpand(True)
        text_renderer = Gtk.CellRendererText()
        check_renderer = Gtk.CellRendererToggle()
        name_column = Gtk.TreeViewColumn('Gtk color list', text_renderer, text=0)
        check_column = Gtk.TreeViewColumn('', check_renderer, active=1)
        self.view.append_column(check_column)
        self.view.append_column(name_column)
        self.view.connect('row-activated', self.row_activated)
        self.add(self.view)

        names = ['active_text_color', 'inactive_text_color',
                 'active_text_shadow_color', 'inactive_text_shadow_color',
                 'active_border_color', 'inactive_border_color',
                 'active_color_1', 'active_color_2', 'active_highlight_1',
                 'active_highlight_2', 'active_mid_1', 'active_mid_2',
                 'active_shadow_1', 'active_shadow_2', 'inactive_color_1',
                 'inactive_color_2', 'inactive_highlight_1',
                 'inactive_highlight_2', 'inactive_mid_1', 'inactive_mid_2',
                 'inactive_shadow_1', 'inactive_shadow_2']
        for name in names:
            self.list.append([name, False])
项目:plotcommander    作者:FilipDominec    | 项目源码 | 文件源码
def __init__(self):
        super(CellRendererFadeWindow, self).__init__(title="CellRendererFade Example")

        self.set_default_size(200, 200)
        self.liststore = Gtk.ListStore(str, str)
        self.liststore.append(["New", Gtk.STOCK_NEW])
        self.liststore.append(["Open", Gtk.STOCK_OPEN])
        self.liststore.append(["Save", Gtk.STOCK_SAVE])

        treeview = Gtk.TreeView(model=self.liststore)
        renderer_text = Gtk.CellRendererText()
        column_text = Gtk.TreeViewColumn("Text", renderer_text, text=0)
        treeview.append_column(column_text)

        renderer_pixbuf = CellRenderFade(param=0.001)
        column_pixbuf = Gtk.TreeViewColumn("Image", renderer_pixbuf, stock_id=1)
        treeview.append_column(column_pixbuf)
        self.add(treeview)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, icons):
        super(OneConfViews, self).__init__()
        model = Gtk.ListStore(GdkPixbuf.Pixbuf, GObject.TYPE_STRING,
            GObject.TYPE_STRING)
        model.set_sort_column_id(self.COL_HOSTNAME, Gtk.SortType.ASCENDING)
        model.set_sort_func(self.COL_HOSTNAME, self._sort_hosts)
        self.set_model(model)
        self.set_headers_visible(False)
        self.col = Gtk.TreeViewColumn('hostname')

        hosticon_renderer = Gtk.CellRendererPixbuf()
        hostname_renderer = Gtk.CellRendererText()
        self.col.pack_start(hosticon_renderer, False)
        self.col.add_attribute(hosticon_renderer, 'pixbuf', self.COL_ICON)
        self.col.pack_start(hostname_renderer, True)
        self.col.add_attribute(hostname_renderer, 'text', self.COL_HOSTNAME)
        self.append_column(self.col)
        self.current_hostid = None
        self.hostids = []

        # TODO: load the dynamic one (if present), later
        self.default_computer_icon = icons.load_icon("computer", 22, 0)

        self.connect("cursor-changed", self.on_cursor_changed)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, icons):
        super(OneConfViews, self).__init__()
        model = Gtk.ListStore(GdkPixbuf.Pixbuf, GObject.TYPE_STRING,
            GObject.TYPE_STRING)
        model.set_sort_column_id(self.COL_HOSTNAME, Gtk.SortType.ASCENDING)
        model.set_sort_func(self.COL_HOSTNAME, self._sort_hosts)
        self.set_model(model)
        self.set_headers_visible(False)
        self.col = Gtk.TreeViewColumn('hostname')

        hosticon_renderer = Gtk.CellRendererPixbuf()
        hostname_renderer = Gtk.CellRendererText()
        self.col.pack_start(hosticon_renderer, False)
        self.col.add_attribute(hosticon_renderer, 'pixbuf', self.COL_ICON)
        self.col.pack_start(hostname_renderer, True)
        self.col.add_attribute(hostname_renderer, 'text', self.COL_HOSTNAME)
        self.append_column(self.col)
        self.current_hostid = None
        self.hostids = []

        # TODO: load the dynamic one (if present), later
        self.default_computer_icon = icons.load_icon("computer", 22, 0)

        self.connect("cursor-changed", self.on_cursor_changed)
项目:yt-browser    作者:juanfgs    | 项目源码 | 文件源码
def setup_download_queue(self):
        """ Setup the download queue"""
        renderer = Gtk.CellRendererText()
        name = Gtk.TreeViewColumn("Name",renderer,text=0)
        status = Gtk.TreeViewColumn("Status",renderer,text=0)
        progress = Gtk.TreeViewColumn("Progress",renderer,text=0)
        self.download_queue.append_column(name)
        self.download_queue.append_column(status)
        self.download_queue.append_column(progress)
项目:aniwall    作者:worron    | 项目源码 | 文件源码
def build_columns(self, treeview, **kwargs):
        """Build columns for Gtk treeview"""
        for i, item in enumerate(self.data):
            column = Gtk.TreeViewColumn(
                item.get("title"),
                item.get("render", Gtk.CellRendererText(ellipsize=Pango.EllipsizeMode.END)),
                **{item.get("attr", "text"): i}
            )
            column.set_visible(item.get("visible", True))
            for k, v in kwargs.items():
                column.set_property(k, v)
            treeview.append_column(column)
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __init__(self):

        Gtk.Window.__init__(self, title='My Window Title')
        self.connect('delete-event', Gtk.main_quit)        

        store = Gtk.ListStore(str, str, str, str)
        self.populate_store(store)

        self.treeview = Gtk.TreeView(model=store)

        renderer = Gtk.CellRendererText()

        column_catalog = Gtk.TreeViewColumn('Catalog Name', renderer, text=0)
        column_catalog.set_sort_column_id(0)        
        self.treeview.append_column(column_catalog)

        column_dbname = Gtk.TreeViewColumn('Database Name', renderer, text=1)
        column_dbname.set_sort_column_id(1)
        self.treeview.append_column(column_dbname)

        column_charset = Gtk.TreeViewColumn('Character Set', renderer, text=2)
        column_charset.set_sort_column_id(2)
        self.treeview.append_column(column_charset)

        column_collation = Gtk.TreeViewColumn('Collation', renderer, text=3)
        column_collation.set_sort_column_id(3)
        self.treeview.append_column(column_collation)

        scrolled_window = Gtk.ScrolledWindow()
        scrolled_window.set_policy(
            Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        scrolled_window.add(self.treeview)
        scrolled_window.set_min_content_height(200)

        self.add(scrolled_window)
        self.show_all()

    # Add data to ListStore
项目:mama    作者:maateen    | 项目源码 | 文件源码
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
项目: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
项目:mama    作者:maateen    | 项目源码 | 文件源码
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
项目:mama    作者:maateen    | 项目源码 | 文件源码
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
项目: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
项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def setup_widgets(self):
        # Create
        self._icon = Gtk.Image()
        self._model = Gtk.ListStore(str, object, str)
        self._combo = Gtk.ComboBox.new_with_model(self._model)
        self._box = Gtk.Box(Gtk.Orientation.HORIZONTAL, 0)
        self._savebutton = None
        self._switch_to_button = None

        # Setup
        rend1 = Gtk.CellRendererText()
        rend2 = Gtk.CellRendererText()
        self._icon.set_margin_right(10)
        self._combo.pack_start(rend1, True)
        self._combo.pack_start(rend2, False)
        self._combo.add_attribute(rend1, "text", 0)
        self._combo.add_attribute(rend2, "text", 2)
        self._combo.set_row_separator_func(
            lambda model, iter : model.get_value(iter, 1) is None and model.get_value(iter, 0) == "-" )
        self.update_icon()

        # Signals
        self._combo.connect('changed', self.on_combo_changed)
        self.connect("button_press_event", self.on_button_press)

        # Pack
        self._box.pack_start(self._icon, False, True, 0)
        self._box.pack_start(self._combo, True, True, 0)
        self.add(self._box)
项目:jcchess    作者:johncheetham    | 项目源码 | 文件源码
def __init__(self):

        glade_dir = gv.jcchess.get_glade_dir()
        self.glade_file = os.path.join(glade_dir, "gamelist.glade")

        # create gamelist window
        self.builder = Gtk.Builder()
        self.builder.set_translation_domain(gv.domain)
        self.builder.add_from_file(self.glade_file)
        self.builder.connect_signals(self)

        self.window = self.builder.get_object("gamelist_window")
        self.treeview = self.builder.get_object("gamelist_treeview")
        self.liststore = self.builder.get_object("liststore1")

        cell0 = Gtk.CellRendererText()
        # cell0.set_property("cell-background", Gdk.color_parse("#F8F8FF"))
        tvcolumn0 = Gtk.TreeViewColumn()
        self.treeview.append_column(tvcolumn0)
        tvcolumn0.pack_start(cell0, True)
        tvcolumn0.set_min_width(50)
        tvcolumn0.set_attributes(cell0, text=0)
        self.treeview.connect("row_activated", self.entry_clicked)
        self.tree_selection = self.treeview.get_selection()

        self.window.hide()

    # user has closed the window
    # just hide it
项目:RetroArch-Playlists-Generator    作者:Kierek    | 项目源码 | 文件源码
def __init__(self):
        from playlist_creator import preferences_file_location, systems_list

        self.settings_file_location = preferences_file_location
        with open(self.settings_file_location) as data_file:
            self.preferences_data = json.load(data_file)

        builder = Gtk.Builder()
        builder.add_from_file("glade/app.glade")
        builder.connect_signals(self)

        self.notebook = builder.get_object("notebook")
        self.renderer_text = Gtk.CellRendererText()

        self.playlists_directory_chooser = builder.get_object("playlists_directory_chooser")
        self.cores_directory_chooser = builder.get_object("cores_directory_chooser")
        self.infos_directory_chooser = builder.get_object("infos_directory_chooser")

        self.playlists_location = self.preferences_data[0]['playlists_location']
        self.cores_location = self.preferences_data[0]['cores_location']
        self.infos_location = self.preferences_data[0]['infos_location']

        self.playlists_directory_chooser.set_current_folder(self.playlists_location)
        self.cores_directory_chooser.set_current_folder(self.cores_location)
        self.infos_directory_chooser.set_current_folder(self.infos_location)

        self.system_names = Gtk.ListStore(str)
        for system_name in systems_list:
            self.system_names.append([system_name])

        # get all cores and populate list
        self.__populate_cores_list__()

        if len(self.preferences_data) > 1:
            for system_from_prefs in self.preferences_data[1]:
                self.create_new_tab(system_from_prefs['system_name'], system_from_prefs['roms_dir'],
                                    system_from_prefs['core_path'], system_from_prefs['core_name'])

        window = builder.get_object("window")
        window.show_all()
        Gtk.main()
项目:sbrick-controller    作者:wintersandroid    | 项目源码 | 文件源码
def create_channel_box(self, channel_number):
        hbox = Gtk.FlowBox()
        hbox.set_max_children_per_line(8)
        hbox.set_min_children_per_line(8)
        hbox.set_selection_mode(Gtk.SelectionMode.NONE)

        hbox.add(Gtk.Label("Channel: %d" % channel_number))

        hbox.add(Gtk.Label("ID:"))
        id_edit = Gtk.Entry()
        id_edit.set_max_length(5)
        hbox.add(id_edit)

        hbox.add(Gtk.Label("Name:"))
        name_edit = Gtk.Entry()
        name_edit.set_max_length(20)
        hbox.add(name_edit)
        hbox.add(Gtk.Label("Type:"))
        combo_type = Gtk.ComboBoxText()
        combo_type.set_id_column(0)
        combo_type.set_model(self.channelTypeStore)
        renderer_text = Gtk.CellRendererText()
        combo_type.clear()
        combo_type.pack_start(renderer_text, True)
        combo_type.add_attribute(renderer_text, "text", 1)
        hbox.add(combo_type)

        self.content.pack_start(hbox, False, True, 0)
        return id_edit, name_edit, combo_type
项目:sbrick-controller    作者:wintersandroid    | 项目源码 | 文件源码
def __init__(self):
        Gtk.Frame.__init__(self)
        self.sbrick = None
        self.set_label("SBrick Information")

        self.store = Gtk.ListStore(str, str)
        self.iterSBrickID = self.store.append(["SBrick BlueGiga ID", "--"])
        self.iterHardwareVersion = self.store.append(["Hardware Version", "--"])
        self.iterSoftwareVersion = self.store.append(["Software Version", "--"])
        self.iterNeedAuthentication = self.store.append(["Need Authentication", "--"])
        self.iterIsAuthenticated = self.store.append(["Is Authenticated", "--"])
        self.iterAuthenticationTimeout = self.store.append(["Authentication Timeout", "--"])
        self.iterInputVoltage = self.store.append(["Input Voltage", "--"])
        self.iterTemperature = self.store.append(["Temperature", "--"])
        self.iterPowerCycles = self.store.append(["Power Cycles", "--"])
        self.iterWatchdogTimeout = self.store.append(["Watchdog Timeout", "--"])
        self.iterUpTime = self.store.append(["Up Time", "--"])
        self.iterThermalLimit = self.store.append(["Thermal Limit", "--"])

        self.listView = Gtk.TreeView(self.store)

        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Item", renderer, text=0)
        self.listView.append_column(column)

        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Value", renderer, text=1)
        self.listView.append_column(column)

        self.scrollTree = Gtk.ScrolledWindow()
        self.scrollTree.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        self.scrollTree.add_with_viewport(self.listView)
        self.scrollTree.set_min_content_height(100)

        self.add(self.scrollTree)
        self.set_sensitive(False)
项目:btcwidget    作者:rafalh    | 项目源码 | 文件源码
def _create_market_combo(self):
        store = Gtk.ListStore(str, str, str)
        for market_config in config['markets']:
            provider = btcwidget.exchanges.factory.get(market_config['exchange'])
            market_name = '{} - {}'.format(provider.get_name(), market_config['market'])
            store.append([market_name, market_config['exchange'], market_config['market']])
        combo = Gtk.ComboBox.new_with_model(store)
        renderer_text = Gtk.CellRendererText()
        combo.pack_start(renderer_text, True)
        combo.add_attribute(renderer_text, "text", 0)
        return combo, store
项目:isar    作者:ilbers    | 项目源码 | 文件源码
def __init__(self, model, dep_type, label):
        Gtk.TreeView.__init__(self)
        self.current = None
        self.dep_type = dep_type
        self.filter_model = model.filter_new()
        self.filter_model.set_visible_func(self._filter, data=None)
        self.set_model(self.filter_model)
        self.append_column(Gtk.TreeViewColumn(label, Gtk.CellRendererText(), text=COL_DEP_PACKAGE))
项目:isar    作者:ilbers    | 项目源码 | 文件源码
def __init__(self, model, label):
        Gtk.TreeView.__init__(self)
        self.current = None
        self.filter_model = model.filter_new()
        self.filter_model.set_visible_func(self._filter)
        self.set_model(self.filter_model)
        self.append_column(Gtk.TreeViewColumn(label, Gtk.CellRendererText(), text=COL_DEP_PARENT))
项目:mcg    作者:coderkun    | 项目源码 | 文件源码
def __init__(self, builder):
        GObject.GObject.__init__(self)
        self._services = Gtk.ListStore(str, str, int)
        self._profile = None

        # Widgets
        self._panel = builder.get_object('server-panel')
        self._toolbar = builder.get_object('server-toolbar')
        # Zeroconf
        self._zeroconf_list = builder.get_object('server-zeroconf-list')
        self._zeroconf_list.set_model(self._services)
        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Zeroconf", renderer, text=0)
        self._zeroconf_list.append_column(column)
        # Host
        self._host_entry = builder.get_object('server-host')
        # Port
        self._port_spinner = builder.get_object('server-port')
        # Passwort
        self._password_entry = builder.get_object('server-password')
        # Image directory
        self._image_dir_entry = builder.get_object('server-image-dir')

        # Zeroconf provider
        self._zeroconf_provider = ZeroconfProvider()
        self._zeroconf_provider.connect_signal(ZeroconfProvider.SIGNAL_SERVICE_NEW, self.on_new_service)
项目:ez_gpg    作者:sgnn7    | 项目源码 | 文件源码
def __init__(self, app):
        super().__init__(app, 'key_management', "Key Management")

        builder = self.get_builder()

        # XXX: Keeping state is bad but we can fix this later
        self._selected_keys = []

        self._key_list_box = builder.get_object('lst_keys')
        self._refresh_key_list()

        self._keyserver_combo = builder.get_object('cmb_keyserver')

        # Populate keyserver list
        keyserver_list = Gtk.ListStore(str, str)
        for keyserver in Config.get_keyservers():
            keyserver_list.append([keyserver, keyserver])

        cell = Gtk.CellRendererText()
        self._keyserver_combo.pack_start(cell, True)
        self._keyserver_combo.add_attribute(cell, 'text', 1)

        self._keyserver_combo.set_model(keyserver_list)
        self._keyserver_combo.set_id_column(0)
        self._keyserver_combo.set_entry_text_column(1)

        # Set default keyserver
        self._keyserver_combo.set_active(0)

        self._edit_key_button = builder.get_object('btn_edit')
        self._upload_key_button = builder.get_object('btn_upload')
        self._export_key_button = builder.get_object('btn_export')
        self._delete_key_button = builder.get_object('btn_delete')

        self.add(builder.get_object('main_vbox'))

        self._update_button_state()
项目:ez_gpg    作者:sgnn7    | 项目源码 | 文件源码
def add_gpg_keys_to_combo_box(combo_box, secret=False):
        gpg_keys_list = Gtk.ListStore(str, str)
        for key in GpgUtils.get_gpg_keys(secret):
            key_id = key[0]
            key_name = key[1]
            gpg_keys_list.append([key_id, key_name])

        cell = Gtk.CellRendererText()
        combo_box.pack_start(cell, True)
        combo_box.add_attribute(cell, 'text', 1)

        combo_box.set_model(gpg_keys_list)
        combo_box.set_entry_text_column(1)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def create_functions_columns(self):

        rendererText = Gtk.CellRendererText()
        rendererText.tooltip_handle = self.connect('motion-notify-event', self.fcn_tooltip)
        rendererPix = Gtk.CellRendererPixbuf()
        column = Gtk.TreeViewColumn("Function")
        column.set_spacing(5)
        column.pack_start(rendererPix, False)
        column.pack_start(rendererText, True)
        column.set_attributes(rendererText, text=1)
        column.set_attributes(rendererPix, pixbuf=0)
        column.set_sort_column_id(1)
        self.store.set_sort_column_id(1,Gtk.SortType.ASCENDING)
        self.append_column(column)
        self.set_model(self.store)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def create_sections_columns(self):

        rendererPix = Gtk.CellRendererPixbuf()
        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Name")
        column.set_spacing(5)
        column.pack_start(rendererPix, False)
        column.pack_start(rendererText, True)
        column.set_attributes(rendererText, text=1)
        column.set_attributes(rendererPix, pixbuf=0)
        column.set_sort_column_id(0)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Virtual Address", rendererText, text=2)
        self.store.set_sort_column_id(2,Gtk.SortType.ASCENDING)
        column.set_sort_column_id(2)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Virtual Size", rendererText, text=3)
        column.set_sort_column_id(3)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Raw Size", rendererText, text=4)
        column.set_sort_column_id(4)
        self.append_column(column)
        self.set_model(self.store)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def create_classes_columns(self):
        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Name", rendererText, text=0)
        column.set_sort_column_id(0)
        self.append_column(column)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def create_tree(self):
        # Scrolled Window
        self.sw = Gtk.ScrolledWindow()
        self.sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
        self.sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)

        self.store = Gtk.ListStore(str, str)
        self.tree = Gtk.TreeView(self.store)

        self.sw.add(self.tree)

        self.tree.set_rules_hint(True)

        # Connect right click popup search menu
        self.popup_handler = self.tree.connect('button-press-event', self.popup_menu)

        # Create the column
        bblocks = Gtk.TreeViewColumn()
        bblocks.set_title("Basic Blocks")

        cell = Gtk.CellRendererText()
        bblocks.pack_start(cell, True)
        bblocks.add_attribute(cell, "text", 0)

        self.treestore = Gtk.TreeStore(str)

        # Add column to tree
        self.tree.append_column(bblocks)
        self.tree.set_model(self.treestore)
        self.tree.expand_all()
项目:pycam    作者:SebKuzminsky    | 项目源码 | 文件源码
def __init__(self, choices, start=None, change_handler=None):
        self.model = gtk.ListStore(GObject.TYPE_STRING)
        self._values = []
        for label, value in choices:
            self.model.append((label, ))
            self._values.append(value)
        renderer = gtk.CellRendererText()
        self.control = gtk.ComboBox.new_with_model(self.model)
        self.control.pack_start(renderer, expand=False)
        self.control.add_attribute(renderer, 'text', 0)
        if start is None:
            self.control.set_active(0)
        else:
            self.set_value(start)
        self.connect("changed", change_handler)
项目:GPU-Viewer    作者:arunsivaramanneo    | 项目源码 | 文件源码
def setColumns(Treeview, Title, MWIDTH,align):
    for i, column_title in enumerate(Title):
        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(column_title, renderer, text=i)
        column.set_sort_column_id(i)
        column.set_alignment(align)
        column.add_attribute(renderer, "background", len(Title))
        column.set_property("min-width", MWIDTH)
        Treeview.set_property("can-focus",False)
        Treeview.append_column(column)


# adding Scrollbar to the Treeview
项目:GPU-Viewer    作者:arunsivaramanneo    | 项目源码 | 文件源码
def setColumnFrameBuffer(TreeFB,Title):
    for i, column_title in enumerate(Title):

        FBrenderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(column_title, FBrenderer, text=i)
        column.add_attribute(FBrenderer, "background", 25)
        if i < len(Title) - 1:
            FBrenderer.set_alignment(0.5, 0.5)
            column.set_alignment(0.5)
        column.set_property("min-width", 40)
        TreeFB.set_property("can-focus", False)
        TreeFB.append_column(column)
项目:GPU-Viewer    作者:arunsivaramanneo    | 项目源码 | 文件源码
def setOclColumns(Treeview,Title):
    for i, column_title in enumerate(Title):
        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(column_title, renderer, text=i)
        column.add_attribute(renderer, "background", len(Title))
        if i == 1:
            column.add_attribute(renderer, "foreground", len(Title) + 1)
        column.set_property("min-width", Const.MWIDTH)
        Treeview.set_property("can-focus", False)
        Treeview.append_column(column)
项目:nautilus-git    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def _build_widgets(self):
        """Generate the headerbar."""
        header_bar = self._builder.get_object("headerbar")
        title = _("Comparing commits of {0}").format(
            self._git.get_project_name())

        header_bar.set_title(title)

        self._stats = self._builder.get_object("stats")

        # Build list of modified files
        self._source = self._builder.get_object("source")
        files = self._git.get_modified()
        files.sort()
        liststore = Gtk.ListStore(str)
        for filename in files:
            liststore.append([filename])

        combobox = self._builder.get_object("files")
        combobox.set_model(liststore)

        renderer_text = Gtk.CellRendererText()
        combobox.pack_start(renderer_text, True)
        combobox.add_attribute(renderer_text, "text", 0)

        combobox.set_active(0)
        # Load the buffer of the first file on the list
        self._set_buffer(files[0])
项目:ridinghood    作者:Aeva    | 项目源码 | 文件源码
def __init__(self):
        builder = Gtk.Builder()
        builder.add_from_file("layout.glade")
        builder.connect_signals(self)

        window = builder.get_object("BrowserWindow")
        window.set_default_size(900, 675)

        self.url_bar = builder.get_object("UrlBar")
        self.refresh_button = builder.get_object("Refresh")
        self.history_forward = builder.get_object("HistoryForward")
        self.history_backward = builder.get_object("HistoryBackward")

        # create popup menu for browser tabs
        self.tab_menu = TabContextMenu(self)
        self.uni_menu = UniverseContextMenu(self)

        # tabs tracks the open BrowserTab objects
        self.tabs = {}
        self.focused = None
        self.tab_store = builder.get_object("TabTreeStore")
        self.tab_tree_view = builder.get_object("TabTreeView")
        self.tab_tree_view.set_activate_on_single_click(True)

        # stores a list of tab ID's, in order of call
        self.focus_history = []

        # setup the treeview's renderer
        renderer = Gtk.CellRendererText()
        renderer.set_property("ellipsize", 3)
        self.title_column = Gtk.TreeViewColumn("Tab Title", renderer, text=0)
        self.tab_tree_view.append_column(self.title_column)
        self.tab_tree_view.connect("row_activated", self.tree_activates_tab)

        # self.views tracks all of the sockets
        self.views = builder.get_object("ViewPorts")

        window.show_all()

        # create a new tab
        self.new_tab("http://duckduckgo.com")
项目:pytimetrack    作者:fhackerz    | 项目源码 | 文件源码
def __init__(self):
        Gtk.TreeView.__init__(self)
        self.task_store = Gtk.TreeStore(str, str)
        self.set_model(self.task_store)
        column = Gtk.TreeViewColumn(_('Tasks'), Gtk.CellRendererText(), text=0)
        self.append_column(column)
        self.connect('notify::tasks', self.tasks_changed)
项目:ACYLS    作者:worron    | 项目源码 | 文件源码
def build_data_stores(self):
        """Build stores for GUI dataviews"""
        self.store = dict()

        # custom icons
        self.ied = {'Name': 0, 'State': 1}
        self.store['custom_icons'] = Gtk.ListStore(str, bool)
        self.store['custom_icons'].append(["Simple Icon Group", False])

        renderer_toggle = Gtk.CellRendererToggle()
        renderer_toggle.connect("toggled", self.on_custom_icon_toggled)

        self.gui['custom_icons_treeview'].append_column(Gtk.TreeViewColumn("Name", Gtk.CellRendererText(), text=0))
        self.gui['custom_icons_treeview'].append_column(Gtk.TreeViewColumn("State", renderer_toggle, active=1))
        self.gui['custom_icons_treeview'].set_model(self.store['custom_icons'])

        # color list
        self.ced = {'Color': 0, 'Alpha': 1, 'Offset': 2, 'RGBA': 3}
        colorstore_visible_keys = [k for k in self.ced.keys() if k != 'RGBA']

        self.store['colorlist'] = Gtk.ListStore(str, float, int, str)
        for key in sorted(colorstore_visible_keys, key=lambda k: self.ced[k]):
            self.gui['colorlist_treeview'].append_column(
                Gtk.TreeViewColumn(key, Gtk.CellRendererText(), text=self.ced[key])
            )
        self.gui['colorlist_treeview'].set_model(self.store['colorlist'])

        # gradient direction
        self.ded = {'Coord': 0, 'Value': 1}
        self.store['direction'] = Gtk.ListStore(str, int)
        self.gui['renderer_spin'] = Gtk.CellRendererSpin(editable=True, adjustment=Gtk.Adjustment(0, 0, 100, 5, 0, 0))
        self.signals['direction_edited'] = self.gui['renderer_spin'].connect("edited", self.on_direction_edited)

        self.gui['direction_treeview'].append_column(Gtk.TreeViewColumn("Coord", Gtk.CellRendererText(), text=0))
        self.gui['direction_treeview'].append_column(Gtk.TreeViewColumn("Value", self.gui['renderer_spin'], text=1))
        self.gui['direction_treeview'].set_model(self.store['direction'])
项目:ssh-manager    作者:Doka-NT    | 项目源码 | 文件源码
def __fill_listbox(self):
        self._list_store.clear()
        connections = self._manager.get_connections()
        for connection in connections:
            self._list_store.append([connection.label])

        renderer = Gtk.CellRendererText()
        column = self._listbox.get_column(0)
        if not column:
            column = Gtk.TreeViewColumn(None, renderer, text=0)
            self._listbox.append_column(column)
        self._listbox.show_all()

    # noinspection PyUnusedLocal
项目:Postgres-GUI    作者:atlast    | 项目源码 | 文件源码
def run_query(self, query):
        try:
            for column in self.query_tree.get_columns():
                self.query_tree.remove_column(column)

            cursor = self.conn.cursor()
            cursor.execute(query)
            self.conn.commit()

            self.query_info.set_text(cursor.statusmessage)

            if not cursor.description:
                return

            columns = []
            # TODO get rid of manual incrementing
            i = 0
            for description in cursor.description:
                renderer = Gtk.CellRendererText()
                column = Gtk.TreeViewColumn(description.name.replace('_', '__'), renderer, text=i)
                column.set_resizable(True)
                i += 1
                self.query_tree.append_column(column)
                columns.append(str)

            store = Gtk.ListStore(*columns)

            for row in cursor.fetchall():
                store.append([str(i) for i in row])

            self.query_tree.set_model(store)

        except DatabaseError as e:
            Alert(e.message, self.query_tree.get_toplevel())
            self.conn.rollback()

        self.query_tree.show_all()
项目:Postgres-GUI    作者:atlast    | 项目源码 | 文件源码
def refresh_schema(self):
        cursor = self.conn.cursor()
        cursor.execute('SELECT * FROM %s LIMIT 1' % self.table)

        for column in self.data_tree.get_columns():
            self.data_tree.remove_column(column)

        self.columns = []
        # TODO get rid of manual incrementing
        i = 0
        for description in cursor.description:
            s = None
            if description.type_code == 16:
                renderer = Gtk.CellRendererToggle()
                self.columns.append(bool)
                column = Gtk.TreeViewColumn(description.name.replace('_', '__'), renderer, active=i)
            else:
                renderer = Gtk.CellRendererText()
                renderer.set_property('editable', True)
                renderer.connect('edited', self.on_text_edit, i)
                renderer.set_property('placeholder-text', 'Null')
                renderer.set_property('ellipsize', Pango.EllipsizeMode.END)
                self.columns.append(str)
                column = Gtk.TreeViewColumn(description.name.replace('_', '__'), renderer, text=i)

            column.set_clickable(True)
            column.set_resizable(True)
            column.set_fixed_width(100)
            if i == 0:
                # TODO Should this be here?
                self.order = description.name
                column.set_sort_indicator(True)
                column.set_sort_order(1)
                self.last_selected_column = column
            column.connect('clicked', self.on_column_click, description.name)
            self.data_tree.append_column(column)
            i += 1

        self.store = Gtk.ListStore(*self.columns)
        self.data_tree.set_model(self.store)
项目:lightdm-settings    作者:linuxmint    | 项目源码 | 文件源码
def __init__(self, keyfile, settings, key, options, valtype="string"):
        self.key = key
        self.keyfile = keyfile
        try:
            self.value = keyfile.get_string(GROUP_NAME, key)
        except:
            self.value = settings.get_string(key)
        Gtk.ComboBox.__init__(self)
        renderer_text = Gtk.CellRendererText()
        self.pack_start(renderer_text, True)
        self.add_attribute(renderer_text, "text", 1)
        self.set_valign(Gtk.Align.CENTER)

        # assume all keys are the same type (mixing types is going to cause an error somewhere)
        var_type = type(options[0][0])
        self.model = Gtk.ListStore(var_type, str)
        self.valtype = valtype
        self.option_map = {}
        for option in options:
            self.option_map[option[0]] = self.model.append([option[0], option[1]])

        self.set_model(self.model)
        self.set_id_column(0)

        if self.value in self.option_map.keys():
            self.set_active_iter(self.option_map[self.value])

        self.connect("changed", self.on_changed)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, header, cache, pkgnames, icons, icon_size, db):
        super(PackageNamesView, self).__init__()
        model = Gtk.ListStore(GdkPixbuf.Pixbuf, str)
        self.set_model(model)
        tp = Gtk.CellRendererPixbuf()
        column = Gtk.TreeViewColumn("Icon", tp, pixbuf=self.COL_ICON)
        self.append_column(column)
        tr = Gtk.CellRendererText()
        tr.set_property("ellipsize", Pango.EllipsizeMode.END)
        column = Gtk.TreeViewColumn(header, tr, markup=self.COL_TEXT)
        self.append_column(column)
        for pkgname in sorted(pkgnames):
            if (not pkgname in cache or
                not cache[pkgname].installed):
                continue
            s = "%s \n<small>%s</small>" % (
                cache[pkgname].installed.summary.capitalize(), pkgname)

            app_details = Application("", pkgname).get_details(db)
            proposed_icon = app_details.icon
            if not proposed_icon or not icons.has_icon(proposed_icon):
                proposed_icon = Icons.MISSING_APP
            if icons.has_icon(proposed_icon):
                icon = icons.load_icon(proposed_icon, icon_size, 0)
                pb = icon.scale_simple(
                    icon_size, icon_size, GdkPixbuf.InterpType.BILINEAR)
            else:
                LOG.warn("cant set icon for '%s' " % pkgname)
                pb = icons.load_icon(Icons.MISSING_APP,
                                     icon_size,
                                     Gtk.IconLookupFlags.GENERIC_FALLBACK)
                pb = pb.scale_simple(icon_size,
                                     icon_size, GdkPixbuf.InterpType.BILINEAR)
            model.append([pb, s])

        # finally, we don't allow selection, it's just a simple display list
        tree_selection = self.get_selection()
        tree_selection.set_mode(Gtk.SelectionMode.NONE)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, icons, layout, show_ratings, overlay_icon_name):
        Gtk.CellRendererText.__init__(self)

        # the icon pixbuf to be displayed in the row
        self.icon = None

        # geometry-state values
        self.pixbuf_width = 0
        self.apptitle_width = 0
        self.apptitle_height = 0
        self.normal_height = 0
        self.selected_height = 0
        self.show_ratings = show_ratings

        # button packing
        self.button_spacing = 0
        self._buttons = {
            Gtk.PackType.START: [],
            Gtk.PackType.END: []
        }
        self._all_buttons = {}

        # cache a layout
        self._layout = layout
        # star painter, paints stars
        self._stars = StarRenderer()
        self._stars.size = StarSize.SMALL

        # icon/overlay jazz
        try:
            self._installed = icons.load_icon(overlay_icon_name,
                                              self.OVERLAY_SIZE, 0)
        except GObject.GError:
            # icon not present in theme, probably because running uninstalled
            self._installed = icons.load_icon('emblem-system',
                                              self.OVERLAY_SIZE, 0)