I was wondering if you could help me out. I have a list box that has seltext and every time i want to select another item in the list it adds on. for example i select "/hello" then it appears as "/hello" but then i select something else it will look like this "/hello/greetings" I would like for it to refresh here is the code.
"c:/file/hello"
I would like it to change the /hello but not the c:/file.

E1.delete(len(test),len(seltext)) 
    E1.insert(INSERT, seltext)

Hmm ... I don't think the problem is there. Could you post more of the code?

Hmm ... I don't think the problem is there. Could you post more of the code?

Here is more code.

def get_list(event):
    """
    function to read the listbox selection
    and put the result in an entry widget
    """
    # get selected line index
    index = lb.curselection()[0]
    # get the line's text
    seltext = lb.get(index)
    # delete previous text in enter1
    #E1.delete(0,50)
    # now display the selected text
    test=E1.get()
    E1.delete(len(test),len(seltext)) 
    E1.insert(INSERT, seltext)

Note from vegaseat: corrected proper code tags

To append seltext to existing text in the entry widget simply use:
E1.insert(END, seltext)

Thanks for the code. But everytime I select a value its in the textbox and when I select another I want it to refresh the current position.for example:
I select scot in the list box

c:/hello/scot

then i select another in the list box

c:/hello/bob

I would want it to change just /scot to /bob

Please Help

Soemthing like that?

s = "c:/hello/scot"
if s.endswith("scot"):
    s = s.replace("scot", "bob")

print s  # c:/hello/bob

Soemthing like that?

s = "c:/hello/scot"
if s.endswith("scot"):
    s = s.replace("scot", "bob")
 
print s  # c:/hello/bob

Sorry exactly.

The program first asks you select a directory.
Then the listbox selection adds another directory.
So in other words first I select a directory with the use of:

tkFileDialog.askdirectory()

first step:
"c:/cars" the use of tkFileDialog
then its stored in the a entry box.
so now the entry box contains:
c:/cars
second step:
I select "/benz" that is the text in the listbox:
Which contains "/ferrai";"/benz";"/opel"
then the entry box contains the following
c:/cars/benz

Problem is when I select another value in the list box from benz to ferrai. It Deletes the entire path.Whenever i would like to change:benz to ferrai or opel all from the list box. I would like it to update /benz part.through the list box values

Sorry exactly.

The program first asks you select a directory.
Then the listbox selection adds another directory.
So in other words first I select a directory with the use of:

tkFileDialog.askdirectory()

first step:
"c:/cars" the use of tkFileDialog
then its stored in the a entry box.
so now the entry box contains:
c:/cars
second step:
I select "/benz" that is the text in the listbox:
Which contains "/ferrai";"/benz";"/opel"
then the entry box contains the following
c:/cars/benz

Problem is when I select another value in the list box from benz to ferrai. It Deletes the entire path.Whenever i would like to change:benz to ferrai or opel all from the list box. I would like it to update /benz part.through the list box values

You should not use a LISTBOX, but a TREE

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.