[pygtk] gtk.combo problem
rhitam sanyal
rhitam_sanyal at hotmail.com
Fri Oct 26 19:42:32 WST 2007
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=python]
import gtk
window=gtk.Window(gtk.WINDOW_TOPLEVEL)
window.connect("destroy",gtk.main_quit)
combo=gtk.Combo()
combo.set_use_arrows(True)
wordlist=['aata','abbay','acute','adistance','bobbby','cat','cbount','daddy']
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=python]
def getch():
import os, tty
fd = sys.stdin.fileno()
tty_mode = tty.tcgetattr(fd)
tty.setcbreak(fd)
try:
ch = 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/
More information about the pygtk
mailing list