def test_cell_layout_cell_data_func(self): import gtk def func(*args): pass layout = gtk.EntryCompletion() render = gtk.CellRendererText() layout.set_cell_data_func(render, func)
def __init__(self): self.out = StringIO() sys.stdout = self.out sys.stderr = self.out self.console = InteractiveConsole() self.console.push('from klaasculator import *') self.window = gtkwindow('Klaasculator Python Console') self.output = gtk.TextView() self.output.modify_font(pango.FontDescription('Monospace')) self.output.set_editable(False) self.output.set_wrap_mode(gtk.WRAP_CHAR) self.buffer = self.output.get_buffer() self.entry = gtk.Entry() self.entry.set_width_chars(80) self.entry.modify_font(pango.FontDescription('Monospace')) self.entry.connect('activate', self.enter, self.entry) self.entry.connect('key-press-event', self.tab) self.completion = gtk.EntryCompletion() self.cstore = gtk.ListStore(str) self.completion.set_model(self.cstore) self.completion.set_text_column(0) self.entry.set_completion(self.completion) self.prompt = gtk.Label() self.prompt.set_width_chars(4) self.prompt.modify_font(pango.FontDescription('Monospace')) self.prompt.set_text('>>>') self.hbox = gtk.HBox() self.hbox.pack_start(self.prompt, expand = False) self.hbox.pack_start(self.entry, expand = True) self.scroll = gtk.ScrolledWindow(None, gtk.Adjustment(value = 0, lower = 0, upper = 1000)) self.scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.scroll.add_with_viewport(self.output) self.scroll.get_vscrollbar().set_range(0, 1) self.box = gtkvbox() self.box.pack_start(self.scroll, expand = True) self.box.pack_start(self.hbox, expand = False) self.window.add(self.box) self.scroll.set_size_request(100, 300) self.entry.grab_focus() self.window.show_all() self.history = [] self.history_iter = 0 self.window.show_all() gtk.main()
def set_autocomp(entry, func, store): completion = gtk.EntryCompletion() entry.set_completion(completion) completion.set_model(store) completion.set_text_column(0) completion.set_inline_completion(True) completion.set_inline_selection(True) completion.set_match_func(func, 0) return entry
def __init__(self): gtk.ComboBoxEntry.__init__(self, gtk.ListStore(str), 0) self.completion = gtk.EntryCompletion() self.child.set_completion(self.completion) self.completion.set_model(self.get_model()) self.completion.set_text_column(0) self.update()
def __init__(self): gtk.Entry.__init__(self) self.comp_list = [] completion = gtk.EntryCompletion() completion.set_match_func(self.match_func) completion.connect("match-selected", self.on_completion_match) completion.set_model(gtk.ListStore(str)) completion.set_text_column(0) self.set_completion(completion)
def __init__(self): gtk.Entry.__init__(self) self.completion = gtk.EntryCompletion() # customize the matching function to match multiple space # separated words self.completion.set_match_func(self.match_func, None) # handle the match-selected signal, raised when a completion # is selected from the popup self.completion.connect('match-selected', self.on_completion_match) self.set_completion(self.completion)
def set_completion(self): self.completion = gtk.EntryCompletion() self.target_list = gtk.ListStore(str) self.completion.set_model(self.target_list) self.completion.set_text_column(0) self.target_entry.set_completion(self.completion) for target in target_list.get_target_list()[:15]: self.target_list.append([target.replace('\n', '')])
def create_replace_entry(self): entry = gtk.Entry() self.replace_completion = gtk.EntryCompletion() entry.set_completion(self.replace_completion) self.replace_model = gtk.ListStore(str) self.replace_completion.set_model(self.replace_model) self.replace_completion.set_text_column(0) entry.show() entry.connect("changed", self.on_entry_changed) return entry
def init_completion(self, file_open=""): self.completion = gtk.EntryCompletion() self.entry_process.set_completion(self.completion) # Create a tree model and use it as the completion model self.completion_model = self.create_completion_model(file_open) self.completion.set_model(self.completion_model) # Use model column 0 as the text column self.completion.set_text_column(0)
def __init__(self, preferences, widget): Preference.__init__(self, preferences, widget) self.list = gtk.ListStore(str) try: try: preset_items = self.preset_items.items() self.list = gtk.ListStore(str, str) text_renderer = self.widget.get_cells()[0] text_renderer.set_property('weight', pango.WEIGHT_BOLD) title_renderer = gtk.CellRendererText() self.widget.pack_start(title_renderer, expand=False) self.widget.add_attribute(title_renderer, 'text', 1) except AttributeError: preset_items = [[item] for item in self.preset_items] for preset in preset_items: self.list.append(preset) except AttributeError: pass self.widget.set_model(self.list) self.widget.set_text_column(0) try: completion = gtk.EntryCompletion() try: completion_items = self.completion_items.items() self.completion_list = gtk.ListStore(str, str) title_renderer = gtk.CellRendererText() completion.pack_end(title_renderer) completion.add_attribute(title_renderer, 'text', 1) except AttributeError: completion_items = [[item] for item in self.completion_items] self.completion_list = gtk.ListStore(str) keyword_renderer = gtk.CellRendererText() keyword_renderer.set_property('weight', pango.WEIGHT_BOLD) completion.pack_end(keyword_renderer) completion.add_attribute(keyword_renderer, 'text', 0) completion.set_match_func(self.on_matching) completion.connect('match-selected', self.on_match_selected) completion.set_popup_single_match(True) completion.set_model(self.completion_list) self.widget.get_child().set_completion(completion) for item in completion_items: self.completion_list.append(item) except AttributeError: pass
def set_completion(self, entry): # Seek entry EntryCompletion self.completion = gtk.EntryCompletion() self.liststore = gtk.ListStore(str) # Add function names to the list for target in self.kblist['hosts']: self.liststore.append([target]) self.completion.set_model(self.liststore) entry.set_completion(self.completion) self.completion.set_text_column(0)
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 __init__(self): gtk.Entry.__init__(self) completion = gtk.EntryCompletion() completion.set_match_func(self.match_func) completion.connect("match-selected", self.on_completion_match) completion.set_model(gtk.ListStore(str)) completion.set_text_column(COL_TEXT) self.set_completion(completion) self.add_words(['abc', 'deff', 'degh','ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'])
def get_completion(): "Return a EntryCompletion" completion = gtk.EntryCompletion() completion.set_match_func(lambda *a: True) completion.set_model(gtk.ListStore(str, int)) completion.set_text_column(0) if hasattr(completion.props, 'popup_set_width'): completion.props.popup_set_width = False completion.insert_action_markup(0, _('<i>Search...</i>')) completion.insert_action_markup(1, _('<i>Create...</i>')) return completion
def __init__(self): gtk.ComboBoxEntry.__init__(self) self.history = gtk.ListStore(str) self.completion = gtk.EntryCompletion() self.completion.set_text_column(0) self.set_text_column(0) self.connect("changed", self.on_changed) self._history_file = os.sep.join((CONFIGDIR, "history.xml")) self.show()
def _get_entry_completion(self): # Check so we have completion enabled, not this does not # depend on the property, the user can manually override it, # as long as there is a completion object set completion = self.get_completion() if completion: return completion completion = gtk.EntryCompletion() self.set_completion(completion) return completion
def setup_edit_widget (self): '''Return an edit widget to let users edit your data. ''' self.cb = cb = gtk.ComboBoxEntry() cb.set_model(self.shopcat_model) cb.set_text_column(0) entry = cb.child completion = gtk.EntryCompletion() completion.set_model(self.shopcat_model) completion.set_text_column(0) entry.set_completion(completion) return cb
def _set_completion(self, metadata): """ Return a predictive text model for value-hints.""" completion = gtk.EntryCompletion() model = gtk.ListStore(str) var_hints = metadata.get(rose.META_PROP_VALUE_HINTS) for hint in var_hints: model.append([hint]) completion.set_model(model) completion.set_text_column(0) completion.set_inline_completion(True) completion.set_minimum_key_length(0) self.entry.set_completion(completion)
def _emit_mode_signal(self, widget): text = self.combobox.get_active_text() if text == "Normal": self.entry.set_completion(None) self.button.props.sensitive = 0 else: completion = gtk.EntryCompletion() self.entry.set_completion(completion) completion.set_model(POSSIBILITY_STORE) completion.set_text_column(0) self.button.props.sensitive = 1 self.emit('mode-changed', text)
def __init__(self, args): gtk.Entry.__init__(self) self.completion = gtk.EntryCompletion() self.completion.connect("match-selected", self.on_completion_match) self.completion.set_model(gtk.ListStore(str)) self.completion.set_text_column(0) self.set_completion(self.completion) if args: self.set_keys(args) else: self.set_keys('name', 'levelname')
def set_entry_completion(widget): """ Set entrycompletion on given widget @param widget: the widget to set entrycompletion """ completion = gtk.EntryCompletion() completion.set_model(widget.get_model()) completion.set_minimum_key_length(1) completion.set_text_column(0) widget.child.set_completion(completion)
def set_completion(self, ctx_map, confirm_clicked, conf): completion = gtk.EntryCompletion() completion.connect('match-selected', self.on_completion_match, confirm_clicked) self.child.set_completion(completion) completion.set_model(ctx_map.completion_model()) completion.set_text_column(0) completion.set_minimum_key_length(3) completion.set_match_func(self.match_func, conf) # Populate the dropdownlist self.set_model(ctx_map.completion_model(SEPARATOR)) self.set_text_column(0)
def register(self, entry): if self.enabled: completion = gtk.EntryCompletion() completion.set_model(self.completions) if self.inlineCompletions: completion.set_inline_completion(True) completion.set_text_column(0) if self.useContainsFunction: # Matching on start is default for gtk.EntryCompletion completion.set_match_func(self.containsMatchFunction) self.addCompletion(entry) entry.set_completion(completion) entry.connect('activate', self.addCompletion) self.entries.append(entry)
def login_auto_completer(self): self.completion = gtk.EntryCompletion() self.completion.set_inline_completion(True) self.completion.set_popup_completion(False) self.tree.get_widget("username_entry").set_completion(self.completion) liststore = gtk.ListStore(str) self.completion.set_model(liststore) pixbufcell = gtk.CellRendererPixbuf() self.completion.pack_start(pixbufcell) self.completion.add_attribute(pixbufcell, 'pixbuf', 3) self.completion.set_text_column(0) users = self.usersDB.get_users(all=True) for user in users: liststore.append([user[0]])
def __init__(self, combo_box): self.combo_box = combo_box self.liststore = gtk.ListStore(gobject.TYPE_STRING) self.combo_box.set_model(self.liststore) self.combo_box.set_text_column(0) self.entry = self.combo_box.get_child() # Autocompletion entry_completion = gtk.EntryCompletion() entry_completion.set_model(self.liststore) entry_completion.set_minimum_key_length(1) entry_completion.set_text_column(0) self.entry.set_completion(entry_completion)
def create_lang_selector(self): lang_selector = gtk.combo_box_entry_new_text() lang_selector.append_text(self.automatic) completion = gtk.EntryCompletion() completion.set_model(lang_selector.get_model()) completion.set_minimum_key_length(1) completion.set_text_column(0) lang_selector.child.set_completion(completion) for name in self.get_lang_names(): lang_selector.append_text(name) return lang_selector
def sig_key_press(self, widget, event): # allow showing available entries by hitting "ctrl+space" completion = gtk.EntryCompletion() if hasattr(completion, 'set_inline_selection'): completion.set_inline_selection(True) if (event.type == gtk.gdk.KEY_PRESS) \ and ((event.state & gtk.gdk.CONTROL_MASK) != 0) \ and (event.keyval == gtk.keysyms.space): self.entry.popup() elif not (event.keyval == gtk.keysyms.Up or event.keyval == gtk.keysyms.Down): completion.set_model(self.model) widget.set_completion(completion) completion.set_text_column(0)
def restart(self): if self.nbook is not None: self.nbook.destroy() self.catbox.destroy() self.nbook = gtk.Notebook() self.nbook.set_show_tabs(False) self.nbook.set_border_width(0) self.nbook.show() self.catbox = gtk.VBox() self.catbox.show() self.catbox.set_spacing(1) self.catbox.set_border_width(1) self.catbox.show() self.mainbox.pack_start(self.catbox, False, False) self.mainbox.pack_start(self.nbook, False, False) self.create_menu() self.catbox.get_children()[0].set_relief(gtk.RELIEF_HALF) if self.entry: for child in self.entrybox.get_children(): child.destroy() self.entry = None if self.settings['run']: self.fl = FileListing(PATH) self.entry = gtk.Entry() self.entry.show() #~ self.entry.set_max_length(150) self.entry.set_width_chars(45) completion = gtk.EntryCompletion() self.entry.set_completion(completion) completion_model = self.create_completion_model() completion.set_model(completion_model) completion.set_text_column(0) self.entry.connect("activate", self.enter_callback) btn = Core.image_button(None, 'images/plugins/run.png', 24) btn.connect("clicked", self.enter_callback) btn.set_focus_on_click(False) self.entrybox.pack_start(self.entry, True, True) self.entrybox.pack_start(btn, False, False)
def widget(self): hbox = gtk.HBox(spacing=6) hbox.connect("show", self.on_show) hbox.connect("hide", self.on_hide) hbox.connect("key-release-event", self.on_key_pressed) lbl = gtk.Label("Search:") lbl.show() hbox.pack_start(lbl, expand=False, fill=False) entry = gtk.Entry() entry.connect("changed", self.on_entry_changed) entry.connect("focus", self.on_entry_focus) entry.connect("activate", self.on_entry_activate) self.search_completion = gtk.EntryCompletion() entry.set_completion(self.search_completion) try: self.search_model = self.parent.search_model except: self.search_model = gtk.ListStore(str) self.parent.search_model = self.search_model self.search_completion.set_model(self.search_model) self.search_completion.set_text_column(0) entry.show() entry.set_activates_default(True) self.entry = entry hbox.pack_start(entry, expand=False, fill=False) # Find backwards btn_back = gtk.Button(stock=gtk.STOCK_GO_BACK) btn_back.show() self.btn_backward = btn_back self.find_backward.connect_proxy(btn_back) hbox.pack_start(btn_back, expand=False, fill=False) # Find forward btn_forward = gtk.Button(stock=gtk.STOCK_GO_FORWARD) btn_forward.show() self.btn_forward = btn_forward self.find_forward.connect_proxy(btn_forward) hbox.pack_start(btn_forward, expand=False, fill=False) self.find.connect("toggled", self.on_find) self.parent.events.register("buffer-changed", self.on_buffer_changed) return hbox
def __init__(self, application): gtk.Entry.__init__(self) self._application = application entry_completion = gtk.EntryCompletion() self.set_completion(entry_completion) liststore = gtk.ListStore(str, str) liststore.set_sort_column_id(1, gtk.SORT_ASCENDING) liststore.set_sort_func(1, self._sort_list) entry_completion.set_model(liststore) entry_completion.set_match_func(self._match_completion) cell = gtk.CellRendererText() entry_completion.pack_start(cell) entry_completion.add_attribute(cell, 'text', 1) entry_completion.connect('match-selected', self._completion_selected) self.connect('changed', self._fill_completion_list, entry_completion)