KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /usr/lib64/pygtk/2.0/demos/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/lib64/pygtk/2.0/demos/entry_completion.py
#!/usr/bin/env python
'''Entry Completion

GtkEntryCompletion provides a mechanism for adding support for
completion in GtkEntry.
'''
# pygtk version: Maik Hertha <maik.hertha@berlin.de>

import gtk

class EntryCompletionDemo(gtk.Dialog):

    def __init__(self, parent=None):
        gtk.Dialog.__init__(self, self.__class__.__name__, parent,
            0,
            (gtk.STOCK_CLOSE, gtk.RESPONSE_NONE))
        try:
            self.set_screen(parent.get_screen())
        except AttributeError:
            self.connect('destroy', lambda *w: gtk.main_quit())
        self.connect("response", lambda d, r: d.destroy())
        self.set_resizable(False)

        vbox = gtk.VBox(False, 5)
        self.vbox.pack_start(vbox, True, True, 0)
        vbox.set_border_width(5)

        label = gtk.Label()
        label.set_markup("Completion demo, try writing <b>total</b> "
            "or <b>gnome</b> for example.")
        vbox.pack_start(label, False, False, 0)

        # Create our entry
        entry = gtk.Entry()
        vbox.pack_start(entry, False, False, 0)

        # Create the completion object
        completion = gtk.EntryCompletion()

        # Assign the completion to the entry
        entry.set_completion(completion)

        # Create a tree model and use it as the completion model
        completion_model = self.__create_completion_model()
        completion.set_model(completion_model)

        # Use model column 0 as the text column
        completion.set_text_column(0)

        self.show_all()

    def __create_completion_model(self):
        ''' Creates a tree model containing the completions.
        '''
        store = gtk.ListStore(str)

        # Append one word
        iter = store.append()
        store.set(iter, 0, "GNOME")

        # Append another word
        iter = store.append()
        store.set(iter, 0, "total")

        # And another word
        iter = store.append()
        store.set(iter, 0, "totally")

        return store

def main():
    EntryCompletionDemo()
    gtk.main()

if __name__ == '__main__':
    main()

Anon7 - 2021