Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>An <code>Entry</code> with an <a href="http://www.pygtk.org/docs/pygtk/class-gtkentrycompletion.html" rel="noreferrer"><code>EntryCompletion</code></a> seems more appropriate than a <code>ComboBoxEntry</code>. As always, the <a href="http://www.pygtk.org/pygtk2tutorial/sec-EntryCompletion.html" rel="noreferrer">tutorial</a> is a good start.</p> <p>It's very easy to set up when the predefined URLs list is small and fixed. You just need to populate a ListStore:</p> <pre><code># simplified example from the tutorial import gtk urls = [ 'http://www.google.com', 'http://www.google.com/android', 'http://www.greatstuff.com', 'http://www.facebook.com', ] liststore = gtk.ListStore(str) for s in urls: liststore.append([s]) completion = gtk.EntryCompletion() completion.set_model(liststore) completion.set_text_column(0) entry = gtk.Entry() entry.set_completion(completion) # boilerplate window = gtk.Window() window.add(entry) window.connect('destroy', lambda w: gtk.main_quit()) window.show_all() gtk.main() </code></pre> <p>Users are not likely to bother typing "http://" or even "www.", so you probably want to match any part of the URL (e.g. just "og" works!):</p> <pre><code>def match_anywhere(completion, entrystr, iter, data): modelstr = completion.get_model()[iter][0] return entrystr in modelstr completion.set_match_func(match_anywhere, None) </code></pre> <p>This will test every value in the ListStore for a match, so it's not scalable to huge lists (I mean <em>huge</em>; a 1000 works fine).</p> <p>Be sure to play with the various options of EntryCompletion, to configure the most pleasant behavior.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload