home *** CD-ROM | disk | FTP | other *** search
/ tusportal.tus.k12.pa.us / tusportal.tus.k12.pa.us.tar / tusportal.tus.k12.pa.us / Wyse / latest-image.raw / 0.img / usr / lib / pygtk / 2.0 / demos / entry_completion.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2010-05-11  |  3KB  |  60 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. '''Entry Completion
  5.  
  6. GtkEntryCompletion provides a mechanism for adding support for
  7. completion in GtkEntry.
  8. '''
  9. import gtk
  10.  
  11. class EntryCompletionDemo(gtk.Dialog):
  12.     
  13.     def __init__(self, parent = None):
  14.         gtk.Dialog.__init__(self, self.__class__.__name__, parent, 0, (gtk.STOCK_CLOSE, gtk.RESPONSE_NONE))
  15.         
  16.         try:
  17.             self.set_screen(parent.get_screen())
  18.         except AttributeError:
  19.             self.connect('destroy', (lambda : gtk.main_quit()))
  20.  
  21.         self.connect('response', (lambda d, r: d.destroy()))
  22.         self.set_resizable(False)
  23.         vbox = gtk.VBox(False, 5)
  24.         self.vbox.pack_start(vbox, True, True, 0)
  25.         vbox.set_border_width(5)
  26.         label = gtk.Label()
  27.         label.set_markup('Completion demo, try writing <b>total</b> or <b>gnome</b> for example.')
  28.         vbox.pack_start(label, False, False, 0)
  29.         entry = gtk.Entry()
  30.         vbox.pack_start(entry, False, False, 0)
  31.         completion = gtk.EntryCompletion()
  32.         entry.set_completion(completion)
  33.         completion_model = self._EntryCompletionDemo__create_completion_model()
  34.         completion.set_model(completion_model)
  35.         completion.set_text_column(0)
  36.         self.show_all()
  37.  
  38.     
  39.     def __create_completion_model(self):
  40.         ''' Creates a tree model containing the completions.
  41.         '''
  42.         store = gtk.ListStore(str)
  43.         iter = store.append()
  44.         store.set(iter, 0, 'GNOME')
  45.         iter = store.append()
  46.         store.set(iter, 0, 'total')
  47.         iter = store.append()
  48.         store.set(iter, 0, 'totally')
  49.         return store
  50.  
  51.  
  52.  
  53. def main():
  54.     EntryCompletionDemo()
  55.     gtk.main()
  56.  
  57. if __name__ == '__main__':
  58.     main()
  59.  
  60.