我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用gi.repository.Gtk.EntryCompletion()。
def __init_txt_goto(self): completion = Gtk.EntryCompletion() store = Gtk.ListStore(str) artists_name = {x.Name for x in ArtistsPlaylist().collections()} albums_name = {x.Name for x in AlbumsPlaylist().collections()} for x in artists_name.union(albums_name): store.append([x]) completion.set_model(store) completion.set_text_column(0) completion.set_inline_completion(True) completion.set_match_func(self.__txt_goto_match_func) completion.set_inline_selection(True) completion.connect('match_selected', lambda x, y, z: self.__manage_goto()) self.txt_goto.set_completion(completion)
def set_completion(self): # Seek entry EntryCompletion self.completion = Gtk.EntryCompletion() self.liststore = Gtk.ListStore(str) # Add function names to the list for function in self.uicore.allfuncs: self.liststore.append([function]) self.completion.set_model(self.liststore) self.seek.set_completion(self.completion) self.completion.set_text_column(0)
def set_up_completion(self): completion = self.gtk_completion = Gtk.EntryCompletion() self.completion_choices = Gtk.ListStore(str) self.completion_choices_as_set = set() completion.set_model(self.completion_choices) completion.set_text_column(0) if self.gtk_completion_enabled: self.set_completion(completion)
def __init__(self): Gtk.Window.__init__(self, title='Search emoji', skip_taskbar_hint=True) self.set_keep_above(True) self.set_resizable(False) self.set_icon_name(shared.icon) self.set_type_hint(Gdk.WindowTypeHint.UTILITY) self.set_default_size(250, 45) self.set_border_width(6) self.connect('show', self.window_shown) self.connect('delete-event', self.hide_window) self.connect('configure-event', self.window_moved) self.entry = Gtk.Entry() self.add(self.entry) self.full_completer = Gtk.EntryCompletion() self.entry.set_completion(self.full_completer) self.full_completer.set_model(shared.emoji.sorted_full) full_pixbuf_cell = Gtk.CellRendererPixbuf() self.full_completer.pack_start(full_pixbuf_cell, False) self.full_completer.add_attribute(full_pixbuf_cell, 'pixbuf', 0) full_text_cell = Gtk.CellRendererText() self.full_completer.pack_start(full_text_cell, True) self.full_completer.set_cell_data_func( full_text_cell, shared.emoji.full_highlighter, None) self.full_completer.set_match_func(shared.emoji.match_full, None) self.short_completer = Gtk.EntryCompletion() self.short_completer.set_model(shared.emoji.sorted_short) short_pixbuf_cell = Gtk.CellRendererPixbuf() self.short_completer.pack_start(short_pixbuf_cell, False) self.short_completer.add_attribute(short_pixbuf_cell, 'pixbuf', 0) short_text_cell = Gtk.CellRendererText() self.short_completer.pack_start(short_text_cell, True) self.short_completer.set_cell_data_func( short_text_cell, shared.emoji.short_highlighter, None) self.short_completer.set_match_func(shared.emoji.match_short, None) self.entry.connect('changed', self.set_model) self.entry.connect('activate', self.select_first) self.full_completer.connect('match-selected', self.paste_emoji) self.short_completer.connect('match-selected', self.paste_emoji) self.full_completer.connect('cursor-on-match', self.paste_emoji) self.short_completer.connect('cursor-on-match', self.paste_emoji)