Text widget - insert line

B

Beps

hello,
I have got a data list.
In my Text widget each data is between the previous and the next; so they
are whole in a only block.
Now:
|--------------------
|BushBerlusconiBlair|
|AlpacinoDeNiroStall|
|oneetcetcetcetcetce|
| |
| |
| |
| |
|-------------------|

How I have to create for each data a singular line.
right version:
|--------------------
|Bush |
|Berlusconi |
|Blair |
|Al Pacino |
|DeNiro |
|Stallone |
| |
| |
|-------------------|
Thank you very much!!!
 
E

Eric Brunel

Beps said:
hello,
I have got a data list.
In my Text widget each data is between the previous and the next; so they
are whole in a only block.
Now:
|--------------------
|BushBerlusconiBlair|
|AlpacinoDeNiroStall|
|oneetcetcetcetcetce|
| |
| |
| |
| |
|-------------------|

How I have to create for each data a singular line.
right version:
|--------------------
|Bush |
|Berlusconi |
|Blair |
|Al Pacino |
|DeNiro |
|Stallone |
| |
| |
|-------------------|
Thank you very much!!!

I'm not sure I understand the question... Do you have some code generating the
first, and you want it to generate the second? If my guess is correct, can you
show us the code? It will surely only be a matter of inserting a '\n' at the end
of each line, then do a textWidget.insert(END, ...), but I'm just guessing here...
 
B

beps

Eric Brunel ha scritto:
I'm not sure I understand the question... Do you have some code generating the
first, and you want it to generate the second? If my guess is correct, can you
show us the code? It will surely only be a matter of inserting a 'n' at the end
of each line, then do a textWidget.insert(END, ...), but I'm just guessing
here...

Here there's my code:
def show_customers(self, customers) :
## data is a list
for data in customers:
dato = operator.concat(str(data), '/n')
self.text_wdg.insert(0.0, data)####
## self.text_wdg.insert(, '/n')

But is wrong, output:
|-----------------------------|
|datadatadata/ndatadatadata/n |
|datadatadata/ndatadatadata/n |
| |
|-----------------------------|

How I can do?
Thank you
 
R

Reinhold Birkenfeld

beps said:
Eric Brunel ha scritto:
here...

Here there's my code:
def show_customers(self, customers) :
## data is a list
for data in customers:
dato = operator.concat(str(data), '/n')
^^
You have to use \n, not /n.

Reinhold
 
B

beps

^^
You have to use n, not /n.

Yes, excuse me, this is my code now:
but the following is the output :
---------------
|data[last]
|data[....]
|data[....]
|data[....]
|data[first]
|--------------

I must obtain the exact contrary :
---------------
|data[first]
|data[....]
|data[....]
|data[....]
|data[last]
|--------------

There's an error in the indices of insert() method of Text widget.
The first data line one goes on the second and so on.
I would have to obtain the exact index of the line end.
But I have not still understood and tried like making.

If you have a ready example you show it to me, please.
thanks for all
 
S

Steve Holden

beps said:
^^
You have to use n, not /n.

Reinhold


Yes, excuse me, this is my code now:


but the following is the output :
---------------
|data[last]
|data[....]
|data[....]
|data[....]
|data[first]
|--------------

I must obtain the exact contrary :
---------------
|data[first]
|data[....]
|data[....]
|data[....]
|data[last]
|--------------

There's an error in the indices of insert() method of Text widget.
The first data line one goes on the second and so on.
I would have to obtain the exact index of the line end.
But I have not still understood and tried like making.

If you have a ready example you show it to me, please.
thanks for all

This is happening because you are telling the widget to insert the new
items at the start (0.0). If you replace this with END instead it should
work as you want.

regards
Steve
 
B

beps

as you have written you I return to the problem begins them, that is the
customers do not go to new line. I must recover the index of the last
column of the data.
 
P

Peter Otten

beps said:
as you have written you I return to the problem begins them, that is the
customers do not go to new line. I must recover the index of the last

You may also try the Italian newsgroup it.comp.lang.python in case you are
not feeling entirely comfortable with the English language.

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top