class AutoCompletionTreeView(object): def __init__(self, model, text_view): self.model = model self.completion_tree_view = BrowserTreeView(self.model) self.completion_tree_view.set_enable_search(False) # hide column self.completion_tree_view.set_headers_visible(False) box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.completion_scrolled_win = ScrolledWindow( self.completion_tree_view) self.label = Gtk.Label('Tags') box.add(self.label) box.add(self.completion_scrolled_win) box.show_all() self.column = Gtk.TreeViewColumn() self.completion_tree_view.append_column(self.column) self.renderer_text = Gtk.CellRendererText() self.column.pack_start(self.renderer_text, False) self.column.set_attributes(self.renderer_text, text=DATA_COL) self.completion_scrolled_win.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.completion_scrolled_win.set_propagate_natural_height(True) self.completion_scrolled_win.set_max_content_height(WIN_HEIGHT) self.completion_scrolled_win.set_size_request(WIN_WIDTH, -1) self.column.set_min_width(50) # window to display results self.popover = Gtk.Popover() self.popover.set_relative_to(text_view) self.popover.add(box)
class AutoCompletionTreeView(object): def __init__(self, model): self.model = model self.completion_win = Window() self.completion_win.set_modal(True) self.completion_win.set_keep_above(True) self.completion_tree_view = BrowserTreeView(self.model) self.completion_tree_view.set_enable_search(False) self.completion_scrolled_win = ScrolledWindow( self.completion_tree_view) self.completion_win.add(self.completion_scrolled_win) self.column = Gtk.TreeViewColumn() self.completion_tree_view.append_column(self.column) self.renderer_text = Gtk.CellRendererText() self.column.pack_start(self.renderer_text, False) self.column.set_attributes(self.renderer_text, text=DATA_COL) # display an undecorated window with a grey border self.completion_scrolled_win.set_size_request(WIN_WIDTH, WIN_HEIGHT) self.completion_scrolled_win.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.completion_win.set_decorated(False) self.completion_scrolled_win.set_border_width(2) # self.completion_scrolled_win.modify_bg(Gtk.StateType.NORMAL, Gdk.Color(GREY)) self.column.set_min_width(50) # hide column self.completion_tree_view.set_headers_visible(False)