hi alain,
your solution is working perfectly fine , but another problem has come up..
i modified the code to test it on a list as follows:
#!/usr/bin/python
# Build the listStore
import gtk
window=gtk.Window(gtk.WINDOW_TOPLEVEL)
window.connect("destroy",gtk.main_quit)
box1=gtk.VBox(False,0)
window.add(box1)
wordlist=['aata','abbay','acute','adistance','bobbby','cat','cbount','daddy']
liststore = gtk.ListStore(str)
for value in wordlist:
liststore.append([value])
# Build completion
completion = gtk.EntryCompletion()
completion.set_model(liststore)
completion.set_minimum_key_length(0)
completion.set_text_column(0)
completion.set_inline_completion(True)
# Built combobox
def entry_callback(widget,entry):
entered_text=entry.get_active_text()
print entered_text
entry = gtk.ComboBoxEntry(liststore, 0)
entry.get_child().set_completion(completion)
entry.get_child().set_max_length(10)
entry.connect("changed",entry_callback,entry)
box1.pack_start(entry,True,True,10)
window.show()
box1.show()
entry.show()
gtk.main()
now consider the function entry_callback. As per the character entered
character , the active text gets modified . here i am just printing that to
the console .. which hardly takes any time... but in the application i am
designing, the entry_callback function deals with large amonts of data where
the function is execute dependign upon the active text.
This is causing the program to hang since it is trying to execute the entry
based upon the constantly changing active_text. What i need is the variable
to contain the text which is finally selected by the user ie the text
selected after the enter key is pressed or say selected by a mouse click. I
tried using get_popup_accessible for this purpose but i didtn really get how
it works .
regards,
Rhitam
From: alain walter <[EMAIL PROTECTED]>
To: rhitam sanyal <[EMAIL PROTECTED]>
CC: [email protected]
Subject: Re: [pygtk] gtk.combo problem
Date: Fri, 26 Oct 2007 14:35:38 +0200
Something like that ?
# Build the listStore
liststore = gtk.ListStore(str)
for value in MyValues():
liststore.append([value])
# Build completion
completion = 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 = gtk.ComboBoxEntry(liststore, 0)
entry.get_child().set_completion(completion)
entry.get_child().set_max_length(itWidth)
rhitam sanyal a écrit :
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/
_______________________________________________
pygtk mailing list [email protected]
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
<< alain.walter.vcf >>
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/