Hello again, i’m still trying to learn wxPython and have another problem, i want to read the content from a combobox with wx.CB_SIMPLE style while the user is typing and meanwhile put it in the choices area, the problem is that only the first character in the box is processed and after the box deletes all it’s content, so how to avoid it?.
Manuel Pérez wrote:
Hello again, i'm still trying to learn wxPython and have another
problem, i want to read the content from a combobox with wx.CB_SIMPLE
style while the user is typing and meanwhile put it in the choices
area, the problem is that only the first character in the box is
processed and after the box deletes all it's content, so how to avoid it?.
Show us your code, so that we can run it here. There are a hundred ways
you could have done this wrong.
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Ok, I have discovered how to add items using .Append(), but there is another problem, if i want to change some of them and i don´t know how to do, tried with .Clear(), but it also deletes the content in the writable area, so i thought could prevent this saving with .GetValue() the value in the ComboBox, but it turns the cursor at the beginning of the box, resulting so impractical, i want for a function to delete just the list-part of the widget, or the list or whatever where the values are to manipulate them as i need
···
El jueves, 12 de abril de 2018, 12:29:16 (UTC-5), Manuel Pérez escribió:
Hello again, i’m still trying to learn wxPython and have another problem, i want to read the content from a combobox with wx.CB_SIMPLE style while the user is typing and meanwhile put it in the choices area, the problem is that only the first character in the box is processed and after the box deletes all it’s content, so how to avoid it?.
and the code, sorry for the syntax, i’m lazy
#-*- coding: utf-8 -*-
from wx import *
class Search(Frame):
def __init__(self):
Frame.__init__(self, None, title = "busqueda1")
self.Show()
self.initWidgets()
self.initBindings()
self.current = "" #neede for search
def initWidgets(self):
self.chc = []#["1","2","3"]
self.searchon = ["Maria", "Pablo", "casa", "oro"]
self.combo = ComboBox(self, -1, choices = self.chc, style = CB_SIMPLE, pos = (100,30), size = (150,50))
def initBindings(self):
self.combo.Bind(EVT_TEXT, self.OnSearchF)
def OnSearchF(self, event):
while len(self.chc) > 0:
self.chc.remove(self.chc[0])
idx = None
look = self.combo.GetValue() + self.current
for entire in self.searchon:
for every in entire:
if len(look) > 0:
if look[0] == every: #la primer letra de lo escrito en buscando coincide con alguno
idx = entire.index(look[0])
equal = True
if idx != None:
if len(entire) >= (idx + len(look)):
for IsEqual in look:
if entire[idx] != IsEqual:
equal = False
idx += 1
if equal == True:
self.chc.append(entire)
idx = None
#########essentially that is the part that don't know; i added the items to the list-part of the combobox, but for delete only them...
#self.combo.Clear()
for toapp in self.chc: #
#print toapp
self.combo.Append(toapp)
if __name__=='__main__':
app = App()
frame = Search()
app.MainLoop()
···
El jueves, 12 de abril de 2018, 12:29:16 (UTC-5), Manuel Pérez escribió:
Hello again, i’m still trying to learn wxPython and have another problem, i want to read the content from a combobox with wx.CB_SIMPLE style while the user is typing and meanwhile put it in the choices area, the problem is that only the first character in the box is processed and after the box deletes all it’s content, so how to avoid it?.
I'm not sure, but maybe wx.lib.TextCtrlAutoComplete matches your use case.
I'm using that one in some of my dialogs and it works quite well.
Regards,
Dietmar
Give the Set(items) method inherited from wx.ItemContainer. IIRC it should allow you to replace just the items in the popup list.
···
On Thursday, April 12, 2018 at 12:55:52 PM UTC-7, Manuel Pérez wrote:
#########essentially that is the part that don't know; i added the items to the list-part of the combobox, but for delete only them... #self.combo.Clear() for toapp in self.chc: # #print toapp self.combo.Append(toapp)
–
Robin