[pygtk] gtk.combo problem

alain walter alain.walter at thalesgroup.com
Fri Oct 26 20:35:38 WST 2007


 Something like that ?

               # Build the listStore
                liststore =3D gtk.ListStore(str)
                for value in MyValues():
                    liststore.append([value])
                # Build completion
                completion =3D gtk.EntryCompletion()
                completion.set_model(liststore)
                completion.set_minimum_key_length(0)
                completion.set_text_column(0)
                completion.set_inline_completion(True)
                # Built combobox
                entry =3D gtk.ComboBoxEntry(liststore, 0)
                entry.get_child().set_completion(completion)
                entry.get_child().set_max_length(itWidth)


rhitam sanyal a =E9crit :

> Hi all.. i am trying to create a combo with the pop down list being =

> modfied in real time as i type each character :
> [CODE=3Dpython]
> import gtk
> window=3Dgtk.Window(gtk.WINDOW_TOPLEVEL)
> window.connect("destroy",gtk.main_quit)
> combo=3Dgtk.Combo()
> combo.set_use_arrows(True)
>
> wordlist=3D['aata','abbay','acute','adistance','bobbby','cat','cbount','d=
addy'] =

>
> def entry_callback(widget,combo):
> # ------
>
> combo.entry.connect("activate",entry_callback,combo)
> window.add(combo)
> window.show()
> combo.show()
> gtk.main()
> [/CODE]
>
> now my aim is when i enter a chareacter 'a' into the combo.entry field =

> .. all the words beginning with the letter 'a'  wud be set in the =

> popdown list ... if the next character is 'c' , meaning now the entry =

> is 'ac' then the pop down list should be modified to only the word =

> 'acute' .. now the problem is the combo.entry.get_text() function will =

> return a string only when the enter key is pressed .. how do i set the =

> pop down list without pressing the enter key ?  :(    assuming i =

> already haev a function which is  a python version of the C function =

> getch() . returning the character which is pressed on the keyboard .. =

> here is the fucntion:
>
> [CODE=3Dpython]
>
> def getch():
>     import os, tty
>
>     fd =3D sys.stdin.fileno()
>     tty_mode =3D tty.tcgetattr(fd)
>     tty.setcbreak(fd)
>     try:
>             ch =3D os.read(fd, 1)
>     finally:
>             tty.tcsetattr(fd, tty.TCSAFLUSH, tty_mode)
>
>     return ch
> [/CODE]
>
> but this wud catch a chaarcter entered in the console .. how do i do =

> the same for the entry box of the combo.. any help appreciated.
> regards,
> Rhitam
>
> _________________________________________________________________
> Express yourself instantly with MSN Messenger! Download today it's =

> FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
>


-- =

Alain Walter - THALES SERVICES
01 69 88 78 73 at Eurocontrol
01 41 48 00 04 at Thales

-------------- next part --------------
A non-text attachment was scrubbed...
Name: alain.walter.vcf
Type: text/x-vcard
Size: 115 bytes
Desc: not available
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20071026/91d5559d/a=
lain.walter.vcf


More information about the pygtk mailing list